随着Gradle 4.10.1
和Android Gradle插件的更新3.3.0
,我得到以下警告:
警告:API'
variantOutput.getPackageApplication()
'已过时,已替换为'variant.getPackageApplicationProvider()
'.
该行,与周围的上下文(由构建变量分配输出文件名):
applicationVariants.all { variant ->
variant.outputs.all { output ->
if (variant.getBuildType().getName() in rootProject.archiveBuildTypes) {
def buildType = variant.getBuildType().getName()
if (variant.versionName != null) {
def baseName = output.baseName.toLowerCase()
String fileName = "${rootProject.name}_${variant.versionName}-${baseName}.apk"
// this is the line:
outputFileName = new File(output.outputFile.parent, fileName).getName()
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
该迁移指南是不是太有帮助; 虽然variant.outputs.all
可能有问题 - 只是不知道要替换什么 - 并且迁移指南指的是任务而不是构建变体.禁用时File ? Settings ? Experimental ? Gradle ? Only sync the active variant
,我会得到更多的弃用警告(重点是,这些方法都没有被直接调用): …
gradle build.gradle android-gradle-plugin deprecation-warning build-variant
我在项目中遇到非常烦人的警告:
WARNING: API 'variant.getMergeResources()' is obsolete and has been replaced with 'variant.getMergeResourcesProvider()'.
It will be removed at the end of 2019.
For more information, see https://d.android.com/r/tools/task-configuration-avoidance.
REASON: It is currently called from the following trace:
...
WARNING: Debugging obsolete API calls can take time during configuration. It's recommended to not keep it on at all times.
Affected Modules: app
Run Code Online (Sandbox Code Playgroud)
由于该警告将在明年成为错误,因此我想一劳永逸地修复它。
我已经更新了gradle插件,google play服务插件和所有依赖项,但是问题仍然存在。
这是项目级别的build.gradle
文件:
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.1'
classpath 'com.google.gms:google-services:4.3.0'
}
} …
Run Code Online (Sandbox Code Playgroud) 我最近开始使用firebase,并遵循官方指南,为项目添加了一些依赖项才能使用它。这是我添加到新创建的项目中的依赖项:
apply plugin: 'com.google.gms.google-services'
implementation "com.google.firebase:firebase-core:$firebaseCoreVersion"
implementation "com.google.firebase:firebase-auth:$firebaseAuthVersion"
buildscript {
...
ext{
firebaseCoreVersion='17.0.0'
firebaseAuthVersion='18.0.0'
}
}
Run Code Online (Sandbox Code Playgroud)
同步我的项目后,我得到了一个非常糟糕的警告。
WARNING: API 'variant.getMergeResources()' is obsolete
and has been replaced with 'variant.getMergeResourcesProvider()'.
It will be removed at the end of 2019.
Run Code Online (Sandbox Code Playgroud)
所以,我在gradle.properties中添加了以下代码行,以查看问题所在。
android.debug.obsoleteApi=true
Run Code Online (Sandbox Code Playgroud)
不幸的是,如果我做错了什么,或者我可以做些什么,我从堆栈跟踪中无法理解。
在整个堆栈跟踪下,请先感谢您可以给我的任何评论或答案。
REASON: It is currently called from the following trace:
java.lang.Thread.getStackTrace(Thread.java:1556)
com.android.build.gradle.internal.errors.DeprecationReporterImpl.reportDeprecatedApi(DeprecationReporterImpl.kt:79)
com.android.build.gradle.internal.api.BaseVariantImpl.getMergeResources(BaseVariantImpl.java:349)
com.android.build.gradle.internal.api.ApplicationVariantImpl_Decorated.getMergeResources(null:-1)
sun.reflect.NativeMethodAccessorImpl.invoke0(NativeMethodAccessorImpl.java:-2)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke(Method.java:498)
org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:104)
groovy.lang.MetaBeanProperty.getProperty(MetaBeanProperty.java:59)
org.gradle.internal.metaobject.BeanDynamicObject$MetaClassAdapter.getProperty(BeanDynamicObject.java:228)
org.gradle.internal.metaobject.BeanDynamicObject.tryGetProperty(BeanDynamicObject.java:171)
org.gradle.internal.metaobject.CompositeDynamicObject.tryGetProperty(CompositeDynamicObject.java:55)
org.gradle.internal.metaobject.AbstractDynamicObject.getProperty(AbstractDynamicObject.java:59)
com.android.build.gradle.internal.api.ApplicationVariantImpl_Decorated.getProperty(null:-1)
org.codehaus.groovy.runtime.callsite.PogoGetPropertySite.getProperty(PogoGetPropertySite.java:49)
org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGetProperty(AbstractCallSite.java:298)
com.google.gms.googleservices.GoogleServicesPlugin.handleVariant(GoogleServicesPlugin.groovy:164)
sun.reflect.NativeMethodAccessorImpl.invoke0(NativeMethodAccessorImpl.java:-2)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke(Method.java:498)
org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:104)
groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:326)
org.gradle.internal.metaobject.BeanDynamicObject$MetaClassAdapter.invokeMethod(BeanDynamicObject.java:479)
org.gradle.internal.metaobject.BeanDynamicObject.tryInvokeMethod(BeanDynamicObject.java:191)
org.gradle.internal.metaobject.ConfigureDelegate.invokeMethod(ConfigureDelegate.java:78)
org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeOnDelegationObjects(ClosureMetaClass.java:398)
org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:338)
org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:68) …
Run Code Online (Sandbox Code Playgroud)