无法加载类';com.android.build.gradle.managed.BuildType\u Impl

无法加载类';com.android.build.gradle.managed.BuildType\u Impl,android,android-studio,android-gradle-plugin,build.gradle,Android,Android Studio,Android Gradle Plugin,Build.gradle,我正在尝试使用androidstudio实现基本的ndk。现在我无法同步gradle,我认为buid.gradle中缺少一些配置 我收到此错误 apply plugin: 'com.android.model.application' model { android { compileSdkVersion = 23 buildToolsVersion

我正在尝试使用androidstudio实现基本的ndk。现在我无法同步gradle,我认为buid.gradle中缺少一些配置

我收到此错误

 apply plugin: 'com.android.model.application'
    model
            {
                android {
                    compileSdkVersion = 23
                    buildToolsVersion = "23.0.1"

                    defaultConfig.with {
                        applicationId = "com.example.app"
                        minSdkVersion.apiLevel = 9
                        targetSdkVersion.apiLevel = 23
                        versionCode = 1
                        versionName = "1.0"
                    }

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

                    packagingOptions {
                        exclude 'META-INF/DEPENDENCIES'
                        exclude 'META-INF/NOTICE'
                        exclude 'META-INF/LICENSE'
                        exclude 'META-INF/LICENSE.txt'
                        exclude 'META-INF/NOTICE.txt'

                    }

                android.ndk {
                    moduleName = "jniSample"
                }

                android.productFlavors {
                    // for detailed abiFilter descriptions, refer to "Supported ABIs" @
                    // https://developer.android.com/ndk/guides/abis.html#sa
                    create("arm") {
                        ndk.abiFilters.add("armeabi")
                    }
                    create("arm7") {
                        ndk.abiFilters.add("armeabi-v7a")
                    }
                    create("arm8") {
                        ndk.abiFilters.add("arm64-v8a")
                    }
                    create("x86") {
                        ndk.abiFilters.add("x86")
                    }
                    create("x86-64") {
                        ndk.abiFilters.add("x86_64")
                    }
                    create("mips") {
                        ndk.abiFilters.add("mips")
                    }
                    create("mips-64") {
                        ndk.abiFilters.add("mips64")
                    }
                    // To include all cpu architectures, leaves abiFilters empty
                    create("all")
                }

                dependencies {
                    compile fileTree(dir: 'libs', include: ['*.jar'])
                    testCompile 'junit:junit:4.12'
                    compile 'com.android.support:appcompat-v7:23.0.1'
                    compile 'com.google.android.gms:play-services-ads:8.4.0'

                    compile files('libs/httpclient-4.1.3.jar')
                    compile files('libs/httpcore-4.1.4.jar')
                }

            }
buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle-experimental:0.4.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
}
错误:无法加载类“com.android.build.gradle.managed.BuildType\u Impl”。 此意外错误的可能原因包括:
  • Gradle的依赖项缓存可能已损坏(这有时在网络连接超时后发生。) 重新下载依赖项和同步项目(需要网络)
  • 渐变生成进程(守护进程)的状态可能已损坏。停止所有Gradle守护进程可以解决此问题。 停止Gradle生成进程(需要重新启动)
  • 您的项目可能使用的第三方插件与项目中的其他插件或项目请求的Gradle版本不兼容。
如果Gradle进程损坏,您也可以尝试关闭IDE,然后关闭所有Java进程

