8

I'm using the latest android studio build 1.1 ,since i want to import an eclipse project that needs NDK .i installed NDK and set the NDK location in the local.properties.The problem is when i try to run the project 2 errors are displayed they are

1) Error:(199) *** Android NDK: Aborting...    .  Stop.
2)Error:Execution failed for task ':app:compileDebugNdk'.
> com.android.ide.common.process.ProcessException:org.gradle.process.internal.ExecException: Process 'command 'C:\Users\vishal\android-ndk-r10d\ndk-build.cmd'' finished with non-zero exit value 2

any solution?

Nazaf Anwar
  • 339
  • 1
  • 8
  • 17
vishalaestro
  • 125
  • 1
  • 1
  • 11
  • You should be able to get the output from the ndk-build command from your gradle logs, with a more explicit error, so we can have more information to help you. – ph0b Feb 27 '15 at 17:26
  • Information:Gradle tasks [:app:assembleDebug] WARNING [Project: :app] Current NDK support is deprecated. Alternative will be provided in the future. :app:preBuild UP-TO-DATE :app:preDebugBuild UP-TO-DATE :app:compileDebugNdk C:\Users\vishal\Desktop\DELTA-Software-master\AppPatcher\app\src\main\jni\bspatch.c: In function 'bspatch': C:\Users\vishal\Desktop\DELTA-Software-master\AppPatcher\app\src\main\jni\bspatch.c:82:2: error: format not a string literal and no format arguments [-Werror=format-security] __android_log_print(ANDROID_LOG_INFO, "bspatch.c", argv[0]); ^ – vishalaestro Mar 04 '15 at 15:43
  • Same error i am getting.how to solve this issue in android studio? – Rajesh Dec 18 '15 at 10:11

3 Answers3

20

Try adding this to the build.gradle file:

sourceSets.main {
   jni.srcDirs = []
}
c4sh
  • 701
  • 1
  • 8
  • 22
8

This solved my problem:

  • If you don't have th JNI directory in your project, create it:

enter image description here

  • Go to the new JNI directory that you just created. It should be in{approot}\app\src\main\jni

enter image description here

  • Create an empty *.c file

enter image description here

  • Add the following code to your app/gradle.build file, in the android section. It should look like this:

    android {
        ...
        sourceSets.main {
            jniLibs.srcDir 'libs'
            jni.srcDirs = [] //disable automatic ndk-build call
        }
    }
    
Jon
  • 9,156
  • 9
  • 56
  • 73
Jorge E. Hernández
  • 2,800
  • 1
  • 26
  • 50
3

May be this is known NDK bug. Try to add empty .c file to your jni dir (like empty.c).

senneco
  • 1,786
  • 2
  • 12
  • 15