Gradle插件3.x升级4.2

升级可能遇到的问题:

  1. NoClassDefFoundError: com/squareup/javapoet/TypeName
  2. No signature of method: build_xxxxx.android()?
  3. What went wrong:
    Could not resolve all dependencies for configuration ':detachedConfiguration13'.
    Using insecure protocols with repositories, without explicit opt-in, is unsupported. Switch Maven repository 'maven(http://maven.aliyun.com/nexus/content/groups/public/)' to redirect to a secure protocol (like HTTPS) or allow insecure protocols. See https://docs.gradle.org/7.0.2/dsl/org.gradle.api.artifacts.repositories.UrlArtifactRepository.html#org.gradle.api.artifacts.repositories.UrlArtifactRepository:allowInsecureProtocol for more details.
gradle.properties 
GRADLE_BUILD_TOOL_VERSION=4.2.0

apk/build.gradle
classpath 'com.android.tools.build:gradle:'+GRADLE_BUILD_TOOL_VERSION

gradle-wraper.properties 
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-all.zip
  • 废弃方法替代

移除依赖项配置

compile根据用例,该配置已被 api 或 implementation 替换。
同样适用于 *Compile 变体,例如 debugCompile。
provided
该配置已被 compileOnly 替换。
同样适用于 *Provided 变体,例如 releaseProvided。
apk
该配置已被 runtimeOnly 替换。
publish
该配置已被 runtimeOnly 替换。

用于启用或停用构建功能的新选项

-    packageBuildConfig  false 

+    buildFeatures {
+        buildConfig = false
+    }

弃用了 includeCompileClasspath

-        javaCompileOptions {
-            annotationProcessorOptions {
-                includeCompileClasspath = true
-            }
-        }

-       provided 'com.squareup:javapoet:1.9.0'
+       compileOnly 'com.squareup:javapoet:1.9.0'
+       annotationProcessor 'com.squareup:javapoet:1.9.0'

升级buildToolsVersion最小支持版本升级

-      buildToolsVersion = '28.0.3'
+      buildToolsVersion = '29.0.2'

你可能感兴趣的:(Gradle插件3.x升级4.2)