我在 AS 中有一个带有本地库的项目。我正在尝试使用实验性插件 (gradle-experimental:0.6.0-alpha5) 来获取 .so 文件(稍后在 System.loadLibrary () 中使用它)。但我无法生成它们。我真的不能明白了,为什么?
我用过这个instruction写我的build.gradle。这是它:
apply plugin: "com.android.model.application"
model {
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.camera.simplewebcam"
minSdkVersion.apiLevel 15
targetSdkVersion.apiLevel 22
buildConfigFields {
create() {
type "int"
name "VALUE"
value "1"
}
}
ndk {
moduleName "ImageProc"
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles.add(file("proguard-rules.pro"))
}
}
// Configures source set directory.
sources {
main {
jni {
source {
srcDir "src/main"
}
}
}
}
productFlavors {
create("arm") {
ndk {
abiFilters.add("armeabi-v7a")
}
}
create("fat") {
}
}
}
dependencies {
compile fileTree(dir: "lib", include: ['.jar','.so'])
compile "com.android.support:appcompat-v7:23.+"
}
尝试运行应用程序时出现的错误:
java.lang.UnsatisfiedLinkError: Couldn't load ImageProc from loader dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.camera.simplewebcam-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.camera.simplewebcam-1, /vendor/lib, /system/lib, /system/lib/arm]]]: findLibrary returned null
这是我的 Android.mk:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := ImageProc
LOCAL_SRC_FILES := ImageProc.c
LOCAL_LDLIBS := -llog -ljnigraphics
include $(BUILD_SHARED_LIBRARY)
这是我的 Application.mk:
# The ARMv7 is significanly faster due to the use of the hardware FPU
APP_ABI := armeabi armeabi-v7a
APP_PLATFORM := android-8
我的错误在哪里?
最佳答案
问题出在targetSdkVersion.apiLevel 22
An integer designating the API Level that the application targets. If not set, the default value equals that given to minSdkVersion. This attribute informs the system that you have tested against the target version and the system should not enable any compatibility behaviors to maintain your app's forward-compatibility with the target version. The application is still able to run on older versions (down to minSdkVersion).
做
targetSdkVersion.apiLevel 23
你应该使用
compile "com.android.support:appcompat-v7:23.0.1
关于java - Android Studio : generating . so文件使用实验性插件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34872968/