错误:没有这样的属性:android for class:com.android.build.gradle.managed.AndroidConfig

时间:2017-04-01 03:34:06

标签: java android android-studio android-ndk

我正在尝试使用NDK构建我的android项目,但是当我更改build.gradle文件时,android studio显示错误,我无法同步gradle。你能帮我解决这个问题吗? 我的依赖

buildscript {
repositories {
    jcenter()
}
dependencies {
    classpath 'com.android.tools.build:gradle-experimental:0.9.0'
    classpath 'com.google.gms:google-services:3.0.0'

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}
allprojects {
repositories {
    jcenter()
}
task clean(type: Delete) {
delete rootProject.buildDir}

和我的build.gradle

apply plugin: 'com.android.model.application'
model {
android {
    compileSdkVersion 24
    buildToolsVersion "25.0.0"
    defaultConfig {
        applicationId "com.mycompany.myproject"
        minSdkVersion.apiLevel 15
        targetSdkVersion.apiLevel 24
        versionCode 11
        versionName "3.1"
        multiDexEnabled true
    }
    buildTypes {
        release {
            debuggable true
            minifyEnabled true
            proguardFiles.add(file("proguard-rules.pro"))
            signingConfig = $("android.signingConfigs.myConfig")
        }
        debug {
            debuggable true
        }
    }
    ndk {
        moduleName = "name"
    }
    android.lintOptions {
        disable 'MissingTranslation'
    }
    android.dexOptions {
        javaMaxHeapSize "4g"
    }
    android.productFlavors {
        manifestPlaceholders = [onesignal_app_id: "onesignalId",
                                local value is ignored.
                                onesignal_google_project_number: "projectnumber"]
    }
}
android.signingConfigs {
    create("myConfig") {
        keyAlias 'alias'
        keyPassword 'mypassword'
        storeFile file('mypath')
        storePassword 'mypassword'
        storeType "jks"
    }
}

感谢您的帮助!

1 个答案:

答案 0 :(得分:0)

看一下这个答案https://stackoverflow.com/a/32312074/593978

你拥有android {}块中的所有内容,而你的大多数条目都应该在它之外。这可能会导致您的例外。