Sim*_*rta 20 android gradle build.gradle android-gradle-3.0
升级到Gradle 4.x后,我收到警告
不推荐使用CompileOptions.bootClasspath属性,并计划在Gradle 5.0中将其删除.请改用CompileOptions.bootstrapClasspath属性.
在我的一个项目中.bootClasspath我的build.gradle中没有看到任何调用或类似内容.这个警告意味着什么?
警告仅出现在公共子项目中,而不是核心中.
公共/的build.gradle:
apply plugin: 'com.android.library'
ext {
PUBLISH_GROUP_ID = 'com.afollestad.material-dialogs'
PUBLISH_ARTIFACT_ID = 'commons'
PUBLISH_VERSION = '0.9.2.3'
BUILD_TOOLS = "26.0.3"
TARGET_SDK = 25
}
android {
compileSdkVersion TARGET_SDK
buildToolsVersion BUILD_TOOLS
defaultConfig {
minSdkVersion 16
targetSdkVersion TARGET_SDK
versionCode 1
versionName PUBLISH_VERSION
}
lintOptions {
checkReleaseBuilds false
}
}
dependencies {
implementation project(':core')
}
// Changes to this block must be applied in core/build.gradle and commons/build.gradle
task("javadoc", type: Javadoc) {
description "Generates Javadoc API documentation for the main source code."
source = android.sourceSets.main.java.srcDirs
ext.androidJar = "${android.sdkDirectory}/platforms/${android.compileSdkVersion}/android.jar"
classpath += files(ext.androidJar)
exclude "**/BuildConfig.java"
exclude "**/R.java"
options.links("http://docs.oracle.com/javase/7/docs/api/");
options.links("http://d.android.com/reference/");
}
Run Code Online (Sandbox Code Playgroud)
核心/的build.gradle:
apply plugin: 'com.android.library'
ext {
PUBLISH_GROUP_ID = 'com.afollestad.material-dialogs'
PUBLISH_ARTIFACT_ID = 'core'
PUBLISH_VERSION = '0.9.2.3'
SUPPORT_LIBRARY_VERSION = '25.4.0'
BUILD_TOOLS = "26.0.3"
TARGET_SDK = 25
}
android {
compileSdkVersion TARGET_SDK
buildToolsVersion BUILD_TOOLS
defaultConfig {
minSdkVersion 16
targetSdkVersion TARGET_SDK
versionCode 1
versionName PUBLISH_VERSION
consumerProguardFiles 'progress-proguard.txt'
}
lintOptions {
checkReleaseBuilds false
}
}
dependencies {
api "com.android.support:support-v13:$SUPPORT_LIBRARY_VERSION"
api "com.android.support:appcompat-v7:$SUPPORT_LIBRARY_VERSION"
api "com.android.support:recyclerview-v7:$SUPPORT_LIBRARY_VERSION"
api "com.android.support:support-annotations:$SUPPORT_LIBRARY_VERSION"
implementation "me.zhanghai.android.materialprogressbar:library:1.4.1"
}
// Changes to this block must be applied in core/build.gradle and commons/build.gradle
task("javadoc", type: Javadoc) {
description "Generates Javadoc API documentation for the main source code."
source = android.sourceSets.main.java.srcDirs
ext.androidJar = "${android.sdkDirectory}/platforms/${android.compileSdkVersion}/android.jar"
classpath += files(ext.androidJar)
exclude "**/BuildConfig.java"
exclude "**/R.java"
options.links("http://docs.oracle.com/javase/7/docs/api/");
options.links("http://d.android.com/reference/");
}
Run Code Online (Sandbox Code Playgroud)
小智 16
我认为这条关于java Classpath和旧JDK的消息,将其添加到您的gradle将解决它:
android {
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
Run Code Online (Sandbox Code Playgroud)
建议使用java 9 JDK并卸载旧的JDK,然后将其包含在项目结构中:File- > Other settings- > Default project structure.
可能的结论:
android-studio的默认JDK是...\Android studio\jre(嵌入式JDK),如上图所示.此嵌入式JDK包含已弃用的bootClasspath.
使用包含bootstrapClasspath的新JDK 或修改你的compileOptions解决方案.
为什么旧的JDK(嵌入式)与新的gradle版本不兼容?
我不知道.
Sim*_*rta 16
我的Gradle /usr/lib/jvm/java-8-openjdk-amd64/jre在Ubuntu上使用OpenJDK 8 (参见println System.getProperty("java.home")build.gradle中的添加.没有涉及Android Studio.
我可以通过显式设置sourceCompatibility和targetCompatibility1.7(默认值)来触发警告.通过将Java版本更改为
android {
compileOptions {
sourceCompatibility 1.8
targetCompatibility 1.8
}
}
Run Code Online (Sandbox Code Playgroud)
警告消失了.
仅针对一个项目显示警告的原因是它不会重复.由于字母数字排序,commons之前配置.当我设置,并以1.8 ,警告进入.coresourceCompatibilitytargetCompatibilitycommonscore
所有项目的设置sourceCompatibility和targetCompatibility1.8都会完全删除警告.如果这是你想要的项目,以及为什么Gradle 4无法使用1.7的警告是两个单独的问题.
| 归档时间: |
|
| 查看次数: |
11622 次 |
| 最近记录: |