2017-01-05 78 views
1

我正在使用ebookdroid & MuPDF CPP文件使用PDF查看器應用程序。在Gradle中,我有很多與NDK集成的問題。我已經經歷了很多答案,但他們還沒有解決我的問題。如何在Gradle中設置NDK lib路徑?

搖籃是給我下面的錯誤信息:

Error:Execution failed for task ':app:compileDebugNdk'. 
Error: Your project contains C++ files but it is not using a supported native build system. 
Consider using CMake or ndk-build integration with the stable Android Gradle plugin: 
    https://developer.android.com/studio/projects/add-native-code.html 
    or use the experimental plugin: 
    http://tools.android.com/tech-docs/new-build-system/gradle-experimental. 

回答

0

編輯您的build.gradle,加defaultConfig.externalNativeBuild.ndkBuildexternalNativeBuild.ndkBuildsourceSet.main.jni.srcDir選項。請參閱下面的評論。

android { 
     compileSdkVersion 22 
     buildToolsVersion "27.0.0" 

     defaultConfig { 
      minSdkVersion 18 
      targetSdkVersion 22 
      versionCode 1 
      versionName "1.0" 

      //add arguments passed to ndkBuild 
      externalNativeBuild { 
       ndkBuild { 
        arguments "NDK_TOOLCHAIN_VERSION=clang", "APP_SHORT_COMMANDS=true", "APP_ALLOW_MISSING_DEPS=true" 
        arguments "-j" + Runtime.runtime.availableProcessors() 
        cFlags "-fexceptions" 
       } 
      } 

      ndk { 
       abiFilters "armeabi-v7a" 
      } 
     } 

     //specify jni source file path 
     sourceSets.main { 
      java.srcDir "src" 
      res.srcDir "res" 
      jni.srcDir "jni" 
     } 


     buildTypes { 
      debug { 
       debuggable true 
       jniDebuggable true 
      } 
     } 

     //specify makefile/CMake file 
     externalNativeBuild { 
      ndkBuild { 
       path 'jni/Android.mk' 
      } 
     } 
    }