gpt4 book ai didi

android - 错误 :Execution failed for task 'ndkBuild' . > 进程 'command ' Android\sdk\ndk-bundle/ndk-build.cmd'' 以非零退出值 2 完成

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:43:22 25 4
gpt4 key购买 nike

我的项目使用 Android NDK,我在构建时遇到上述错误。

  • 我安装了最新的 Java 版本、Android NDK 和 Android SDK
  • 使用 Windows 8 和 Android Studio我在local.properties中添加了SDK和NDK

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

这是我的build.gradle:

apply plugin: 'com.android.application'

android {
compileSdkVersion 21
buildToolsVersion "23.0.0"

defaultConfig {
applicationId "uk.digitalsquid.netspoofer"
minSdkVersion 10
targetSdkVersion 21
}

buildTypes {
release {
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}

sourceSets.main.jni.srcDirs = []
}

dependencies {
compile 'com.android.support:support-v4:23.0.0'
compile 'com.google.android.gms:play-services:7.8.0'
compile 'org.jsoup:jsoup:1.8.3'
compile project(':androidsupportv4preferencefragment')
}

tasks.withType(JavaCompile) {
compileTask -> compileTask.dependsOn ndkLibsToJar, ndkBinariesToJar, ndkBinariesToJar16, ndkDataToJar
}

task ndkLibsToJar(type: Zip, dependsOn: 'ndkBuild', description: 'Create a JAR of the native libs') {
destinationDir new File(buildDir, 'libs')
baseName 'ndk-libs'
extension 'jar'
from(new File(buildDir, 'libs')) {
include '**/*.so'
}
into 'lib/'
}


task ndkBinariesToJar(type: Zip, dependsOn: 'ndkBuild', description: 'Create a JAR of the native binaries') {
destinationDir new File(buildDir, 'libs')
baseName 'ndk-binaries'
extension 'jar'
from(new File(buildDir, 'libs')) {
include '**/arp-scan'
include '**/arpspoof'
include '**/iptables'
}
into 'assets/binaries/android-9'
}

task ndkBinariesToJar16(type: Zip, dependsOn: 'ndkBuild16', description: 'Create a JAR of the native binaries for Android 16+') {
destinationDir new File(buildDir, 'libs')
baseName 'ndk-binaries-16'
extension 'jar'
from(new File(buildDir, 'android-16/libs')) {
include '**/arp-scan'
include '**/arpspoof'
include '**/iptables'
}
into 'assets/binaries/android-16'
}


task ndkDataToJar(type: Zip, dependsOn: 'ndkBuild', description: 'Create a JAR of the native data') {
destinationDir new File(buildDir, 'libs')
baseName 'ndk-data'
extension 'jar'
from(new File('src/main/jni/arp-scan')) {
include '**/ieee-iab.txt'
include '**/ieee-oui.txt'
include '**/mac-vendor.txt'
}
into 'assets/data/'
}


task ndkBuild(type: Exec, description: 'Compile JNI source via NDK') {
def ndkDir = project.plugins.findPlugin('com.android.application').sdkHandler.getNdkFolder()
println(ndkDir)
commandLine "$ndkDir/ndk-build.cmd",
'NDK_PROJECT_PATH=build',
'APP_BUILD_SCRIPT=src/main/jni/Android.mk',
'NDK_APPLICATION_MK=src/main/jni/Application.mk',
'-j1'
}

task ndkBuild16(type: Exec, description: 'Compile JNI source via NDK for Android 16+') {
def ndkDir = project.plugins.findPlugin('com.android.application').sdkHandler.getNdkFolder()
println(ndkDir)
commandLine "$ndkDir/ndk-build.cmd",
'NDK_PROJECT_PATH=build/android-16',
'APP_BUILD_SCRIPT=src/main/jni/Android.mk',
'NDK_APPLICATION_MK=src/main/jni/Application-16.mk',
'-j1'
}

这是构建日志:

    Information:Gradle tasks [:androidnetspoof:assembleDebug]
C:\Users\Jang\AppData\Local\Android\sdk\ndk-bundle
C:\Users\Jang\AppData\Local\Android\sdk\ndk-bundle
:androidnetspoof:preBuild
:androidsupportv4preferencefragment:compileLint UP-TO-DATE
:androidnetspoof:preDebugBuild
:androidsupportv4preferencefragment:copyReleaseLint UP-TO-DATE
:androidnetspoof:checkDebugManifest UP-TO-DATE
:androidsupportv4preferencefragment:preBuild
:androidnetspoof:preReleaseBuild UP-TO-DATE
:androidsupportv4preferencefragment:preBuild UP-TO-DATE
:androidsupportv4preferencefragment:preReleaseBuild
:androidnetspoof:generateDebugBuildConfig UP-TO-DATE
:androidsupportv4preferencefragment:checkReleaseManifest
:androidsupportv4preferencefragment:preDebugAndroidTestBuild UP-TO-DATE
:androidsupportv4preferencefragment:preDebugBuild UP-TO-DATE
:androidsupportv4preferencefragment:preDebugUnitTestBuild UP-TO-DATE
:androidsupportv4preferencefragment:preReleaseUnitTestBuild UP-TO-DATE
:androidsupportv4preferencefragment:prepareComAndroidSupportSupportV42300Library UP-TO-DATE
:androidnetspoof:generateDebugAssets UP-TO-DATE
:androidnetspoof:generateDebugResValues UP-TO-DATE
:androidsupportv4preferencefragment:preReleaseBuild UP-TO-DATE
:androidsupportv4preferencefragment:prepareReleaseDependencies
:androidnetspoof:ndkBuild
:androidsupportv4preferencefragment:compileReleaseAidl UP-TO-DATE
:androidsupportv4preferencefragment:compileReleaseRenderscript UP-TO-DATE
:androidsupportv4preferencefragment:generateReleaseBuildConfig UP-TO-DATE
:androidsupportv4preferencefragment:generateReleaseAssets UP-TO-DATE
:androidsupportv4preferencefragment:mergeReleaseAssets UP-TO-DATE
:androidsupportv4preferencefragment:generateReleaseResValues UP-TO-DATE
:androidsupportv4preferencefragment:generateReleaseResources UP-TO-DATE
:androidsupportv4preferencefragment:mergeReleaseResources UP-TO-DATE
:androidsupportv4preferencefragment:processReleaseManifest UP-TO-DATE
:androidsupportv4preferencefragment:processReleaseResources UP-TO-DATE
:androidsupportv4preferencefragment:generateReleaseSources UP-TO-DATE
:androidsupportv4preferencefragment:processReleaseJavaRes UP-TO-DATE
:androidsupportv4preferencefragment:compileReleaseJavaWithJavac UP-TO-DATE
:androidsupportv4preferencefragment:extractReleaseAnnotations UP-TO-DATE
:androidsupportv4preferencefragment:mergeReleaseProguardFiles UP-TO-DATE
:androidsupportv4preferencefragment:packageReleaseJar UP-TO-DATE
:androidsupportv4preferencefragment:compileReleaseNdk UP-TO-DATE
:androidsupportv4preferencefragment:packageReleaseJniLibs UP-TO-DATE
:androidsupportv4preferencefragment:packageReleaseLocalJar UP-TO-DATE
:androidsupportv4preferencefragment:packageReleaseRenderscript UP-TO-DATE
:androidsupportv4preferencefragment:packageReleaseResources UP-TO-DATE
:androidsupportv4preferencefragment:bundleRelease UP-TO-DATE
process_begin: CreateProcess(NULL, realpath obj, ...) failed.
process_begin: CreateProcess(NULL, realpath obj, ...) failed.
Warning:warning: overriding commands for target `/extensions/gen_initext.c'
Warning:warning: ignoring old commands for target `/extensions/gen_initext.c'
process_begin: CreateProcess(NULL, realpath obj, ...) failed.
Warning:warning: overriding commands for target `/extensions/gen_initext.c'
Warning:warning: ignoring old commands for target `/extensions/gen_initext.c'
process_begin: CreateProcess(NULL, realpath obj, ...) failed.
Warning:warning: overriding commands for target `/extensions/gen_initext.c'
Warning:warning: ignoring old commands for target `/extensions/gen_initext.c'
C:\Users\Jang\AppData\Local\Android\sdk\ndk-bundle\build\core\build-binary.mk
Warning:(464) warning: overriding commands for target `build/obj/local/armeabi/objs/ext/extensions/libipt_standard.o'
Warning:(464) warning: ignoring old commands for target `build/obj/local/armeabi/objs/ext/extensions/libipt_standard.o'
Warning:(464) warning: overriding commands for target `build/obj/local/armeabi-v7a/objs/ext/extensions/libipt_standard.o'
Warning:(464) warning: ignoring old commands for target `build/obj/local/armeabi-v7a/objs/ext/extensions/libipt_standard.o'
Warning:(464) warning: overriding commands for target `build/obj/local/mips/objs/ext/extensions/libipt_standard.o'
Warning:(464) warning: ignoring old commands for target `build/obj/local/mips/objs/ext/extensions/libipt_standard.o'
Warning:(464) warning: overriding commands for target `build/obj/local/x86/objs/ext/extensions/libipt_standard.o'
Warning:(464) warning: ignoring old commands for target `build/obj/local/x86/objs/ext/extensions/libipt_standard.o'
[armeabi] Install : arp-scan => libs/armeabi/arp-scan
[armeabi] Install : arpspoof => libs/armeabi/arpspoof
mkdir -p /extensions/
The syntax of the command is incorrect.
make.exe: *** [/extensions/gen_initext.c] Error 1
:androidsupportv4preferencefragment:prepareReleaseDependencies FAILED
Error:Execution failed for task ':androidnetspoof:ndkBuild'.
> Process 'command 'C:\Users\Jang\AppData\Local\Android\sdk\ndk-bundle/ndk-build.cmd'' finished with non-zero exit value 2

最佳答案

  • 确保也添加 this 的内容存储库到 jni/arp-scan/arp-scan
  • 还要确保添加 this 的内容存储库到 jni/iptables/custom-android-iptables

如果它不起作用,请将 ndkBuild 任务 commandLine 的标志更改为 -j1 以确保它不会并行构建:

commandLine "$ndkDir/ndk-build.cmd",
'NDK_PROJECT_PATH=build',
'APP_BUILD_SCRIPT=src/main/jni/Android.mk',
'NDK_APPLICATION_MK=src/main/jni/Application.mk',
'-j1'

发布构建日志后编辑

发生此错误是因为在 makefile custom-android-iptabes/Android.mk 中有一个执行 mkdir -p/extensions/ 的脚本,即 基于 UNIX,而我假设您正在尝试从基于 DOS 的 Windows 进行构建。

您需要做的是将那些基于 UNIX 的脚本转换为基于 DOS 的脚本,例如,在本例中,mkdir\extensions\

关于android - 错误 :Execution failed for task 'ndkBuild' . > 进程 'command ' Android\sdk\ndk-bundle/ndk-build.cmd'' 以非零退出值 2 完成,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32440302/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com