结合最近对公司项目做了一下升级,踩了点坑。记录一下,方便后续有人参考。

module模块build.gradle变化

  • apply plugin变成了plugins
  • 对部分android闭包下面的属性也做了缩短优化,但但可以不修改。
  • apply from 还可正常使用,plugins的顺序还要放前面。
  • 去除dexOptions, 删除javaCompileOptions注解处理器配置否则项目无法正常sync,使用kapt替换。
plugins {id 'com.android.application'id 'org.jetbrains.kotlin.android' version '1.6.10' apply falseid 'kotlin-android'id 'kotlin-kapt'id 'com.google.firebase.crashlytics' apply falseid 'com.google.gms.google-services'
}
//apply plugin: 'com.android.application'
//apply plugin: 'kotlin-android'
//apply plugin: 'kotlin-android-extensions'
//apply plugin: 'kotlin-kapt'
//apply plugin: 'com.google.firebase.crashlytics'
apply from: 'config.gradle'
android {compileSdk 31defaultConfig {versionCode 1versionName '1.0'minSdk 21targetSdk 31}
//    dexOptions {//        preDexLibraries true
//        maxProcessCount 8
//        threadCount 8
//        javaMaxHeapSize "6g"
//        jumboMode true
//    }
}

项目gradle

  • seeting.gradle新增了插件管理
  • 如果使用了http,需要在maven中配置allowInsecureProtocol = true
pluginManagement {repositories {gradlePluginPortal()google()mavenCentral()}
}
dependencyResolutionManagement {repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)repositories {google()mavenCentral()}
}maven {url 'http://maven.aliyun.com/nexus/content/groups/public/'allowInsecureProtocol = true
}

问题记录

