Open De47h69 opened 11 months ago
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.
You can extract the logcat stuff when you're connected to your device with adb shell
and then run the following command
logcat | grep com.newsolutions.checkware2
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
Some OEMs strip meta-data from the manifest. This is problematic as FileProvider was depending on meta-data to specify a resource containing the paths that should be shared.
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 getUriForFile
function from the FileProvider which internally calls getPathStrategy
-> parsePathStrategy
-> getFileProviderPathsMetaData
and then ends on line 664 in the FileProvider.java file with the exception that's displayed in Logcat
if (info == null) { throw new IllegalArgumentException( "Couldn't find meta-data for provider with authority " + authority); }
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:
public class FileProvider extends androidx.core.content.FileProvider {
private static final String LOG_TAG = "FileProvider";
public FileProvider() {
super(R.xml.camera_provider_paths);
LOG.d(LOG_TAG, "ResourceId" + R.xml.camera_provider_paths);
}
}
When i debug the application it returns the Id for the meta-data file which is 2131951616 and writes the log into Logcat
FileProvider com.newsolutions.checkware2 D ResourceID: 2131951616
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
` CameraLauncher com.newsolutions.checkware2 D photo: /data/user/0/com.newsolutions.checkware2/cache/.Pic.jpg
CameraLauncher com.newsolutions.checkware2 D imageFilePath: /data/user/0/com.newsolutions.checkware2/cache/.Pic.jpg
CameraLauncher com.newsolutions.checkware2 D activity: com.newsolutions.checkware2.MainActivity@a19591
CameraLauncher com.newsolutions.checkware2 D authority: com.newsolutions.checkware2.cordova.plugin.camera.provider
CameraLauncher com.newsolutions.checkware2 D -------------------`
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. It only happens after I download the apk from the PlayStore. You can't reproduce this issue when debugging.
Is there some flag or something I can set in my release workflow so I can debug the Release version?
s there some flag or something I can set in my release workflow so I can debug the Release version?
In your AndroidManifest.xml
, try setting android:debuggable="true"
on your <application>
tag.
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 build.gradle
file.
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)
Note that a release build with debuggable enabled will be rejected in the play store.
Will it be rejected even if I only push it to interal testing?
Not sure about ProGuard. I'm gonna investigate that one
Will it be rejected even if I only push it to interal testing?
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
Given this line from logcat
java.lang.RuntimeException: Failure delivering result ResultInfo{who=@android:requestPermissions:, request=0, result=-1, data=Intent
why is the request amount 0? it should request more than zero permissions right?
So compiling and signing it with ProGuard enabled doesn't change the fact that the generated APK runs fine.
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.
why is the request amount 0? it should request more than zero permissions right?
I believe that's just simply a side effect of the full error:
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
The main error is java.lang.IllegalArgumentException: Couldn't find meta-data for provider with authority com.newsolutions.checkware2.cordova.plugin.camera.provider
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.
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
https://github.com/apache/cordova-plugin-camera/assets/154965518/38d90cca-6dd0-4015-bcd5-b1a14634d4c1
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