I test my application locally using Espresso with an Android API 22 emulator and it works. I have this in my Manifest.xml:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
I also ask for permissions at runtime, as required after Android 23. However when Travis CI is running the tests with a same API emulator, the app throws an error:
02:10:29 V/InstrumentationResultParser: Caused by: java.io.FileNotFoundException: /storage/sdcard/dd3c49bc-efdb-41b9-90af-e814ca17c59d.png: open failed: EACCES (Permission denied)
This is my .travis.yml:
language: android
jdk: oraclejdk8
sudo: false
android:
components:
- tools
- platform-tools
- build-tools-28.0.3
- android-28
- android-22
- extra-google-google_play_services
- extra-google-m2repository
- extra-android-m2repository
- sys-img-armeabi-v7a-android-22
before_script:
- touch local.properties
- chmod +x gradlew
- echo no | android create avd --force -n test -t android-22 --abi armeabi-v7a
- emulator -avd test -no-audio -no-window &
- android-wait-for-emulator
- adb shell input keyevent 82 &
script:
- ./gradlew clean build connectedCheck
I also opened a question in StackOverFlow with this problem: EACCES (Permission denied) in Travis CI Android Emulator - Stack Overflow
This is the repo Travis is building: Travis CI - Test and Deploy with Confidence