3

I am facing a lot of trouble trying to integrate screenshotter library from here, into my very simple Android project. I followed the steps outlined in the tutorial pretty meticulously.

When I look at logs from gcloud I see the following error

01-07 19:41:06.724: E/cloud_screenshotter(5752): Exception taking screenshot: java.io.FileNotFoundException: /sdcard/screenshots/com.computemachines.android.workplay.ClockingActivityScreenshotTest-takeScreenshot-main_screen_3-1.jpg: open failed: ENOENT (No such file or directory)

Funnily enough, I have a different project in the same computer with almost identical build structure in which taking screenshots work! The gradle version, test case, build.gradle files are exactly the same in both.

An excerpt from app/build.gradle in the repo that doesn't work

androidTestCompile (name:'cloudtestingscreenshotter_lib', ext:'aar')
    compile fileTree(dir: 'libs', include: ['*.jar'])
    // Espresso testing
    androidTestCompile 'com.android.support.test:runner:0.5'
    androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2'
    androidTestCompile 'com.android.support:support-annotations:25.1.0', {
        exclude group: 'com.google.code', module: 'jsr305'
}

The whole repo that doesn't work is at GitHub and the repo that works is here.

The invocation command for invoking the builds and running on GCloud is the same for both

./gradlew clean assembleDebug assembleDebugAndroidTest && gcloud beta test android run \
  --type instrumentation \
  --app app/build/outputs/apk/app-debug-unaligned.apk \
  --test app/build/outputs/apk/*est-unaligned.apk \
  --device-ids Nexus6 \
  --os-version-ids 23 \
  --locales en \
  --orientations portrait

I have spent more than 10 hours on trying to figure this out and a summary mind map of all things I tried is here. I can provide any other information that is needed but wanted to solve this problem.

AL.
  • 36,815
  • 10
  • 142
  • 281
satyajit
  • 1,470
  • 3
  • 22
  • 43

1 Answers1

2

In order to write the screenshot to the expected location, the app must hold the WRITE_EXTERNAL_STORAGE permission, as described in the documentation.

Doug Stevenson
  • 297,357
  • 32
  • 422
  • 441
  • In the sample app yes I was missing the permission in the android manifest file. In my main project I had a seperate AndroidManfiest.xml with this permission in the androidTest folder but for it to merge correctly I also needed android:userid as explained in http://stackoverflow.com/a/14196493/31252 – satyajit Jan 10 '17 at 22:11
  • I've never heard of userid ever being a problem for anyone before. – Doug Stevenson Jan 11 '17 at 03:00