Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Getting JNI right to invoke camera on androidx

Getting JNI right to invoke camera on androidx

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
2 Posts 2 Posters 402 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    m2dtkast
    wrote on 5 Jan 2021, 23:01 last edited by m2dtkast 1 May 2021, 23:05
    #1

    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?

    E 1 Reply Last reply 7 Jan 2021, 15:53
    0
    • M m2dtkast
      5 Jan 2021, 23:01

      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?

      E Offline
      E Offline
      ekkescorner
      Qt Champions 2016
      wrote on 7 Jan 2021, 15:53 last edited by
      #2

      @m2dtkast does your build.gradle contain

      dependencies {
          implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar'])
          compile 'com.android.support:support-v4:25.3.1'
      }
      

      ekke ... Qt Champion 2016 | 2024 ... mobile business apps
      5.15 --> 6.8 https://t1p.de/ekkeChecklist
      QMake --> CMake https://t1p.de/ekkeCMakeMobileApps

      1 Reply Last reply
      0

      1/2

      5 Jan 2021, 23:01

      • Login

      • Login or register to search.
      1 out of 2
      • First post
        1/2
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved