当使用 JDK 11 目标时,我收到此错误:
错误:包 android.app 不存在
我看到了升级到“Canary”AS 版本的解决方案。我更喜欢使用测试版或稳定版 Android Studio。我定期更新它。不打算仅仅为了升级而进行重大改变。
因此,这效果很好:即使使用 Android Studio“项目设置”和带有“JDK 11”的“JDK”。
当 build.gradle 具有这些编译选项时,一切正常。
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
Run Code Online (Sandbox Code Playgroud)
这给出了提到的错误:
compileOptions {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
Run Code Online (Sandbox Code Playgroud)
我的 build.grade 项目文件是:
buildscript {
repositories {
mavenCentral()
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.2.1'
classpath 'org.ajoberstar:grgit:3.3'
}
}
allprojects {
repositories {
maven { url "https://jitpack.io" }
google()
}
}
Run Code Online (Sandbox Code Playgroud)
我的 build.grade 模块文件的部分内容是:
apply plugin: 'com.android.application'
repositories {
mavenCentral()
maven { url "https://jitpack.io" }
google()
}
Run Code Online (Sandbox Code Playgroud)
如何使用 (Oracle) JDK 11 编译器正常构建?
刚刚收到 Android Studio / Gradle 7 升级。
现在一切正常!
Run Code Online (Sandbox Code Playgroud)compileOptions { sourceCompatibility JavaVersion.VERSION_11 targetCompatibility JavaVersion.VERSION_11 }
| 归档时间: |
|
| 查看次数: |
11222 次 |
| 最近记录: |