Unable to enable useAndroidX ad to use FileProvider
-
wrote on 26 Feb 2022, 11:38 last edited by
Testo di origine
The latest android api levels require FileProvider implementation to create and share files.
So the tutorial
https://developer.android.com/reference/androidx/core/content/FileProvider
does not work in Qt world because, after having added the section<provider android:name="androidx.core.content.FileProvider" android:authorities="org.qtproject.example" android:exported="false" android:grantUriPermissions="true"> <meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/file_paths" /> </provider>
after having added the file file_path.xml and
android.useAndroidX=true android.enableJetifier=true
in the gradle.properties, during statup the application goes to crash with
E AndroidRuntime: FATAL EXCEPTION: main E AndroidRuntime: Process: org.qtproject.example, PID: 2905 E AndroidRuntime: java.lang.RuntimeException: Unable to get provider androidx.core.content.FileProvider: java.lang.ClassNotFoundException: Didn't find class "androidx.core.content.FileProvider" on path: DexPathList[[zip file "/data/app/org.qtproject.example-KFKpcJodUkUxx65aKHw76A==/base.apk"],nativeLibraryDirectories=[/data/app/org.qtproject.example-KFKpcJodUkUxx65aKHw76A==/lib/arm, /data/app/org.qtproject.example-KFKpcJodUkUxx65aKHw76A==/base.apk!/lib/armeabi-v7a, /system/lib, /vendor/lib]] E AndroidRuntime: at android.app.ActivityThread.installProvider(ActivityThread.java:6242) E AndroidRuntime: at android.app.ActivityThread.installContentProviders(ActivityThread.java:5805) E AndroidRuntime: at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5722) E AndroidRuntime: at android.app.ActivityThread.-wrap1(Unknown Source:0)
Have you got the same behaviour? Any idea to resolve?
-
Testo di origine
The latest android api levels require FileProvider implementation to create and share files.
So the tutorial
https://developer.android.com/reference/androidx/core/content/FileProvider
does not work in Qt world because, after having added the section<provider android:name="androidx.core.content.FileProvider" android:authorities="org.qtproject.example" android:exported="false" android:grantUriPermissions="true"> <meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/file_paths" /> </provider>
after having added the file file_path.xml and
android.useAndroidX=true android.enableJetifier=true
in the gradle.properties, during statup the application goes to crash with
E AndroidRuntime: FATAL EXCEPTION: main E AndroidRuntime: Process: org.qtproject.example, PID: 2905 E AndroidRuntime: java.lang.RuntimeException: Unable to get provider androidx.core.content.FileProvider: java.lang.ClassNotFoundException: Didn't find class "androidx.core.content.FileProvider" on path: DexPathList[[zip file "/data/app/org.qtproject.example-KFKpcJodUkUxx65aKHw76A==/base.apk"],nativeLibraryDirectories=[/data/app/org.qtproject.example-KFKpcJodUkUxx65aKHw76A==/lib/arm, /data/app/org.qtproject.example-KFKpcJodUkUxx65aKHw76A==/base.apk!/lib/armeabi-v7a, /system/lib, /vendor/lib]] E AndroidRuntime: at android.app.ActivityThread.installProvider(ActivityThread.java:6242) E AndroidRuntime: at android.app.ActivityThread.installContentProviders(ActivityThread.java:5805) E AndroidRuntime: at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5722) E AndroidRuntime: at android.app.ActivityThread.-wrap1(Unknown Source:0)
Have you got the same behaviour? Any idea to resolve?
wrote on 12 Jan 2024, 14:53 last edited byAt https://bugreports.qt.io/browse/QTBUG-106495 I hacked CMake and created a
Packageing.cmake
file to package a Qt application without gradle.I had to extract the androidx.core
aar
file and compile theclasses.dex
with theclasses.jar
from theaar
file.But ... it worked! 🎉 The above error went away!
-
Testo di origine
The latest android api levels require FileProvider implementation to create and share files.
So the tutorial
https://developer.android.com/reference/androidx/core/content/FileProvider
does not work in Qt world because, after having added the section<provider android:name="androidx.core.content.FileProvider" android:authorities="org.qtproject.example" android:exported="false" android:grantUriPermissions="true"> <meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/file_paths" /> </provider>
after having added the file file_path.xml and
android.useAndroidX=true android.enableJetifier=true
in the gradle.properties, during statup the application goes to crash with
E AndroidRuntime: FATAL EXCEPTION: main E AndroidRuntime: Process: org.qtproject.example, PID: 2905 E AndroidRuntime: java.lang.RuntimeException: Unable to get provider androidx.core.content.FileProvider: java.lang.ClassNotFoundException: Didn't find class "androidx.core.content.FileProvider" on path: DexPathList[[zip file "/data/app/org.qtproject.example-KFKpcJodUkUxx65aKHw76A==/base.apk"],nativeLibraryDirectories=[/data/app/org.qtproject.example-KFKpcJodUkUxx65aKHw76A==/lib/arm, /data/app/org.qtproject.example-KFKpcJodUkUxx65aKHw76A==/base.apk!/lib/armeabi-v7a, /system/lib, /vendor/lib]] E AndroidRuntime: at android.app.ActivityThread.installProvider(ActivityThread.java:6242) E AndroidRuntime: at android.app.ActivityThread.installContentProviders(ActivityThread.java:5805) E AndroidRuntime: at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5722) E AndroidRuntime: at android.app.ActivityThread.-wrap1(Unknown Source:0)
Have you got the same behaviour? Any idea to resolve?
@mrdebug which Qt Version are you using ?
-
@mrdebug which Qt Version are you using ?
wrote on 13 Jan 2024, 19:50 last edited by@ekkescorner Sorry but it is been a long time.
I don't remember the Qt version but I suppose the latest available version on february 2022 and Android 12 if i remember correctly.