JavaCV + Android Studio + gradle- possible?

前端 未结 7 1095
难免孤独
难免孤独 2021-01-31 21:19

I\'m trying use JavaCV with Android Studio and Gradle. I wrote such code fragment:

   repositories {
    mavenCentral()
    maven {
        url \"http://maven2.j         


        
相关标签:
7条回答
  • 2021-01-31 22:02

    For an up-to-date solution (JavaCV 1.1 and Android Studio 2.1.1) please see my step-by-step instructions in my Gist. JavaCV 1.2 currently doesn't like Android 6.

    This tut will use JavaCV 1.1, version 1.2 currently has SIGSEGV issue. JavaCV 1.1 comes with FFmpeg 2.8.1.

    1. Obtain the prebulit binaries here.
    2. Extract it and copy these files:
      • javacpp.jar (essential).
      • javacv.jar (essential).
      • ffmpeg.jar (essential if you use FFmpeg).
      • ffmpeg-android-arm.jar (for arm CPU).
      • ffmpeg-android-x86.jar (optional for x86 CPU). into the libs folder of your project (app/libs in my case).
    3. Click on app -> F4 -> Dependencies -> + -> File dependencies -> choose all the previous .jar.
    4. Temporarily, because of this issue, we need to set targetSdkVersion 22 the app's build.gradle.
    5. Possibly need to set these packagingOptions in the build.gradle:

    android { compileSdkVersion 23 buildToolsVersion "23.0.3"

    defaultConfig {
        applicationId "com.example.test"
        minSdkVersion 16
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
    }
    
    packagingOptions {
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/maven/org.bytedeco.javacpp-presets/ffmpeg/pom.properties'
        exclude 'META-INF/maven/org.bytedeco.javacpp-presets/ffmpeg/pom.xml'
    
        //might need these if you use openCV
        //exclude 'META-INF/maven/org.bytedeco.javacpp-presets/opencv/pom.properties'
        //exclude 'META-INF/maven/org.bytedeco.javacpp-presets/opencv/pom.xml'
    }
    

    }

    0 讨论(0)
提交回复
热议问题