关于警告:INFO: API 'variant.getJavaCompiler()' is obsolete and has..

警告信息如下:
INFO: API ‘variant.getJavaCompiler()’ is obsolete and has been replaced with ‘variant.getJavaCompileProvider()’.
It will be removed at the end of 2019.
For more information, see https://d.android.com/r/tools/task-configuration-avoidance.
To determine what is calling variant.getJavaCompiler(), use -Pandroid.debug.obsoleteApi=true on the command line to display more information.
Affected Modules: material_calendarview_libary

代码如下:

android.libraryVariants.all { variant ->
  task("generate${variant.name.capitalize()}Javadoc", type: Javadoc) {
    title "Material CalendarView ${version}"
    description "Generates Javadoc for $variant.name."
    source = variant.javaCompiler.source
    doFirst {
      classpath = files(variant.javaCompiler.classpath.files, project.android.getBootClasspath())
    }
    exclude '**/BuildConfig.java'
    exclude '**/R.java'
    options {
      links "http://docs.oracle.com/javase/7/docs/api/"
      linksOffline "http://d.android.com/reference", "${android.sdkDirectory}/docs/reference"
    }
  }
}

主要是将第五行代码改为如下方式:

source = variant.javaCompileProvider.name

问题解决来源:
根据gradle源码:可以知道javaCompiler已经过期,source也没有定义。
tips:

android.libraryVariants.all

中的libraryVariants可以点击,通过查看源码解决。这段代码暂时不清楚,临时解决警告而解决。

关于打包时候会出现类似的警告,官方有新的打包方式,官网上有

发布了132 篇原创文章 · 获赞 29 · 访问量 26万+

猜你喜欢

转载自blog.csdn.net/Mr_Tony/article/details/103883179