无法加载类的com.android.build.gradle.managed.BuildType_Impl [英] Unable to load class 'com.android.build.gradle.managed.BuildType_Impl

查看:786
本文介绍了无法加载类的com.android.build.gradle.managed.BuildType_Impl的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图用机器人工作室做基本的NDK实现。现在我无法同步gradle这个我觉得有些配置从buid.gradle错过

我收到此错误

错误:无法加载类的com.android.build.gradle.managed.BuildType_Impl。
这个意外的错误可能的原因包括:

  • 摇篮的依赖缓存可能已损坏(这是一个网络连接超时后,有时会出现)
    重新下载的依赖和同步工程(需要网络)
  • 一个摇篮生成过程(守护进程)的状态可能已损坏。停止所有摇篮守护进程可能会解决这个问题。
    停止摇篮建设进程(需要重启动)
  • 您的项目可能会使用第三方插件,这是不符合该项目的其他插件或摇篮的版本由项目要求的兼容。
在腐败的摇篮过程的情况下,你也可以尝试关闭IDE,然后杀死所有Java进程。

我的buid.gradle(APP)

 应用插件:'com.android.model.application
    模型
            {
                安卓{
                    compileSdkVersion = 23
                    buildToolsVersion =23.0.1                    defaultConfig.with {
                        的applicationID =com.example.app
                        minSdkVersion.apiLevel = 9
                        targetSdkVersion.apiLevel = 23
                        版本code = 1
                        的versionName =1.0
                    }                }
                android.buildTypes {
                    发布 {
                        minifyEnabled = FALSE
                        proguardFiles + =文件(ProGuard的-rules.txt')
                    }
                }                    packagingOptions {
                        排除META-INF /相关内容
                        排除META-INF /注意事项
                        排除META-INF / LICENSE
                        排除META-INF / LICENSE.TXT
                        排除META-INF / NOTICE.txt                    }                android.ndk {
                    MODULENAME =jniSample
                }                android.productFlavors {
                    //详细abiFilter说明,请参见支持的ABI@
                    // https://developer.android.com/ndk/guides/abis.html#sa
                    创建(ARM){
                        ndk.abiFilters.add(armeabi)
                    }
                    创建(ARM7){
                        ndk.abiFilters.add(armeabi-V7A)
                    }
                    创建(ARM8){
                        ndk.abiFilters.add(arm64-V8A)
                    }
                    创建(86){
                        ndk.abiFilters.add(86)
                    }
                    创建(X86-64){
                        ndk.abiFilters.add(x86_64的)
                    }
                    创建(MIPS){
                        ndk.abiFilters.add(MIPS)
                    }
                    创建(MIPS-64){
                        ndk.abiFilters.add(MIPS64)
                    }
                    //要包括所有的CPU架构,叶abiFilters空
                    创建(全能)
                }                依赖{
                    编译文件树(导演:'库',包括:['的* .jar'])
                    testCompile'的JUnit:JUnit的:4.12
                    编译com.android.support:appcompat-v7:23.0.1
                    编译com.google.android.gms:播放服务的广告:8.4.0                    编译文件(库/ HttpClient的-4.1.3.jar')
                    编译文件(库/的HttpCore-4.1.4.jar')
                }            }

我的build.gradle(项目)

  buildscript {
    库{
        jcenter()
    }
    依赖{
        类路径'com.android.tools.build:gradle-experimental:0.4.0
        //注意:不要在这里把你的应用程序依赖关系;他们属于
        //在单个模块的build.gradle文件
    }
}allprojects {
    库{
        jcenter()
    }
}任务清除(类型:删除){
    删除rootProject.buildDir
}

gradle.wrapper.properties

  distributionBase = GRADLE_USER_HOME
distributionPath =包装/ dists中
zipStoreBase = GRADLE_USER_HOME
zipStorePath =包装/ dists中
distributionUrl = HTTPS \\://services.gradle.org/distributions/gradle-2.8-all.zip


解决方案

我的问题都解决了该解决方案是把'依赖'的模型之外{}

和ProGuard的规则改为

  proguardFiles.add(文件(ProGuard的-rules.txt))

而不是

  proguardFiles + =文件(ProGuard的-rules.txt')

I am trying to do basic ndk implementation using android studio. Now i am failed to sync gradle i think that some configurations are missed from buid.gradle

I getting this error

Error:Unable to load class 'com.android.build.gradle.managed.BuildType_Impl'. Possible causes for this unexpected error include:

  • Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.) Re-download dependencies and sync project (requires network)
  • The state of a Gradle build process (daemon) may be corrupt. Stopping all Gradle daemons may solve this problem. Stop Gradle build processes (requires restart)
  • Your project may be using a third-party plugin which is not compatible with the other plugins in the project or the version of Gradle requested by the project.
In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.

My buid.gradle (app)

 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')
                }

            }

My build.gradle (project)

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

解决方案

My problems are solved the solution was putting 'dependencies' outside the model {}

and proGuard Rule changed into

proguardFiles.add(file("proguard-rules.txt"))

instead of

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

这篇关于无法加载类的com.android.build.gradle.managed.BuildType_Impl的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