Android Studio 3.0升级--Unable to load class ‘org.gradle.api.internal.component.Usage’.

3.0升级之后遇到不少错误

1.Unable to load class ‘org.gradle.api.internal.component.Usage’.

解决办法:项目根目录的 build.gradle 中 修改如下代码:

 

buildscript {
    repositories {
        jcenter()
        google()
    }
    dependencies {
        ...
        classpath 'com.novoda:bintray-release:0.5.0'//修改此处版本号为 0.5.0---修改之前是0.3.4(AS版本3.1.4改为0.8.0)
        ...
    }
}

2.Error:Unable to find method 'com.android.build.gradle.internal.variant.BaseVariantData.getOutputs()

 

buildscript {
    ext.kotlin_version = '1.1.2-3'
    repositories {
        maven { url 'https://maven.google.com' }
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.0-alpha1'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

将1.1.2-3’ -> ‘1.1.2-4’

 

3.Failed to resolve: multidex
  Open File

  Failed to resolve: multidex-instrumentation
  Open File

Android Studio 3.0升级--Unable to load class ‘org.gradle.api.internal.component.Usage’._第1张图片

出现情况是我将android studio从2.3升级到3.2版本的时候编译报错

解决办法:

在工程的build文件下保持google()在第一位置

allprojects {
    repositories {
        google()
        jcenter()
    }
}

4.All flavors must now belong to a named flavor dimension. Learn more at

3.0之前配置多版本打包是不会有问题的,可以正常运行、打包。但是AndroidStudio升级到3.0之后,配置多版本打包运行的时候会提示这个错误(Error:All flavors must now belong to a named flavor dimension. Learn more at https://d.android.com)

解决办法:

在defaultConfig{}中添加:

flavorDimensions ""   就可以了

Android Studio 3.0升级--Unable to load class ‘org.gradle.api.internal.component.Usage’._第2张图片

flavorDimensions值与versionCode值保持相同

5.ERROR: Unable to find method 'org.gradle.api.tasks.TaskInputs.file(Ljava/lang/Object;)Lorg/gradle/api/tasks/TaskInputs;'.
Possible causes for this unexpected error include:

解决办法:

将项目build.gradle内greedao配置版本升级

原来是:classpath 'org.greenrobot:greendao-gradle-plugin:3.1.0'

升级为:classpath 'org.greenrobot:greendao-gradle-plugin:3.2.2'

还有一处在项目主项目build.gradle中添加的依赖包连接升级

原来是:compile 'org.greenrobot:greendao:3.1.0'

升级后:'org.greenrobot:greendao:3.2.2'

6.待补充

 

你可能感兴趣的:(android公共方法收集)