Android studio 2.3 迁移项目到 3.0
来源:互联网 发布:网络分为哪几类 编辑:程序博客网 时间:2024/06/07 12:06
1-gradle下载4.1,
2-Build tools 下载 26.0.2
3-SDK API26(android 8.0)
4-Porject:src 报错
1-gradle打包,自定义apk名称
applicationVariants.all { variant -> variant.outputs.each { output -> def outputFile = output.outputFile if (outputFile != null && outputFile.name.endsWith('.apk')) { //这里修改apk文件名 def fileName = "${variant.productFlavors[0].name}.apk" output.outputFile = new File(outputFile.parent, fileName) } }}
报错: Error:(58, 0) Cannot set the value of read-only property 'outputFile' for ApkVariantOutputImpl_Decorated{apkData=Main{type=MAIN, fullName=AHMobileReleaseUnsigned, filters=[]}} of type com.android.build.gradle.internal.api.ApkVariantOutputImpl.
<a href="openFile:E:\Projects\AS3.0projects\v2.x\src\mobile\iptvclient\build.gradle">Open File</a>
处理办法(直接用下列代码替换):
android.applicationVariants.all { variant -> variant.outputs.all { outputFileName = "${variant.productFlavors[0].name}.apk" } }
2-维度统一
报错: Error:All flavors must now belong to a named flavor dimension. Learn more at https://d.android.com/r/tools/flavorDimensions-missing-error-message.html
解决办法(版本号后添加flavorDimensions “versionCode”):
defaultConfig { targetSdkVersion:*** minSdkVersion :*** versionCode:*** versionName :***//版本名后面添加一句话,意思就是flavor dimension 它的维度就是该版本号,这样维度就是都是统一的了 flavorDimensions "versionCode"}
解决:项目中用了多渠道,3.0之前配置多渠道:productFlavors配置不同的渠道包,3.0 新增了flavorDimensions的配置
报错的大致原因是:Android Plugin3.0的依赖机制:在使用library时会自动匹配variant(debug, release),就是说app的debug会自动匹配library的debug,相信大多数人也像我一样,当library多了,不会手动选择每个Library的variant。现在好了,它会自动匹配了。同样如果使用flavor的时候,比如app的redDebug同样会自动匹配library的readDebug。虽然有这样的优势,但是在使用flavor时,必须定义flavor dimension,否则会提示错误
项目中修改:
productFlavors { AHMobile { applicationId "com.ahmobile.android.tvclient" //com.zte.iptvclient.android.ahmobile signingConfig signingConfigs.ahmobile_release versionCode 11 versionName "1.1.2.3" manifestPlaceholders = [APP_MARKET_VALUE: "Https-market-Android"] //**如下两行** dimension "versionCode" matchingFallbacks = ['versionCode'] } ...}
5-AAPT2 编译报错 AAPT2 error
报错 Error:java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
解决:在gradle.properties中关闭APPT2 编译
android.enableAapt2=false
注:如果是eclipse转到as上的项目,可能没有gradle.properties文件,请在项目根目录中手动创建
6-Unable to resolve dependency
Error:Unable to resolve dependency for ':mobile:iptvclient@AHMobileReleaseUnsigned/compileClasspath': Could not resolve project :uisdk:baseclient.
<a href="openFile:E:/Projects/AS3.0projects/v2.x/src/mobile/iptvclient/build.gradle">Open File</a><br><a href="Unable to resolve dependency for ':mobile:iptvclient@AHMobileReleaseUnsigned/compileClasspath': Could not resolve project :uisdk:baseclient.">Show Details</a>
原因:
local与debug不兼容。原因是在主项目中有一个变种local,而在library中是没有对应的。
build.gradle 修改如下:
buildTypes { release { // signingConfig signingConfigs.ahmobile_release minifyEnabled true // 是否混淆 shrinkResources true zipAlignEnabled true // 是否zip对齐 proguardFiles 'proguard.cfg'/* * 因为只有release,没有debug,新增如下内容 */ matchingFallbacks = ['debug'] } releaseUnsigned.initWith(buildTypes.release) releaseUnsigned { signingConfig null }}
7-添加google()
buildscript { repositories { ... google() } dependencies { classpath 'com.android.tools.build:gradle:3.0.0' }}allprojects { repositories { ... google() }}
- Android studio 2.3 迁移项目到 3.0
- 迁移项目到Android Studio
- Eclipse项目迁移到Android Studio中
- 将Eclipse项目迁移到Android Studio
- eclipse到Android Studio的项目迁移
- eclipse项目迁移到android studio【转载】
- eclipse项目迁移到Android Studio
- eclipse到Android Studio的项目迁移
- eclipse项目迁移到android studio
- eclipse项目迁移到android studio上
- 项目从Eclipse到Android Studio迁移
- 迁移Eclipse项目到Android Studio
- Eclipse项目迁移到Android Studio记录
- eclipse项目迁移到android studio【转载】
- eclipse项目迁移到Android studio
- 公司eclipse项目迁移到android studio
- 迁移到Android Studio 3.0
- 迁移到Android Studio 3.0
- Hbase-简介-存储API与实现
- 定形相变复合材料热性能标准测试方法及其改进
- [ 线段树 ] [ POI2014 ] BZOJ3521
- 11.1
- 神奇的序列 HNUST 1883
- Android studio 2.3 迁移项目到 3.0
- 论文阅读笔记:A 3D Coarse-to-Fine Framework for Automatic Pancreas Segmentation
- Android 8.0 Oreo(用户体验篇)
- HDU1280-前m大的数
- 关于ajax异步加载图片的路径赋值问题
- MFC cdc hdc 等
- JAVA自动装箱和拆箱功能是把双刃剑
- 2017年12月18日 第四十天次总结
- rsync服务的安装、配置、使用及其安全问题