涉及注释库的AndroidX的Play-Services-Maps和Android Studio 3.3问题

时间:2019-01-16 15:23:31

标签: android gradle google-play-services androidx android-studio-3.3

我最近将我的项目更新为从Android Studio 3.3进行构建,其中涉及进行以下更改(在Android Studio启动时提示)

build.gradle依赖项:

classpath 'com.android.tools.build:gradle:3.3.0'

渐变包装:

distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip

当尝试使用Google Maps进行同步时,这在功能模块中产生了许多错误。我使用的是play-services-maps版本16.0.0:

implementation "com.google.android.gms:play-services-maps:16.0.0"

尝试同步gradle时出现的错误是:

ERROR: Unable to resolve dependency for ':featureModule@flavorDebugFeature/compileClasspath': Could not resolve androidx.annotation:annotation:1.0.0.

ERROR: Unable to resolve dependency for ':featureModule@flavorDebugFeature/compileClasspath': Could not resolve androidx.annotation:annotation:1.0.1.

ERROR: Unable to resolve dependency for ':featureModule@flavorDebugFeature/compileClasspath': Could not resolve androidx.core:core:1.0.0.

ERROR: Unable to resolve dependency for ':featureModule@flavorDebugFeature/compileClasspath': Could not resolve androidx.core:core:1.0.1.

此模块中所有可能的风味变体组合都会重复此操作。

值得指出的是,该项目几个月前已迁移到androidX,并且运行良好。

错误的解决方法是将以下内容添加到该失败模块的gradle依赖项中:

implementation "androidx.annotation:annotation:1.0.1"
implementation "androidx.core:core:1.0.1"

然后,该应用可以正常编译并在设备上运行。完善。在我们尝试在项目上发布之前在CI构建中运行lint之前,我们遇到了麻烦,出现了错误消息:

Execution failed for task ':featureModule:lintFlavorDebug'.
> Lint infrastructure error
  Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
... [several lines omitted for brevity]
 Caused by: java.lang.IllegalStateException: Expected task 'processFlavorDebugAndroidTestJavaRes' output files to contain exactly one file, however, it contains no files.
    at org.gradle.api.internal.file.AbstractFileCollection.getSingleFile(AbstractFileCollection.java:65)
    at com.android.build.gradle.internal.variant.BaseVariantData.getJavaResourcesForUnitTesting(BaseVariantData.java:700)
    at com.android.build.gradle.internal.ide.ModelBuilder.createAndroidArtifact(ModelBuilder.java:992)
    at com.android.build.gradle.internal.ide.ModelBuilder.createVariant(ModelBuilder.java:617)
    at com.android.build.gradle.internal.ide.ModelBuilder.buildAndroidProject(ModelBuilder.java:399)
    at com.android.build.gradle.internal.ide.ModelBuilder.buildAll(ModelBuilder.java:212)
    at com.android.tools.lint.gradle.LintGradleExecution.createAndroidProject(LintGradleExecution.java:352)
    at com.android.tools.lint.gradle.LintGradleExecution.analyze(LintGradleExecution.java:85)
    ... 59 more

如果我们删除2个新的依赖项(加上Google Maps,这似乎是对核心库和注释库的要求的原因),则此问题将消失。

我已经在此处和通过Google进行了一些搜索,其他人也看到了Expected task 'processFlavorDebugAndroidTestJavaRes' output files to contain exactly one file, however, it contains no files.异常,他们的解决方案是确保基本的build.gradle文件具有baseFeature true标志在defaultConfig中,它已经存在于我的项目中。

在解决这个问题方面,我现在无所适从。

0 个答案:

没有答案