java - Android Studio : generating . so文件使用实验性插件

标签 java android android-ndk shared-libraries gradle-experimental

我在 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

这是我的项目结构: enter image description here

这是我的 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/

相关文章:

Android:如何在 native Activity 之上添加另一个 View

java - 无法让我的 .jar 启动 Ignite 以在 GKE 上运行

java - javax.xml.soap 比 apache cxf 好吗?

java - 如何插入用户输入的字符串来直接引用?

java - 如何找出阻止 FileAppender 正常滚动的原因

android - 如何在编辑文本的中心对齐文本(提示)

android - html电子邮件签名不在gmail中显示内联css

android - 在android中通过选项卡传递数据

android - 使用 ffmpeg 或 MediaMuxer for android 在来自 sd 卡的视频文件上添加图像资源

安卓 NDK 和 C++ STL