A problem occurred evaluating project ‘:app’.
Failed to apply plugin ‘com.android.internal.application’.
The option ‘android.enableBuildCache’ is deprecated.
The current default is ‘false’.
It was removed in version 7.0 of the Android Gradle plugin.
The Android-specific build caches were superseded by the Gradle build cache (https://docs.gradle.org/current/userguide/build_cache.html).

  1. gradle.properties文件,把 android.enableBuildCache=true 和 android.buildCacheDir=./build/buildCache/注销掉。

Firebase Crashlytics - java.lang.IllegalStateException: The Crashlytics build ID is missing.

  1. 遇到问题,脚本能正常编译后运行程序启动奔溃,有如下日志,原来是crashlytics没有被启动apply false 改为true。

Method ‘buildStarted’ from class ‘BuildTraceListener’ does not override method from its superclass or interfaces but is annotated with @Override.

  1. Gradle 7.0移除了BuildListener.buildStarted(Gradle),直接删除buildStarted方法即可。
    改用BuildListener.beforeSettings(Settings)代替。

java.lang.RuntimeException: Manifest merger failed with multiple errors

  1. 打开每个模块的清单文件切到Merged Manifest视图查看合并错误。

using Jetifier. Reason: AmbiguousStringJetifierException, message: The given
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: /Users/mahui/.gradle/caches/modules-2/files-2.1/com.jakewharton/butterknife-compiler/8.8.1/b2f4505a1babb7b7c11abbbf8ea4c90b18c3aeac/butterknife-compiler-8.8.1.jar.
Failed to transform ‘/Users/mahui/.gradle/caches/modules-2/files-2.1/com.jakewharton/butterknife-compiler/8.8.1/b2f4505a1babb7b7c11abbbf8ea4c90b18c3aeac/butterknife-compiler-8.8.1.jar’ using Jetifier. Reason: AmbiguousStringJetifierException, message: The given artifact contains a string literal with a package reference ‘android.support.v4.content’ that cannot be safely rewritten. Libraries using reflection such as annotation processors need to be updated manually to add support for androidx… (Run with --stacktrace for more details.)
This is a known exception, and Jetifier won’t be able to jetify this library.
Suggestions:
- If you believe this library doesn’t need to be jetified (e.g., if it already supports AndroidX, or if it doesn’t use support libraries/AndroidX at all), add android.jetifier.blacklist = {comma-separated list of regular expressions (or simply names) of the libraries that you don’t want to be jetified} to the gradle.properties file.
- If you believe this library needs to be jetified (e.g., if it uses old support libraries and breaks your app if it isn’t jetified), contact the library’s authors to update this library to support AndroidX and use the supported version once it is released.
If you need further help, please leave a comment at https://issuetracker.google.com/issues/140747218.

  1. 出现了support和androidx迁移遗留问题,虽然我们项目已经迁移了androidx,但可能不彻底。这边暂时的解决办法是根据提示信息在gradle.properties配置文件中增加:android.jetifier.ignorelist=bundletool-1.6.0.jar,同步一下重新编译居然通过了。

Android~老项目项目升级GradleAGP 7.0踩坑相关推荐

  1. 一次Delta lake 0.8.0 踩坑有感:使用新框架的新版本,一定要尽早关注多多关注社区动态...

    点击上方蓝色"明哥的IT随笔",关注并选择"设为星标",keep striving! 一.数据胡三剑客介绍 关注大数据发展动态的朋友,都知道最近几年数据湖存储引 ...

  2. 【Vue】Vue1.0+Webpack1+Gulp项目升级构建方案的踩坑路

    最近半年在维护公司的一个管理后台项目,搭建之初的技术栈比较混乱,构建方案采用了Gulp中调用Webpack的方式,Gulp负责处理.html文件,Webpack负责加载.vue..js等.而在这一套构 ...

  3. android8 老手机,老用户福音 四款荣耀老产品即将升级安卓8.0

    [IT168 资讯]今日上午,荣耀在官微宣布启动新一轮的老款手机安卓8.0系统升级计划.在6月30日,将向荣耀8.荣耀V8.荣耀Note 8.荣耀畅玩6X等四款2016年发布的老机型推送EMUI 8. ...

  4. mate7安装android o,华为Mate7升级安卓6.0详细教程

    来讲一下华为Mate7升级安卓6.0(EMUI4.0)M版本详细图文教程吧,新的一年了,大家都迫不及待的想升级一下EMUI4.0,但是很多朋友都不知道怎样来升级,下面刷机网小编就来给大家仔细说一说吧, ...

  5. 荣耀6plus android版本号,荣耀6PLUS升级安卓6.0(emui4.0)感受

    我的手机是荣耀6PLUS,是16年2月买,当时降价200,卖1399.只所以选他,感觉主要配置同Mate7,考虑到自己连密码都不设,又便宜700,所以就买了它.当时它的系统是B133.买了之后,双卡使 ...

  6. 如何选好网络项目,五条建议避免你踩坑

    关于互联网创业,很多人都陆陆续续踩过很多坑,在踩坑的同时还交了不少的学费.刚入行的三年都是在小打小闹,但这三年也是至关重要,当你有了这几年积聚的底蕴,就没有相关的行业洞察力,自然也无法看清项目的本质. ...

  7. Qt5.13.2中配置opencv4.5.0踩坑记录

      目录 cmake编译opencv时速度过慢或超时 mingw32-make时报错 错误一 [modules\core\CMakeFiles\opencv_core.dir\build.make:1 ...

  8. lgg8各个版本_LG G8 展示机 升级安卓10 防踩坑指南

    先来对比下展示机版本信息是不是大体相同再下手 关于手机中,无s/n,无IMEI 安卓9软件版本为G820UM10C,硬件版本1.0 被阉割功能:5G频段wifi,nfc,移动网络(无基带),高分屏,r ...

  9. 【MathType安装】Office2019+MathType7.4.8.0+踩坑记录+最终使用方案

    使用Office2019安装MathType7.4.8.0屡屡碰壁,最终使用的解决方案不同于网络上的大多数方法.尽管当前记录的解决方案还不完美.未做到一劳永逸,但能用就行. MathType安装包获取 ...

最新文章

  1. 内核方式挂载cephfs
  2. Linux三剑客之grep详解
  3. vs2012无法启动已配置的开发Web服务器
  4. Spring boot属性松散绑定
  5. linux显示隐藏分区,找到了linux分区顺序错乱修复方法
  6. Android简单实现Socket通信,客户端连接服务器后,服务器向客户端发送文字数据
  7. mysql循环insert多条数据
  8. 【LeetCode - 131】分割回文串(dp,dfs)
  9. stage3图书管理系统服务器部署
  10. 信息安全系统设计基础第一次实验报告
  11. Windows:win 10系统麦克风没有声音,无法使用
  12. su灯光插件_lightup插件下载|lightup for sketchup下载v4.0中文免费版 附使用教程 - 欧普软件下载...
  13. PHP亿乐社区源码一比一高仿全开源源码
  14. U盘制作DOS启动盘MSDOS 7.10
  15. 手机模拟器自带root_VMOS Pro Android 手机上的模拟器 (手机版虚拟机)
  16. 阿里linux内核月报2014-07-08
  17. 爬虫:获取OLD的Oxford 3000 and 5000
  18. 音乐外链生成 html,音乐外链生成工具V2.1 支持14个音乐网站外链提取转换
  19. 塞规公差带图_塞规和卡规公差表
  20. spring cloud 实现服务不间断

热门文章

  1. Oracle同义词的好处
  2. VSCode配置C++环境【报错interpreter=mi】
  3. 学习通考试刷题(ocs网课助手)
  4. 网络篇 物理拓扑与逻辑拓扑-19
  5. APK获取包名的办法
  6. csol怎么设置屏蔽服务器信息,谁知道反恐精英OL的控制台怎么调? -反恐精英锤子宏设置...
  7. 一步步实现windows版ijkplayer系列文章之三——Ijkplayer播放器源码分析之音视频输出——音频篇
  8. 用iSee图片专家制作淘宝店标教程
  9. cdr文件过大导出pdf打不开_cdr导出pdf 文件有问题怎么办
  10. 口语语汇单词篇(5)