Android Studio升级到3.0遇到的问题

  • app/build.gradle 报错

错误信息:
Cannot set the value of read-only property 'outputFile' for ApkVariantOutputImpl_Decorated{apkData=Main{type=MAIN, fullName=debug, filters=[]}} of type com.android.build.gradle.internal.api.ApkVariantOutputImpl.

解决方法:
Use output.outputFileName instead of output.outputFile

android.applicationVariants.all { variant ->
variant.outputs.all {
    outputFileName = "app_${defaultConfig.versionName}_${variant.productFlavors[0].name}.apk"  
} 


  • Android SDK Build Tools version 错误

错误信息:
The specified Android SDK Build Tools version (25.0.2) is ignored, as it is below the minimum supported version (26.0.2) for Android Gradle Plugin 3.0.0. Android SDK Build Tools 26.0.2 will be used. To suppress this warning, remove "buildToolsVersion '25.0.2'" from your build.gradle file, as each version of the Android Gradle Plugin now has a default version of the build tools. Update Build Tools version and sync project

解决方法:
升级 buildToolsVersion 至 '26.0.2'


  • build.gradle 报错

错误信息:
Could not find com.android.tools.build:gradle:3.0.0. Searched in the following locations:

解决方法:

buildscript {
    repositories {
        ...
        // You need to add the following repository to download the
        // new plugin.
        google() // new which replace https://maven.google.com
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.0'
    }
}


错误信息:
Failed to resolve: com.android.support:appcompat-v7:25.4.0 Add Google Maven repository and sync project Show in File Show in Project Structure dialog

解决方法:

allprojects {
    repositories {
        ...
        // add new repository
        maven {
            url "https://maven.google.com"
        }
    }
}
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容