我的buid.gradle(应用程序)

 apply plugin: 'com.android.model.application'
    model
            {
                android {
                    compileSdkVersion = 23
                    buildToolsVersion = "23.0.1"

                    defaultConfig.with {
                        applicationId = "com.example.app"
                        minSdkVersion.apiLevel = 9
                        targetSdkVersion.apiLevel = 23
                        versionCode = 1
                        versionName = "1.0"
                    }

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

                    packagingOptions {
                        exclude 'META-INF/DEPENDENCIES'
                        exclude 'META-INF/NOTICE'
                        exclude 'META-INF/LICENSE'
                        exclude 'META-INF/LICENSE.txt'
                        exclude 'META-INF/NOTICE.txt'

                    }

                android.ndk {
                    moduleName = "jniSample"
                }

                android.productFlavors {
                    // for detailed abiFilter descriptions, refer to "Supported ABIs" @
                    // https://developer.android.com/ndk/guides/abis.html#sa
                    create("arm") {
                        ndk.abiFilters.add("armeabi")
                    }
                    create("arm7") {
                        ndk.abiFilters.add("armeabi-v7a")
                    }
                    create("arm8") {
                        ndk.abiFilters.add("arm64-v8a")
                    }
                    create("x86") {
                        ndk.abiFilters.add("x86")
                    }
                    create("x86-64") {
                        ndk.abiFilters.add("x86_64")
                    }
                    create("mips") {
                        ndk.abiFilters.add("mips")
                    }
                    create("mips-64") {
                        ndk.abiFilters.add("mips64")
                    }
                    // To include all cpu architectures, leaves abiFilters empty
                    create("all")
                }

                dependencies {
                    compile fileTree(dir: 'libs', include: ['*.jar'])
                    testCompile 'junit:junit:4.12'
                    compile 'com.android.support:appcompat-v7:23.0.1'
                    compile 'com.google.android.gms:play-services-ads:8.4.0'

                    compile files('libs/httpclient-4.1.3.jar')
                    compile files('libs/httpcore-4.1.4.jar')
                }

            }
buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle-experimental:0.4.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
}
My build.gradle(项目)

 apply plugin: 'com.android.model.application'
    model
            {
                android {
                    compileSdkVersion = 23
                    buildToolsVersion = "23.0.1"

                    defaultConfig.with {
                        applicationId = "com.example.app"
                        minSdkVersion.apiLevel = 9
                        targetSdkVersion.apiLevel = 23
                        versionCode = 1
                        versionName = "1.0"
                    }

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

                    packagingOptions {
                        exclude 'META-INF/DEPENDENCIES'
                        exclude 'META-INF/NOTICE'
                        exclude 'META-INF/LICENSE'
                        exclude 'META-INF/LICENSE.txt'
                        exclude 'META-INF/NOTICE.txt'

                    }

                android.ndk {
                    moduleName = "jniSample"
                }

                android.productFlavors {
                    // for detailed abiFilter descriptions, refer to "Supported ABIs" @
                    // https://developer.android.com/ndk/guides/abis.html#sa
                    create("arm") {
                        ndk.abiFilters.add("armeabi")
                    }
                    create("arm7") {
                        ndk.abiFilters.add("armeabi-v7a")
                    }
                    create("arm8") {
                        ndk.abiFilters.add("arm64-v8a")
                    }
                    create("x86") {
                        ndk.abiFilters.add("x86")
                    }
                    create("x86-64") {
                        ndk.abiFilters.add("x86_64")
                    }
                    create("mips") {
                        ndk.abiFilters.add("mips")
                    }
                    create("mips-64") {
                        ndk.abiFilters.add("mips64")
                    }
                    // To include all cpu architectures, leaves abiFilters empty
                    create("all")
                }

                dependencies {
                    compile fileTree(dir: 'libs', include: ['*.jar'])
                    testCompile 'junit:junit:4.12'
                    compile 'com.android.support:appcompat-v7:23.0.1'
                    compile 'com.google.android.gms:play-services-ads:8.4.0'

                    compile files('libs/httpclient-4.1.3.jar')
                    compile files('libs/httpcore-4.1.4.jar')
                }

            }
buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle-experimental:0.4.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
}
gradle.wrapper.properties

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.8-all.zip

我的问题解决了解决方案是将“依赖项”放在模型{}之外

而proGuard规则变成了

proguardFiles.add(file("proguard-rules.txt"))
而不是

proguardFiles += file('proguard-rules.txt')

我的问题解决了解决方案是将“依赖项”放在模型{}之外

而proGuard规则变成了

proguardFiles.add(file("proguard-rules.txt"))
而不是

proguardFiles += file('proguard-rules.txt')

我刚刚创建的示例2.8甚至不适用于新的Android Studio构建工具。我刚刚创建的示例2.8甚至不适用于新的Android Studio构建工具。