Fixed
Status Update
Comments
ar...@google.com <ar...@google.com> #2
Can you please attach the full logcat output to this bug, so we can take a look?
ma...@tomtom.com <ma...@tomtom.com> #3
Yes of course. Here the full logcat. Tested on multiple devices for example Moto G5, Samsung A5 and Nexus 5 (but custom rom)
ar...@google.com <ar...@google.com> #4
I've tested it today also on the Nexus 5X (Dev Preview 4) and Nexus 5 without custom rom.
ma...@tomtom.com <ma...@tomtom.com> #5
Thanks! I will try to see if I can reproduce it on a device. What's interesting though is that the permission seems to be already granted to the package. If you look at your log cat output, right before the exception there is this line: "I/GrantPermissionCallable: Permission: android.permission.WRITE_EXTERNAL_STORAGE is already granted!". What GPC does is to verify that the permission was actually granted for the target context (app under test). One thing that would be interesting if you could run "adb shell pm dump <package> | grep permission" after you ran the tests and paste the outputs here. Thanks.
ar...@google.com <ar...@google.com> #6
Hi sorry for the late response:
I get the following respone from the command:
requested permissions:
android.permission.INTERNET
android.permission.WRITE_EXTERNAL_STORAGE
android.permission.READ_EXTERNAL_STORAGE
android.permission.RECORD_AUDIO
android.permission.SET_ALARM
android.permission.RECEIVE_BOOT_COMPLETED
android.permission.WAKE_LOCK
android.permission.ACCESS_NETWORK_STATE
android.permission.ACCESS_FINE_LOCATION
install permissions:
android.permission.RECEIVE_BOOT_COMPLETED: granted=true
android.permission.INTERNET: granted=true
android.permission.ACCESS_NETWORK_STATE: granted=true
android.permission.WAKE_LOCK: granted=true
runtime permissions:
android.permission.WRITE_EXTERNAL_STORAGE: granted=true
android.permission.RECORD_AUDIO: granted=true
ACTIVITY MANAGER URI PERMISSIONS (dumpsys activity permissions)
time="26.9.2017, 18:55" type=MOVE_TO_FOREGROUND package=com.google.android.packageinstaller class=com.android.packageinstaller.permission.ui.ManagePermissionsActivity
time="26.9.2017, 18:56" type=MOVE_TO_BACKGROUND package=com.google.android.packageinstaller class=com.android.packageinstaller.permission.ui.ManagePermissionsActivity
time="26.9.2017, 19:14" type=MOVE_TO_FOREGROUND package=com.google.android.packageinstaller class=com.android.packageinstaller.permission.ui.GrantPermissionsActivity
time="26.9.2017, 19:14" type=MOVE_TO_BACKGROUND package=com.google.android.packageinstaller class=com.android.packageinstaller.permission.ui.GrantPermissionsActivity
time="26.9.2017, 19:20" type=MOVE_TO_FOREGROUND package=com.google.android.packageinstaller class=com.android.packageinstaller.permission.ui.GrantPermissionsActivity
time="26.9.2017, 19:20" type=MOVE_TO_BACKGROUND package=com.google.android.packageinstaller class=com.android.packageinstaller.permission.ui.GrantPermissionsActivity
So it seems that the permission is granted. But I get all the time the exception.
I get the following respone from the command:
requested permissions:
android.permission.INTERNET
android.permission.WRITE_EXTERNAL_STORAGE
android.permission.READ_EXTERNAL_STORAGE
android.permission.RECORD_AUDIO
android.permission.SET_ALARM
android.permission.RECEIVE_BOOT_COMPLETED
android.permission.WAKE_LOCK
android.permission.ACCESS_NETWORK_STATE
android.permission.ACCESS_FINE_LOCATION
install permissions:
android.permission.RECEIVE_BOOT_COMPLETED: granted=true
android.permission.INTERNET: granted=true
android.permission.ACCESS_NETWORK_STATE: granted=true
android.permission.WAKE_LOCK: granted=true
runtime permissions:
android.permission.WRITE_EXTERNAL_STORAGE: granted=true
android.permission.RECORD_AUDIO: granted=true
ACTIVITY MANAGER URI PERMISSIONS (dumpsys activity permissions)
time="26.9.2017, 18:55" type=MOVE_TO_FOREGROUND package=com.google.android.packageinstaller class=com.android.packageinstaller.permission.ui.ManagePermissionsActivity
time="26.9.2017, 18:56" type=MOVE_TO_BACKGROUND package=com.google.android.packageinstaller class=com.android.packageinstaller.permission.ui.ManagePermissionsActivity
time="26.9.2017, 19:14" type=MOVE_TO_FOREGROUND package=com.google.android.packageinstaller class=com.android.packageinstaller.permission.ui.GrantPermissionsActivity
time="26.9.2017, 19:14" type=MOVE_TO_BACKGROUND package=com.google.android.packageinstaller class=com.android.packageinstaller.permission.ui.GrantPermissionsActivity
time="26.9.2017, 19:20" type=MOVE_TO_FOREGROUND package=com.google.android.packageinstaller class=com.android.packageinstaller.permission.ui.GrantPermissionsActivity
time="26.9.2017, 19:20" type=MOVE_TO_BACKGROUND package=com.google.android.packageinstaller class=com.android.packageinstaller.permission.ui.GrantPermissionsActivity
So it seems that the permission is granted. But I get all the time the exception.
ar...@google.com <ar...@google.com>
nk...@google.com <nk...@google.com>
nk...@google.com <nk...@google.com> #7
I experienced the same issue using Rules 1.0.1 on Nexus 5X running Android 8.0
I found a workaround for this issue where I also grant the 'Manifest.permission.READ_EXTERNAL_STORAGE' permission and then things work as expected.
So instead of:
GrantPermissionRule.grant(Manifest.permission.WRITE_EXTERNAL_STORAGE);
I use:
GrantPermissionRule.grant(Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.READ_EXTERNAL_STORAGE);
The issue could be (this is just my guess):
'GrantPermissionRule.grant(Manifest.permission.WRITE_EXTERNAL_STORAGE)' only grants write permission. However, when requesting the write permission using the Android system dialog both the write and read permissions are granted. This is also the expected behaviour as described in the Manifest.permission class:
https://developer.android.com/reference/android/Manifest.permission.html#READ_EXTERNAL_STORAGE
"Any app that declares the WRITE_EXTERNAL_STORAGE permission is implicitly granted this permission."
I found a workaround for this issue where I also grant the 'Manifest.permission.READ_EXTERNAL_STORAGE' permission and then things work as expected.
So instead of:
GrantPermissionRule.grant(Manifest.permission.WRITE_EXTERNAL_STORAGE);
I use:
GrantPermissionRule.grant(Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.READ_EXTERNAL_STORAGE);
The issue could be (this is just my guess):
'GrantPermissionRule.grant(Manifest.permission.WRITE_EXTERNAL_STORAGE)' only grants write permission. However, when requesting the write permission using the Android system dialog both the write and read permissions are granted. This is also the expected behaviour as described in the Manifest.permission class:
"Any app that declares the WRITE_EXTERNAL_STORAGE permission is implicitly granted this permission."
nk...@google.com <nk...@google.com> #8
Experienced same problem after updating hockey sdk to version 5.0.3.
After investigating I found that hockey sdk declares following in AndroidManifest.xml:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="18" />
While my app main library just defines following in AndroidManifest.xml:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
Fixed by changing main library manifest to following:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"
tools:node="replace" />
After investigating I found that hockey sdk declares following in AndroidManifest.xml:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="18" />
While my app main library just defines following in AndroidManifest.xml:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
Fixed by changing main library manifest to following:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"
tools:node="replace" />
nk...@google.com <nk...@google.com> #9
Experience same problem with Manifest.permission.READ_CONTACTS and android.Manifest.permission.WRITE_CONTACTS permission
ma...@tomtom.com <ma...@tomtom.com> #10
Fix will be available in 1.0.2-alpha2
Description
E/TestExecutor: Fatal exception when running tests
java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/v4/app/DialogFragment;
at java.lang.Class.classForName(Native Method)
at java.lang.Class.forName(Class.java:400)
at android.support.test.internal.runner.TestLoader.doCreateRunner(TestLoader.java:76)
at android.support.test.internal.runner.TestLoader.getRunnersFor(TestLoader.java:104)
at android.support.test.internal.runner.TestRequestBuilder.build(TestRequestBuilder.java:808)
at android.support.test.runner.AndroidJUnitRunner.buildRequest(AndroidJUnitRunner.java:481)
at android.support.test.runner.AndroidJUnitRunner.onStart(AndroidJUnitRunner.java:367)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1962)
Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.v4.app.DialogFragment" on path: DexPathList[[zip file "/system/framework/android.test.runner.jar", zip file "/data/app/com.extension.runnercrashapp.test-2/base.apk"],nativeLibraryDirectories=[/data/app/com.extension.runnercrashapp.test-2/lib/arm64, /system/lib64, /vendor/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at java.lang.Class.classForName(Native Method)
at java.lang.Class.forName(Class.java:400)
at android.support.test.internal.runner.TestLoader.doCreateRunner(TestLoader.java:76)
at android.support.test.internal.runner.TestLoader.getRunnersFor(TestLoader.java:104)
at android.support.test.internal.runner.TestRequestBuilder.build(TestRequestBuilder.java:808)
at android.support.test.runner.AndroidJUnitRunner.buildRequest(AndroidJUnitRunner.java:481)
at android.support.test.runner.AndroidJUnitRunner.onStart(AndroidJUnitRunner.java:367)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1962)
it happens only if module from gradle dependency is excluded, for example:
implementation ("com.google.android.gms:play-services-analytics:11.0.4") {
exclude group: 'com.android.support', module: 'support-v4'
}
Tested on devices with Android 5 and 7.
With version 0.5 of com.android.support.test:runner it wasn't happening.
To reproduce, run android tests from android studio or gradle connectedCheck
Small example project is available here: