Execution failed for ':app:ndkBuild'. Process 'command ndk-build.cmd' finished with non-zero exit value 2

后端 未结 2 762
梦如初夏
梦如初夏 2021-01-14 02:41

I have been stuck on this problem for 2 days and have tried out all possible solutions given on stackoverflow. Below is my build.gradle file:

apply plugin: \         


        
相关标签:
2条回答
  • 2021-01-14 03:20

    You should use the latest Android Studio, 2.3.2 is OK. It has integrated externalNativeBuild in android gradle plugin, so you don't need the tricks with custom gradle task.

    I could not actually test the build.gradle script below, so please forgive me any typos:

    apply plugin: 'com.android.application'
    
    android {
        compileSdkVersion 25
        buildToolsVersion "25.0.3"
    
    defaultConfig {
        applicationId "com.example.anannyauberoi.testingcam"
        minSdkVersion 15
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        externalNativeBuild {
            ndkBuild {
                targets "app"
                cppFlags "-std=c++11 -fexceptions"
                arguments "APP_STL=gnustl_shared"
                abiFilters "armeabi-v7a"
            }
        }
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    sourceSets { main { 
      res.srcDirs = ['src/main/res']
    } }
    
    externalNativeBuild {
        ndkBuild {
            path "src/main/jni/Android.mk"
        }
    }
    
        //Modify the below set of code to the ndk-build.cmd location in your computer.
    
    dependencies {
        compile fileTree(include: ['*.jar'], dir: 'libs')
        testCompile 'junit:junit:4.12'
        compile 'com.android.support:appcompat-v7:25.3.1'
        compile project(':openCVLibrary249')
    }
    
    0 讨论(0)
  • 2021-01-14 03:38

    I went to

    C:\Users\Dev\AppData\Local\Android\Sdk\ndk-bundle\ndk-build.cmd
    

    directory and for the ndk-build.cmd i press

    Right-Click> Edit and change the cmd file from:

    @echo off
    %~dp0\build\ndk-build.cmd %*
    

    to

    @echo off
    THAT works for me
    
    0 讨论(0)
提交回复
热议问题