【问题标题】:Android Studio - error: linker command failed with exit code 1Android Studio - 错误:链接器命令失败,退出代码为 1
【发布时间】:2017-04-12 14:34:55
【问题描述】:

我从这个存储库下载了代码(它是一个控制鹦鹉无人机的应用程序):

Github

希望让它工作,以便我可以研究代码,但是我得到这个错误,在搜索网络后似乎很难找到解决方案,我主要是为 IOS、xcode 等找到东西

我将项目导入 android studio,当我尝试执行应用程序时出现以下错误:

错误:错误:链接器命令失败,退出代码为 1(使用 -v 查看调用)

我不是很喜欢 NDK,但据我所知,这可能是原因,我尝试过的事情:

  • 已下载 NDK 并为其添加了正确的路径。
  • 使用最新的 SDK。
  • 对 build.gradle 的更改,例如设置 buildToolsVersion “25.0.0”等

Build.gradle(项目:ardrone)

    buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.2.2'
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

Build.gradle(模块:app)

    import org.apache.tools.ant.taskdefs.condition.Os

apply plugin: 'com.android.application'

android {
    compileSdkVersion 24
    buildToolsVersion "25.0.0"

    defaultConfig {
        multiDexEnabled true
        applicationId "com.parrot.freeflight"
        minSdkVersion 9
        targetSdkVersion 24
        versionCode 20000
        versionName "2.0-SDK"

        ndk {
            moduleName "adfreeflight"
        }
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
            // TODO proguard-rules seem outdated and useless cause it's only Android stuff
        }
    }
    sourceSets.main {
        jni.srcDirs = [] // This prevents the auto generation of Android.mk
        jniLibs.srcDir 'src/main/jniLibs'
        // This is not necessary unless you have precompiled libraries in your project.
    }

    task buildNative(type: Exec, description: 'Compile JNI source via NDK') {
        def ndkCommand = "${android.ndkDirectory}/ndk-build"
        if (Os.isFamily(Os.FAMILY_WINDOWS)) {
            ndkCommand += ".cmd"
        }

        commandLine ndkCommand,
                '-C', file('src/main/jni').absolutePath,
                '-j', Runtime.runtime.availableProcessors(),
                'all',
                'NDK_DEBUG=1'
    }

    task cleanNative(type: Exec, description: 'Clean JNI object files') {
        def ndkCommand = "${android.ndkDirectory}/ndk-build"
        if (Os.isFamily(Os.FAMILY_WINDOWS)) {
            ndkCommand += ".cmd"
        }

        commandLine ndkCommand,
                '-C', file('src/main/jni').absolutePath,
                'clean'
    }

    clean.dependsOn 'cleanNative'

    tasks.withType(JavaCompile) {
        compileTask -> compileTask.dependsOn buildNative
    }
}

dependencies {
    compile 'com.google.android.gms:play-services:10.0.0'
    compile files('libs/android-support-v13.jar')
    compile files('libs/com.sony.rdis.receiver-20111206.jar')
    compile files('libs/com.sony.rdis.receiver.utility-20111206.jar')
}

local.properties

    ndk.dir=C\:\\Users\\BugDroid\\AppData\\Local\\Android\\Sdk\\ndk-bundle
sdk.dir=C\:\\Users\\BugDroid\\AppData\\Local\\Android\\Sdk

【问题讨论】:

  • 错误文本应该比那一行多。请查看日志并找到描述性错误消息,因为这只是来自 ld 的一般消息。
  • 如何查看日志?
  • 在 Android Studio 的日志窗口中,如果你是从那里构建的话。
  • 我没有得到任何其他东西。

标签: android-ndk java-native-interface android-gradle-plugin build.gradle android-sdk-tools


【解决方案1】:

您需要检查您的日志以获取更多详细信息,因为错误“Linker command failed with exit code 1”通常后面跟着更详细的错误。

因此,要查找更多详细信息,请在 Xcode 中单击 Buildtime 下的错误并选择 Reveal in log。这应该会给你额外的提示。没有任何具体错误,很难知道问题出在哪里。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-03-08
    • 2018-06-12
    • 1970-01-01
    • 2014-02-15
    相关资源
    最近更新 更多