Android studio低版本的工程升级到高版本的痛苦之旅

修改内容比较简单,就是更新下版本号和修改下文字

时间很急迫,客户急着要

之前没发布过程序,而且Android studio在线下载gradle编译工具非常慢

 

下面是笔者踩过的坑,笔者一一记录下来

一、旧版本更新新版本几个需要修改的地方

1、gradle\wrapper\gradle-wrapper.properties文件

旧:distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip

新:distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip

 

2、build.gradle文件

旧:

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

新:

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

 

 

3、app\build.gradle文件

旧:

android {
    compileSdkVersion 26
    buildToolsVersion "26.0.3"

新:

android {
    compileSdkVersion 26
   // buildToolsVersion "26.0.3"

 

依赖库语法的更改,compile变成implementation,testCompile变成testImplementation

注意有的依赖库在新版本上已经更新版本了 alpha1 ->beta1

旧:

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    testCompile 'junit:junit:4.12'
    compile 'com.squareup.okhttp3:okhttp:3.8.0'
    compile 'com.android.support:appcompat-v7:26.0.0-alpha1'
    compile 'com.android.support:design:26.0.0-alpha1'
    compile 'com.android.support:support-v4:26.0.0-alpha1'
    compile 'com.amap.api:location:latest.integration'
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    testImplementation 'junit:junit:4.12'
    implementation 'com.squareup.okhttp3:okhttp:3.8.0'
    implementation 'com.android.support:appcompat-v7:26.0.0-beta1'
    implementation 'com.android.support:design:26.0.0-alpha1'
    implementation 'com.android.support:support-v4:26.0.0-alpha1'
    implementation 'com.amap.api:location:latest.integration'
}

二、Android studio下载gradle过慢的问题

https://www.jianshu.com/p/338860fc4921

buildscript {
    repositories {
        maven{url 'http://maven.aliyun.com/nexus/content/groups/public/'}
        maven { url "https://jitpack.io" }
        google()
//        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.2'
    }
}

allprojects {
    repositories {
//        jcenter()
        maven{url 'http://maven.aliyun.com/nexus/content/groups/public/'}
        google()
    }
}

 

三、Android版本号更改问题

旧版本是在AndroidManifest.xml上修改

新版本是在app\build.gradle中修改,versionCode用户看不到的,判断高版本覆盖靠它,versionName是给用户看的

defaultConfig {

        versionCode 2
        versionName "2.0.5"

四:Android发布release版本

Android studio左下角有build variants  debug改成relase

菜单

1、“build”-》“Make project” 

2、“build”-》“build Bundles /apks”-》"build apks"

3、"build"-》"Generate sign bundles/apks"

签名教程

https://jingyan.baidu.com/article/22a299b583606b9e19376acf.html

V1key和V2key区别

https://blog.csdn.net/francisbingo/article/details/78655848

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值