Getting JNI right to invoke camera on androidx
-
wrote on 5 Jan 2021, 23:01 last edited by m2dtkast 1 May 2021, 23:05
Hi,
I am trying to get this example: https://github.com/minixxie/examples/tree/master/qt-for-mobile/TestExternalAndroidCamera1
to work on android abi 29 (added the android:requestLegacyExternalStorage="true" flag to application entry in manifest);Faced some challenges most likely due to problems with this s*cker : https://stackoverflow.com/questions/57116335/environment-getexternalstoragedirectory-deprecated-in-api-level-29-java#57116787
getting a SIG33 error when running this "out of the box" , more specifically:JNI DETECTED ERROR IN APPLICATION: JNI GetStaticMethodID called with pending exception android.os.FileUriExposedException: file:///storage/emulated/0/camera.jpg exposed beyond app through ClipData.Item.getUri()
Any help would be very much appreciated.
EDIT : might be related to not using getUriForFile, so I tried to throw in this :
QAndroidJniObject filename = QAndroidJniObject::callStaticObjectMethod( "android/support/v4/content/FileProvider", "getUriForFile", // only the function name!! "(Landroid/content/Context;Ljava/lang/String;Ljava/io/File;)Landroid/net/Uri;", QtAndroid::androidActivity().object(), "org.qtproject.qt5.android.bindings.QtApplication.provider", photo.object());
but it does not seem to yield a valid result, instead i get
java.lang.ClassNotFoundException: Didn't find class "android.support.v4.content.FileProvider" on path: DexPathList[[],nativeLibraryDirectories=[/system/lib]]
most likely for the same reason above?
-
Hi,
I am trying to get this example: https://github.com/minixxie/examples/tree/master/qt-for-mobile/TestExternalAndroidCamera1
to work on android abi 29 (added the android:requestLegacyExternalStorage="true" flag to application entry in manifest);Faced some challenges most likely due to problems with this s*cker : https://stackoverflow.com/questions/57116335/environment-getexternalstoragedirectory-deprecated-in-api-level-29-java#57116787
getting a SIG33 error when running this "out of the box" , more specifically:JNI DETECTED ERROR IN APPLICATION: JNI GetStaticMethodID called with pending exception android.os.FileUriExposedException: file:///storage/emulated/0/camera.jpg exposed beyond app through ClipData.Item.getUri()
Any help would be very much appreciated.
EDIT : might be related to not using getUriForFile, so I tried to throw in this :
QAndroidJniObject filename = QAndroidJniObject::callStaticObjectMethod( "android/support/v4/content/FileProvider", "getUriForFile", // only the function name!! "(Landroid/content/Context;Ljava/lang/String;Ljava/io/File;)Landroid/net/Uri;", QtAndroid::androidActivity().object(), "org.qtproject.qt5.android.bindings.QtApplication.provider", photo.object());
but it does not seem to yield a valid result, instead i get
java.lang.ClassNotFoundException: Didn't find class "android.support.v4.content.FileProvider" on path: DexPathList[[],nativeLibraryDirectories=[/system/lib]]
most likely for the same reason above?
@m2dtkast does your build.gradle contain
dependencies { implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar']) compile 'com.android.support:support-v4:25.3.1' }
1/2