Closed lancewoo closed 1 year ago
No, we don't need to, for example: https://github.com/bytedeco/sample-projects/blob/master/JavaCV-android-example/app/build.gradle
Great! Then I only used an ndk abifilters block to filter out those unwanted, like this:
ndk {
// in case you want to use some arch only
abiFilters "armeabi-v7a"//, "arm64-v8a"
}
There's another question here. How can I package the executables like ffmpeg and ffprobe into the apk? Any other tricks?
There's another question here. How can I package the executables like ffmpeg and ffprobe into the apk? Any other tricks?
We need to use Android API 28 or less for that to work, see https://github.com/bytedeco/javacv/issues/1127#issuecomment-643700534
Hi @saudet , the problem here is ffmpeg didn't get packaged. Even though I changed targetSdkVersion to 26(Android 8.0), I find that the ffmpeg executable is still missing in the final apk. So I am wondering why the executable didn't get packaged.
But when I compiled the app using the dependency jar file directly, the executable file is right there in the apk. It seems different.
The Android plugin won't do that for us, you'll need to add them as resources somehow. Probably copying them in the right subdirectory for Gradle to pick them up should do the trick.
OK, got it. Thanks! @saudet
Then I am posting my workaround code snippet here for somebody else's information:
plugins {
id 'com.android.application'
id 'kotlin-android'
}
android {
compileSdkVersion 30
buildToolsVersion "30.0.3"
defaultConfig {
applicationId "com.example.app"
minSdkVersion 24
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
ndk {
abiFilters "armeabi-v7a"//, "arm64-v8a"
}
}
....
packagingOptions {
pickFirst 'META-INF/native-image/android-arm*/jnijavacpp/jni-config.json'
pickFirst 'META-INF/native-image/android-arm*/jnijavacpp/reflect-config.json'
}
....
}
dependencies {
// implementation fileTree(dir: 'libs', include: ['*.jar'])
// java
implementation 'org.bytedeco:javacpp:1.5.9'
implementation 'org.bytedeco:ffmpeg:6.0-1.5.9'
// so
implementation files("libs/javacpp-1.5.9-android-arm.jar",
"libs/ffmpeg-6.0-1.5.9-android-arm.jar"
)
}
For Android apks, some may only inlcude armeabi-v7a libraries but they want to run on an arm64-v8 device. If we don't set the javacpp.platform, it seems those apps won't run properly.