Android现有项目迁移AndroidX

Android Studio 一键迁移
Refactor-->Migrate to AndroidX...

老项目中遇到的报错提示:
1、修改com.android.tools.build:gradle版本

The gradle plugin version in your project build.gradle file needs to be set 
to at least com.android.tools.build:gradle:3.2.0

修改build.gradle文件,com.android.tools.build:gradle版本至少是3.2.0或更高。
eg:新项目中使用的版本

classpath "com.android.tools.build:gradle:4.0.1"
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-bin.zip

2、修改 android.enableAapt2=true或注释/删除

A problem occurred evaluating project ':app'.
> Failed to apply plugin [id 'com.android.internal.application']
   > The option 'android.enableAapt2' is deprecated.
     The current default is 'true'.
     It has been removed from the current version of the Android Gradle plugin.
     This property has no effect, AAPT2 is now always used.

3、butterknife为support包下的不适用:

Execution failed for task ':app:javaPreCompileDebug'.
> Could not resolve all files for configuration ':app:debugAnnotationProcessorClasspath'.
   > Failed to transform butterknife-compiler-8.8.1.jar (com.jakewharton:butterknife-compiler:8.8.1) to match attributes {artifactType=processed-jar, org.gradle.category=library, org.gradle.libraryelements=jar, org.gradle.status=release, org.gradle.usage=java-runtime}.
      > Execution failed for JetifyTransform: /home/pateo/.gradle/caches/modules-2/files-2.1/com.jakewharton/butterknife-compiler/8.8.1/b2f4505a1babb7b7c11abbbf8ea4c90b18c3aeac/butterknife-compiler-8.8.1.jar.

修改butterknife版本为:

implementation "com.jakewharton:butterknife:10.0.0"
annotationProcessor "com.jakewharton:butterknife-compiler:10.0.0"

4、AndroidManifest.xml 中的minSdkVersion不适用:

The minSdk version should not be declared in the android manifest file. You can move 
the version from the manifest to the defaultConfig in the build.gradle file.

删除AndroidManifest.xml 中的minSdkVersion:

5、Lint检查,build.gradle文件,增加如下代码(检查发现错误仍然继续构建):

Execution failed for task ':app:lintVitalRelease'.
> Lint found fatal errors while assembling a release target.

  To proceed, either fix the issues identified by lint, or modify your build script as follows:
  ...
  android {
      lintOptions {
          checkReleaseBuilds false
          // Or, if you prefer, you can continue to check for errors in release builds,
          // but continue the build even when errors are found:
          abortOnError false
      }
  }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值