【发布时间】:2021-08-09 20:54:14
【问题描述】:
我已将我的 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
}
}
我不知道为什么我的活动中有Instantiatable 错误。所有这些活动都扩展了一个BaesActivity,它扩展了AppCompatActivity。所以这个错误并没有任何意义。
但是当我将 Gradle 包装器降级到 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
这是什么警告,我该如何解决?
【问题讨论】:
-
我对 AGP 7.0.2 有同样的错误。你已经解决了吗?
-
@GabiMoreno 我没有找到合适的方法,所以我现在恢复到 AGP
4.2.2和 JDK1.8 -
好的。谢谢,@Nishant ????
标签: java android android-studio kotlin gradle