ndk以非零退出值69结束

时间:2016-08-30 14:05:50

标签: android android-ndk java-native-interface

我在android中学习ndk。我遇到了问题。 这是错误信息: 错误:任务执行失败':app:compileDebugNdk'。

> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/Users/yishuaiqin/Documents/adt-bundle-mac-x86_64-20140702/sdk/ndk-bundle/ndk-build'' **finished with non-zero exit value 69**

的build.gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.3"

    defaultConfig {
        applicationId "com.example.yishuaiqin.myapplication"
        minSdkVersion 15
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"

        ndk{
            moduleName "JniDemo"
        }
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.4.0'
}

我尝试添加

sourceSets.main {
        res.srcDirs = ['src/main/res']
        jniLibs.srcDirs = ['src/main/JniDemo']
        jni.srcDirs = [] // This prevents the auto generation of Android.mk
    }

但是我会发生另一个错误,这个:

FATAL EXCEPTION: main
                                                                                      Process: com.example.yishuaiqin.myapplication, PID: 19774
                                                                                      java.lang.UnsatisfiedLinkError: com.android.tools.fd.runtime.IncrementalClassLoader$DelegateClassLoader[DexPathList[[dex file "/data/data/com.example.yishuaiqin.myapplication/files/instant-run/dex/slice-support-annotations-23.4.0_a08614bb6283cfa324b87685191afbfb59aca883-classes.dex", dex file "/data/data/com.example.yishuaiqin.myapplication/files/instant-run/dex/slice-slice_9-classes.dex", dex file "/data/data/com.example.yishuaiqin.myapplication/files/instant-run/dex/slice-slice_8-classes.dex", dex file "/data/data/com.example.yishuaiqin.myapplication/files/instant-run/dex/slice-slice_7-classes.dex", dex file "/data/data/com.example.yishuaiqin.myapplication/files/instant-run/dex/slice-slice_6-classes.dex", dex file "/data/data/com.example.yishuaiqin.myapplication/files/instant-run/dex/slice-slice_5-classes.dex", dex file "/data/data/com.example.yishuaiqin.myapplication/files/instant-run/dex/slice-slice_4-classes.dex", dex file "/data/data/com.example.yishuaiqin.myapplication/files/instant-run/dex/slice-slice_3-classes.dex", dex file "/data/data/com.example.yishuaiqin.myapplication/files/instant-run/dex/slice-slice_2-classes.dex", dex file "/data/data/com.example.yishuaiqin.myapplication/files/instant-run/dex/slice-slice_1-classes.dex", dex file "/data/data/com.example.yishuaiqin.myapplication/files/instant-run/dex/slice-slice_0-classes.dex", dex file "/data/data/com.example.yishuaiqin.myapplication/files/instant-run/dex/slice-internal_impl-23.4.0_d3bbf4c848f2f380fb4656d172d460d67e20c13a-classes.dex", dex file "/data/data/com.example.yishuaiqin.myapplication/files/instant-run/dex/slice-com.android.support-support-vector-drawable-23.4.0_349aae7a307baa89345a2ee68f546bcfc06d7dcb-classes.dex", dex file "/data/data/com.example.yishuaiqin.myapplication/files/instant-run/dex/slice-com.android.support-support-v4-23.4.0_1345311585f1d2a3e686ce5b1400b7695dd6eb16-classes.dex", dex file "/data/data/com.example.yishuaiqin.myapplication/files/instant-run/dex/slice-com.android.support-appcompat-v7-23.4.0_f833b9499bab0649a8dfe39f8821365db78812c6-classes.dex", dex file "/data/data/com.example.yishuaiqin.myapplication/files/instant-run/dex/slice-com.android.support-animated-vector-drawable-23.4.0_1ce53af57ba1082cd25ff52df7ce61dddbd9cdad-classes.dex"],nativeLibraryDirectories=[/data/app/com.example.yishuaiqin.myapplication-1/lib/x86, /vendor/lib, /system/lib]]] couldn't find "libJniDemo.so"
                                                                                          at java.lang.Runtime.loadLibrary(Runtime.java:367)
                                                                                          at java.lang.System.loadLibrary(System.java:1076)
                                                                                          at com.example.yishuaiqin.myapplication.NdkTest.<clinit>(NdkTest.java:10)
                                                                                          at com.example.yishuaiqin.myapplication.MainActivity.onCreate(MainActivity.java:14)
                                                                                          at android.app.Activity.performCreate(Activity.java:6237)
                                                                                          at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
                                                                                          at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
                                                                                          at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
                                                                                          at android.app.ActivityThread.-wrap11(ActivityThread.java)
                                                                                          at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
                                                                                          at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                                          at android.os.Looper.loop(Looper.java:148)
                                                                                          at android.app.ActivityThread.main(ActivityThread.java:5417)
                                                                                          at java.lang.reflect.Method.invoke(Native Method)
                                                                                          at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
                                                                                          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

我在其他答案中尝试过解决方案,但没有帮助我。 任何人有任何想法?提前谢谢。

1 个答案:

答案 0 :(得分:0)

如果您是MacOS用户,请检查您的XCode是否需要同意最新的许可协议。在运行XCode并同意许可证之前,它将阻止ndk任务,因为它使用XCode发行版中包含的工具。