Android Studio3.1升级遇到的坑

1,gradle-wrapper.properties 更改distributionUrl到最新 如下:gradle-4.4-all.zip

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

2,检查所有build.gradle文件 更改过时配置

compile拆成了两个:implementation只在本Module中有效,api对所有Module都有效

 compile 替换为 implementation/api   
 instrumentTestCompile/androidTestCompile 替换为 androidTestImplementation/androidTestApi 
 instrumentTest  替换为 androidTest 
 testCompile  替换为 testImplementation/testApi
 debugCompile 替换为debugImplementation
 releaseCompile 替换为 releaseImplementation
 apt 替换为 annotationProcessor 

3,检查project层级build.gradle文件 配置google()

如果不配置 会报错:Failed to resolve:

//注意:google()放在jcenter()前面,不然会报Could not find runtime.jar (android.arch.lifecycle:runtime:1.1.0)错误.
buildscript {
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.2'

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

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

task clean(type: Delete) {
    delete rootProject.buildDir
}

4,检查所有build.gradle中buildTypes配置要一致

比如主Module配置了tesing 其他所有module中也要配置相同的. 否则会报错:Unable to resolve dependency for ‘:app@tesing/compileClasspath’: Could not resolve project

buildTypes {
        tesing{
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值