简体   繁体   English

NDK与Android Studio集成

[英]NDK Integration with Android Studio

I'm new in NDK .and try to setup Integration with NDk .But after research through many sites ,i could not solved my problem. 我是NDK的新手,并尝试设置与NDk的集成。但是经过许多站点的研究后,我无法解决我的问题。 Here is build.gradle file 这是build.gradle文件

  apply plugin: 'com.android.model.application'
     model {
      android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"
    }

  android.ndk {
    moduleName "native"
   }

  defaultConfig.with {
    applicationId "app.com.jnitester"
    minSdkVersion.apiLevel 15
    targetSdkVersion.apiLevel 23
    versionCode 1
    versionName "1.0"
    buildConfigFields {
        create() {
            type = "int"
            name = "VALUE"
            value = "1"
        }
    }
}

/*   android.ndk {
    moduleName = "native"
}*/


android.buildTypes {
    release {
        minifyEnabled false
        proguardFiles += file('proguard-rules.txt')
    }
}

android.productFlavors {
    create("flavor1") {
        applicationId "com.app"
    }
}

android.sources {
    main {
        jni {

            source {
                srcDir 'src'
            }
        }
    }
}

}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
}

my classpath is:

classpath 'com.android.tools.build:gradle-experimental:0.4.0' classpath'com.android.tools.build:gradle-experimental:0.4.0'

we get error like that: 我们得到这样的错误:

Error:(18, 0) No signature of method: org.gradle.model.dsl.internal.NonTransformedModelDslBacking.applicationId() is applicable for argument types: (java.lang.String) values: [app.com.jnitester] Open File 错误:(18,0)没有方法签名:org.gradle.model.dsl.internal.NonTransformedModelDslBacking.applicationId()适用于参数类型:(java.lang.String)值:[app.com.jnitester]打开文件

when i put buildTypes,productFlavours,sources inside android{} then it gives Errors like that: 当我将buildTypes,productFlavours,sources放入android{}它会给出如下错误:

Error:(4, 1) A problem occurred configuring project ':app'.
 > Exception thrown while executing model rule: model.android
   > Could not find method compileSdkVersion() for arguments [23] on project ':app'.

may be this question be duplicate but we couldn't find the solution yet . 这个问题可能是重复的,但是我们找不到解决方案。 Your help would save my time. 您的帮助将节省我的时间。 Any Help would be appreciated in Advanced. 任何帮助将不胜感激。

try adding '=' char. 尝试添加“ =”字符。 eg 例如

compileSdkVersion 23 编译版本23

change to 改成

compileSdkVersion = 23 compileSdkVersion = 23

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM