Bug P2
Status Update
Comments
sl...@google.com <sl...@google.com> #2
Thanks. We will take a look. Even though we need to figure out a way to reliably detect when a Service is actually shutdown. Thanks for the sample project makes it a lot easier to reproduce the issue.
ze...@gmail.com <ze...@gmail.com> #3
ze...@gmail.com <ze...@gmail.com> #4
I don't know the inner workings of this, but there seems to be a connection to Issue 36949180 : ServiceTestRule.bindService() returns null on 2nd invocation.
Issue 36949180 has a workaround where you repeat "serviceRule.bindService(intent)" until it no longer returns null. I tried the FooServiceTest in multiple-service-calls-test.tgz in my own project setting and test 2 to 5 failed. However, all tests succeeded after changing the bindService() method to repeatedly bind inside a while loop until the returned binder is not null.
sl...@google.com <sl...@google.com> #5
Fixed in next Runner/Rules v1.0 release.
ze...@gmail.com <ze...@gmail.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.
ta...@gmail.com <ta...@gmail.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."
sl...@google.com <sl...@google.com>
eg...@gmail.com <eg...@gmail.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" />
be...@gmail.com <be...@gmail.com> #9
Experience same problem with Manifest.permission.READ_CONTACTS and android.Manifest.permission.WRITE_CONTACTS permission
ri...@gmail.com <ri...@gmail.com> #11
I am also experiencing the same issue with Manifest.permission.ACCESS_FINE_LOCATION
fr...@gmail.com <fr...@gmail.com> #12
How do I import 1.0.2-alpha2 into my project?
[Deleted User] <[Deleted User]> #13
When should we expect a build of 1.0.2-alpha2 with this fix?
nk...@google.com <nk...@google.com> #14
alpha2 is not released just yet
dr...@gmail.com <dr...@gmail.com> #15
I tested on beta1 for ACCESS_FINE_LOCATION and it still does not work.
nk...@google.com <nk...@google.com>
vb...@gmail.com <vb...@gmail.com> #16
Any progress on this issue?
lu...@gmail.com <lu...@gmail.com> #17
Same problem here trying to grant access WRITE_EXTERNAL_STORAGE with latest 1.0.2
mu...@gmail.com <mu...@gmail.com> #18
The API isn't working for me too.
I get this in the logcat everytime I try to run my test: "junit.framework.AssertionFailedError: Failed to grant permissions, see logcat for details"
And I have done things very simple and straigt forward
@RunWith(AndroidJUnit4.class)
public class MainTest {
@Rule
public GrantPermissionRule grantPermissionRule = GrantPermissionRule.grant(Manifest.permission.WRITE_EXTERNAL_STORAGE);
private Context context;
@Before
public void setup() {
context = InstrumentationRegistry.getTargetContext();
}
}
I get this in the logcat everytime I try to run my test: "junit.framework.AssertionFailedError: Failed to grant permissions, see logcat for details"
And I have done things very simple and straigt forward
@RunWith(AndroidJUnit4.class)
public class MainTest {
@Rule
public GrantPermissionRule grantPermissionRule = GrantPermissionRule.grant(Manifest.permission.WRITE_EXTERNAL_STORAGE);
private Context context;
@Before
public void setup() {
context = InstrumentationRegistry.getTargetContext();
}
}
pa...@finanzen.net <pa...@finanzen.net> #19
This one fixed it for me. It works only with replace node for me:
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" tools:node="replace"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" tools:node="replace" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" tools:node="replace"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" tools:node="replace" />
al...@gmail.com <al...@gmail.com> #20
I am also experiencing the same issue with rules:1.0.2 while testing a custom view on an emulated Nexus 5 API 27.
Build: 3.4, AI-183.5429.30.34.5452501, 201904100040,
AI-183.5429.30.34.5452501, JRE 1.8.0_152-release-1343-b01x64 JetBrains s.r.o, OS Mac OS X(x86_64) v10.14.4, screens 1680x1050
Android Gradle Plugin: 3.4.0
Gradle: 5.2
Build: 3.4, AI-183.5429.30.34.5452501, 201904100040,
AI-183.5429.30.34.5452501, JRE 1.8.0_152-release-1343-b01x64 JetBrains s.r.o, OS Mac OS X(x86_64) v10.14.4, screens 1680x1050
Android Gradle Plugin: 3.4.0
Gradle: 5.2
sl...@google.com <sl...@google.com>
gu...@gmail.com <gu...@gmail.com> #21
i am still experience same issue.
here's my config
"androidx.test:core:1.3.0",
"androidx.test:rules:1.3.0",
here's my config
"androidx.test:core:1.3.0",
"androidx.test:rules:1.3.0",
su...@gmail.com <su...@gmail.com> #22
Any update on this issue?
I was facing the same issue, the following code won't work on Android R physical device:
@Rule
public GrantPermissionRule rule = GrantPermissionRule.grant(
Manifest.permission.ACCESS_FINE_LOCATION,
Manifest.permission.WRITE_EXTERNAL_STORAGE
);
av...@gmail.com <av...@gmail.com> #23
tools:node="replace" adding this to permission on manifest worked for me.
ae...@google.com <ae...@google.com> #24
This bug has not been updated in over a year. Please reopen if this is still an issue or requires addition inspection.
Description
Version used: Rules 1.0.0
What steps will reproduce the problem?
1. Use new GrantPermissionRule with WRITE_EXTERNAL_STORAGE in your test
@Rule
public GrantPermissionRule mRuntimePermissionRule =
GrantPermissionRule.grant(Manifest.permission.WRITE_EXTERNAL_STORAGE);
2. Use a method in app code which tries to write to internal sdcard (create a new folder on external sdcard)
In my Application.java:
public void createDir() throws IOException {
new File(Environment.getExternalStorageDirectory() + "/test").createNewFile();
}
How are you running your tests (via Android Studio, Gradle, adb, etc.)?
Android Studio
What is the expected output? What do you see instead?
In the app settings the permission is enabled and the call should work but it throws the following exception:
java.io.IOException: Permission denied
at java.io.UnixFileSystem.createFileExclusively0(Native Method)
at java.io.UnixFileSystem.createFileExclusively(UnixFileSystem.java:280)
at java.io.File.createNewFile(File.java:948)
at test.app.directory.Application.createDir(EarApplication.java:253)
at test.app.directory.ExternalDirTest.test(ExternalDirTest.java:24)
at java.lang.reflect.Method.invoke(Native Method)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at android.support.test.rule.GrantPermissionRule$RequestPermissionStatement.evaluate(GrantPermissionRule.java:109)
at org.junit.rules.RunRules.evaluate(RunRules.java:20)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runners.Suite.runChild(Suite.java:128)
at org.junit.runners.Suite.runChild(Suite.java:27)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at org.junit.runner.JUnitCore.run(JUnitCore.java:115)
at android.support.test.internal.runner.TestExecutor.execute(TestExecutor.java:58)
at android.support.test.runner.AndroidJUnitRunner.onStart(AndroidJUnitRunner.java:369)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1932)