gpt4 book ai didi

java - 升级到 Gradle 包装器到 7.0.2 和 JDK 11 后,Android 版本构建失败

转载 作者:行者123 更新时间:2023-12-04 23:55:58 25 4
gpt4 key购买 nike

我已将我的 Android Studio 更新为 Artic Fox,并将 Gradle 包装器更新为 7.0.2(插件 7.0.0)和 JDK 1.8 -> 11。

当我通过 Android Studio 在我的设备上安装调试版本时,它可以正常工作,并且没有错误。

现在每当我尝试创建发布 APK 时,构建总是失败并出现 Lint 错误。不确定发生了什么。

w: Runtime JAR files in the classpath have the version 1.4, which is older than the API version 1.5. Consider using the runtime of version 1.5, or pass '-api-version 1.4' explicitly to restrict the available APIs to the runtime of version 1.4. You can also pass '-language-version 1.4' instead, which will restrict not only the APIs to the specified version, but also the language features
w: /Users/xxx/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-jdk8/1.4.10/998caa30623f73223194a8b657abd2baec4880ea/kotlin-stdlib-jdk8-1.4.10.jar: Runtime JAR file has version 1.4 which is older than required for API version 1.5
w: /Users/xxx/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-jdk7/1.4.31/84ce8e85f6e84270b2b501d44e9f0ba6ff64fa71/kotlin-stdlib-jdk7-1.4.31.jar: Runtime JAR file has version 1.4 which is older than required for API version 1.5
w: /Users/xxx/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.4.32/461367948840adbb0839c51d91ed74ef4a9ccb52/kotlin-stdlib-1.4.32.jar: Runtime JAR file has version 1.4 which is older than required for API version 1.5
w: /Users/xxx/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-common/1.4.32/ef50bfa2c0491a11dcc35d9822edbfd6170e1ea2/kotlin-stdlib-common-1.4.32.jar: Runtime JAR file has version 1.4 which is older than required for API version 1.5
/src/main/AndroidManifest.xml:23: Error: SplashScreenActivity must extend android.app.Activity [Instantiatable]
android:name="com.abc.xyz.activity.SplashScreenActivity"
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/src/main/AndroidManifest.xml:36: Error: MainActivity must extend android.app.Activity [Instantiatable]
android:name="com.abc.xyz.activity.MainActivity"
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/src/main/AndroidManifest.xml:66: Error: PlayerActivity must extend android.app.Activity [Instantiatable]
android:name="com.abc.xyz.activity.PlayerActivity"
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Explanation for issues of type "Instantiatable":
/Users/xxx/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-jdk8/1.4.10/998caa30623f73223194a8b657abd2baec4880ea/kotlin-stdlib-jdk8-1.4.10.jar: Runtime JAR file has version 1.4 which is older than required for API version 1.5

Activities, services, broadcast receivers etc. registered in the manifest
file (or for custom views, in a layout file) must be "instantiatable" by
the system, which means that the class must be public, it must have an
empty public constructor, and if it's an inner class, it must be a static
inner class.

/Users/xxx/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-jdk7/1.4.31/84ce8e85f6e84270b2b501d44e9f0ba6ff64fa71/kotlin-stdlib-jdk7-1.4.31.jar: Runtime JAR file has version 1.4 which is older than required for API version 1.5

3 errors, 0 warnings
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
}
}

我不确定为什么我的 Activity 会出现那些Instantiatable 错误。所有这些 Activity 都扩展了一个 BaesActivity,后者扩展了 AppCompatActivity。所以这个错误没有任何意义。但是当我将 Gradle wrapper 降级到 6.7.1(插件 4.2.2)和 JDK 1.8 时......一切运行顺利。

还有,我有这些警告,比如

/Users/xxx/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-jdk8/1.4.10/998caa30623f73223194a8b657abd2baec4880ea/kotlin-stdlib-jdk8-1.4.10.jar: Runtime JAR file has version 1.4 which is older than required for API version 1.5

这是什么警告,我该如何解决?

最佳答案

经过大量搜索,我找到了解决方法。

构建因 Instantiatable lint 检查而失败。

Activities, services, broadcast receivers etc. registered in the manifest
file (or for custom views, in a layout file) must be "instantiatable"

有几个解决方案,

  1. 更新应用程序级别的build.gradle(虽然不理想)
android {
lintOptions {
disable "Instantiatable"
}
}
  1. 如果您的应用程序依赖于库模块(像我一样,我在库模块中有 BaseActivities),那么在库模块上禁用 minifyEnabled,除非您尝试这样做,否则没有必要这样做发布库模块(.aar 文件)。

请参阅 here 中的问题.

更具体地说,来自 here 的评论.

关于java - 升级到 Gradle 包装器到 7.0.2 和 JDK 11 后,Android 版本构建失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68718432/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com