WRITE_EXTERNAL_STORAGE permission is removed by HockeyApp #356
Description
The HockeyApp SDK sets an android:maxSdkVersion="18"
attribute on the WRITE_EXTERNAL_STORAGE permission in its AndroidManifest, which removes the permission on higher API levels. I don't know why this attribute is there, but it is causing problems in our app.
Example: Our app uses LeakCanary and Spoon, both of which require this permission to work correctly. Even though we put the <uses-permission>
tag in our debug AndroidManifest, these tools always fail. Apparently the merged manifest also contains the android:maxSdkVersion
attribute. These kind of hidden attributes are very difficult to discover. I actually thought it was some new security policy in Android that was causing LeakCanary to fail.
Is it possible to remove the attribute from the SDK, and leave the permissions up to the end user? Perhaps HockeyApp can print a warning in the Logs or a show Toast if the permission is missing.
Activity
smuldr commentedon Jan 26, 2018
For anyone having the same issue, you can remove the
android:MaxSdkVersion
attribute from the merged manifest as follows.MatkovIvan commentedon Jan 26, 2018
Duplicate of #301
MatkovIvan commentedon Jan 26, 2018
Hi @smuldr,
This is described in our documentation and release notes:
Best,
Ivan
Iqra786 commentedon Feb 22, 2018
Hi,
I have tried all solution but no success.
ElektrojungeAtWork commentedon Feb 22, 2018
Hi @Iqra786,
have you tried
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" tools:node="replace"/>
as well as<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" tools:node="remove" />
?Iqra786 commentedon Feb 23, 2018
Hi, @TroubleMakerBen
Yes, I have tried both.
ElektrojungeAtWork commentedon Feb 23, 2018
Is there any chance you can send us the project (or a sample that has this behavior)? We cannot repro this and I'm running out of ideas. To do that, please contact us via Support and mention this conversation.
Thx a ton!
tobi512 commentedon Mar 27, 2018
@Iqra786 @TroubleMakerBen
I can confirm that replacing the
maxSdkVersion
works as expected for us with the following ways:tools:node="replace"
andtools:remove="android:maxSdkVersion"
.However,
tools:node="remove"
only removes the permission itself and not themaxSdkVersion
restriction, so don't use this!We also have Spoon and LeakCanary besides HockeySDK in our project, did you make sure to check your merged manifest (tab "Merged Manifest" in Android Studio).
If you have multiple manifest files in your project for more than one module, you should also check if the right one is used.
The following screenshots show the difference in our final merged manifest (first one without the additional code, resulting in the
maxSdkVersion
to be incorrectly present, and the second one with themaxSdkVersion
replaced/removed correctly).Hope this helps you in finding your problem cause...
Btw: don't ask me why the READ_EXTERNAL_STORAGE permission occurs twice in the final merge result 😄
rusmonster commentedon Jul 24, 2018
Adding
tools:node="replace"
helps for me, but now I have the warningTask :app:processDebugManifest /Android/app/AndroidManifest.xml:6:2-131 Warning: uses-permission#android.permission.WRITE_EXTERNAL_STORAGE was tagged at AndroidManifest.xml:6 to replace another declaration but no other declaration present
Any ideas how to avoid or at least suppress it?
jaeklim commentedon Jul 24, 2018
@rusmonster The warning tells you that you don't have any tags to be replaced. Looks like your project doesn't contain HockeyApp dependencies, can you make sure your app contains HockeyApp libraries in it?
rusmonster commentedon Jul 25, 2018
@jaelim-ms Yes, I'm sure my app contains hockeyApp. Moreover, without
tools:node="replace"
hockeyApp drops WRITE_EXTERNAL_STORAGE in my app on API > 18 and adding thetools:node="replace"
returns it back. So the warning looks like manifest merger issue. I'm just asking about how to suppress it?jaeklim commentedon Jul 25, 2018
@rusmonster I've tried to find a way to suppress the warning but couldn't find any. Sorry about that. I keep searching it and let you know if I find but the warning isn't from lint so I don't think you can suppress it.
jaeklim commentedon Jul 30, 2018
We have another open issue regarding the permission issue. Please continue conversation in #373.