I tried adding an instant app feature to my app, but when launching my app as an instant app I'm getting this error :
RuntimeException: Unable to get provider android.support.v4.content.FileProvider: java.lang.SecurityException: Provider must grant uri permissions
Here is how it's used in my feature
Manifest:
<manifest>
<application>
<provider
android:name="android.support.v4.content.FileProvider"
android:authorities="${applicationId}.provider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/provider_paths" />
</provider>
</application>
</manifest>
And my instant-app build.gradle
:
apply plugin: 'com.android.instantapp'
android {
compileSdkVersion rootProject.compileSdk
defaultConfig {
applicationId "applicationId" // same than my app's APK module
minSdkVersion rootProject.minSdk
targetSdkVersion rootProject.compileSdk
versionCode rootProject.versionCode
versionName rootProject.versionName
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation project(':feature') // app's feature
}
What is wrong? Thanks for your help.
EDIT : Here is the complete logcat:
02-13 17:51:28.501 28992-28992/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: package, PID: 28992
java.lang.RuntimeException: Unable to get provider android.support.v4.content.FileProvider: java.lang.SecurityException: Provider must grant uri permissions
at android.app.ActivityThread.installProvider(ActivityThread.java:6206)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:5721)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5639)
at android.app.ActivityThread.-wrap2(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1637)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:156)
at android.app.ActivityThread.main(ActivityThread.java:6523)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:941)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:831)
Caused by: java.lang.SecurityException: Provider must grant uri permissions
at android.support.v4.content.FileProvider.attachInfo(FileProvider.java:375)
at android.app.ActivityThread.installProvider(ActivityThread.java:6203)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:5721)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5639)
at android.app.ActivityThread.-wrap2(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1637)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:156)
at android.app.ActivityThread.main(ActivityThread.java:6523)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:941)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:831)
02-13 17:51:28.535 28932-28944/? E/Isotope: UID: [10188] PID: [28932] IActivityManagerProxy : Instant app: package crashed: java.lang.RuntimeException: Unable to get provider android.support.v4.content.FileProvider: java.lang.SecurityException: Provider must grant uri permissions
at android.app.ActivityThread.installProvider(ActivityThread.java:6206)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:5721)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5639)
at android.app.ActivityThread.-wrap2(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1637)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:156)
at android.app.ActivityThread.main(ActivityThread.java:6523)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:941)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:831)
Caused by: java.lang.SecurityException: Provider must grant uri permissions
at android.support.v4.content.FileProvider.attachInfo(FileProvider.java:375)
at android.app.ActivityThread.installProvider(ActivityThread.java:6203)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:5721)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5639)
at android.app.ActivityThread.-wrap2(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1637)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:156)
at android.app.ActivityThread.main(ActivityThread.java:6523)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:941)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:831)
It looks like the FileProvider
isn't supported on O either because other apps aren't allowed to see its ContentProvider
.
I have a test app that works as an installed app but not as an instant app. It looks like instant apps aren't allowed to use grantUriPermission
(grant URI permissions) (which makes sense given the policy that instant apps can't be visible to installed apps and ContentProvider
is not visible).
This means that instant apps can't retrieve pictures taken with ACTION_IMAGE_CAPTURE
(because they can't read external storage and the camera app can't write to instant apps' private storage).