-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Android 13 app crashes when trying to access the provider-path meta-data file #878
Comments
can you provide a sample app that reproduces the issue? |
It will take some time to set up a working test project. In the meantime you can test my release version. Apparently Github doesn't accept .zip files even though it says so... The file should be available for the public https://download.germanedge.com/index.php/s/WJ9RxoF2L8DntKG Just follow the workflow i provided in the gif.
|
Thanks for the app, but we don’t request sample apps because we don’t believe you, we ask for sample apps for being able to reproduce the issue in an app we can debug and use that app to verify a possible fix, so a release version is not useful. |
My intention was so that you can see it for yourself in Logcat, since I can't reproduce this issue when I debug the app. Only happens when I install it from the Play Store. Currently setting up a sample |
Ok, I've done some extensive digging on this issue. It seems that the meta-data file get stripped from the apk on installation. There was a bugfix for that in the Android.core.content.FileProvider stuff as seen here https://android-review.googlesource.com/c/platform/frameworks/support/+/1978527 Most important here is
Because of that I set the ANDROIDX_CORE_VERSION to 1.9.0 which includes the fix, but that sadly didn't fixed it From what I could gather from the FileProvider implementation in the core package it calls the Another suggestions that was made was to call super of the FileProvider with the ResourceId of the meta-data file so i adjusted the org.apache.cordova.camera.FileProvider to this:
When i debug the application it returns the Id for the meta-data file which is 2131951616 and writes the log into Logcat
However when I install the apk via the PlayStore this Log entry won't be written which is weird I added some logging into the CameraLauchner.java file and this is the output
So the file for the picture gets created as intended, the cache folder exists and the authority is also correct. There seems to be some kind of issue when the apk gets installed on the device. When I inspect the release apk from the PlayStore page the xml file exists I tried to recreate this issue in a sample project. However I can't recreate it locally in debug or if I create a Signed APK or AAB via Android Studio. Is there some flag or something I can set in my release workflow so I can debug the Release version? |
In your https://developer.android.com/guide/topics/manifest/application-element#debug By default its true for debug builds and false for release builds. When true it should allow the native debugger to be attached. Note that a release build with debuggable enabled will be rejected in the play store. So if the issue truly only occurs on a build variant from the play store, then this won't help. If you have any plugins that manipulates the AndroidManifest it may get overwritten if you use the cordova command line, in which case you can try setting: android {
buildTypes {
release {
debuggable true
}
}
} in the app's In other thoughts, if you use proguard I'd try disabling it (or enable it for your debug build to see if it breaks then) |
Not sure about ProGuard. I'm gonna investigate that one |
Good question... not 100% sure, but I feel like I recall Google producing an error on upload complaining its a debuggable artefact... so I think so, but not really sure. |
Thanks for your answers. I'm gonna test your suggestions and see what comes from it |
Ok. So compiling and signing it with ProGuard enabled doesn't change the fact that the generated APK runs fine. So this is really some issue when it's uploaded to the PlayStore. Interestingly enough now the Store APK also crashes on Devices running Android 12 and lower. But that could also be a problem with my changes. Gonna revert that and test it again. EDIT: Well, even my older releases aren't working anymore with Android 12 and lower 😕 I have zero idea what's going on Oh and yeah, the PlayStore refuses the upload if android:debuggable is set to true 🙄 I guess I'm gonna contact google now. Maybe they can tell me what the heck is going on |
Actually there's one more thing that confuses me |
Just wanted to clarify that ProGuard should be disabled unless you know what you're doing. ProGuard adds a layer of protection to your app against reverse engineering. It does so by obfuscating your compiled code, mangling symbol names, etc... which can break stuff, especially in Cordova where it relies on dynamic references by string names. In this case, I was worried it was breaking the manifest mapping.
I believe that's just simply a side effect of the full error:
The main error is |
Yeah, I know what it's doing. Opening the release APK from the store reveals that the meta-data file is still present. At least in the Universal APK that you can download from the internal pages. Adding obfuscation doesn't change the fact that the file is still present It just changes the filename to something stupid |
Bug Report
Problem
Android 13
App crashes when permission is granted for the first time. After requesting the permission once, the "Take Picture" button has no effect. Selecting an image from the gallery works.
Note: This only happens in the Release version from the store
What is expected to happen?
Upon requesting the permission to take photos the camera intent should start and i should be able to take a photo with the camera
What does actually happen?
App is crashing when when granting the permission to take photos
screen-20231227-093301.mp4
Information
This is the stacktrace from logcat
FATAL EXCEPTION: main Process: com.newsolutions.checkware2, PID: 14859 java.lang.RuntimeException: Failure delivering result ResultInfo{who=@android:requestPermissions:, request=0, result=-1, data=Intent { act=android.content.pm.action.REQUEST_PERMISSIONS (has extras) }} to activity {com.newsolutions.checkware2/com.newsolutions.checkware2.MainActivity}: java.lang.IllegalArgumentException: Couldn't find meta-data for provider with authority com.newsolutions.checkware2.cordova.plugin.camera.provider at android.app.ActivityThread.deliverResults(ActivityThread.java:5994) at android.app.ActivityThread.handleSendResult(ActivityThread.java:6033) at android.app.servertransaction.ActivityResultItem.execute(ActivityResultItem.java:67) at android.app.servertransaction.ActivityTransactionItem.execute(ActivityTransactionItem.java:45) at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135) at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2574) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loopOnce(Looper.java:226) at android.os.Looper.loop(Looper.java:313) at android.app.ActivityThread.main(ActivityThread.java:8757) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1067) Caused by: java.lang.IllegalArgumentException: Couldn't find meta-data for provider with authority com.newsolutions.checkware2.cordova.plugin.camera.provider at androidx.core.content.FileProvider.getFileProviderPathsMetaData(FileProvider.java:664) at androidx.core.content.FileProvider.parsePathStrategy(FileProvider.java:695) at androidx.core.content.FileProvider.getPathStrategy(FileProvider.java:645) at androidx.core.content.FileProvider.getUriForFile(FileProvider.java:449) at org.apache.cordova.camera.CameraLauncher.takePicture(CameraLauncher.java:332) at org.apache.cordova.camera.CameraLauncher.onRequestPermissionResult(CameraLauncher.java:1394) at org.apache.cordova.CordovaInterfaceImpl.onRequestPermissionResult(CordovaInterfaceImpl.java:222) at org.apache.cordova.CordovaActivity.onRequestPermissionsResult(CordovaActivity.java:527) at android.app.Activity.dispatchRequestPermissionsResult(Activity.java:9124) at android.app.Activity.dispatchActivityResult(Activity.java:8955) at android.app.ActivityThread.deliverResults(ActivityThread.java:5987) at android.app.ActivityThread.handleSendResult(ActivityThread.java:6033) at android.app.servertransaction.ActivityResultItem.execute(ActivityResultItem.java:67) at android.app.servertransaction.ActivityTransactionItem.execute(ActivityTransactionItem.java:45) at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135) at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2574) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loopOnce(Looper.java:226) at android.os.Looper.loop(Looper.java:313) at android.app.ActivityThread.main(ActivityThread.java:8757) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1067)
Command or Code
Blank app with camera plugin
Environment, Platform, Device
Android 13 Samsung Galaxy A32
Android 13 Lenovo Tab M10 Plus 3rd Gen
Android 13 Samsung Galaxy Tab S7
Android 14 Google Pixel Pro 7
Works fine on Android 12 and below and also on LineageOS Android 13
Version information
packages.json
Generated AndroidManifest.xml
Checklist
The text was updated successfully, but these errors were encountered: