美文网首页
AndroidStudio 3.2+ AndroidX 爬坑

AndroidStudio 3.2+ AndroidX 爬坑

作者: 失吾爱后而心死 | 来源:发表于2019-11-11 23:23 被阅读0次

升级的as,然后一个半年没有维护的项目就打不开了,各种报错,决定通过逐个击破的方式解决这个问题。

第一条

更新gradle插件版本,和Gradle版本,按照as的提示进行。

第二条

一个警告,是说这个varinat.getJavaCompile() API将会在2019年后移除。

WARNING: API 'variant.getJavaCompile()' is obsolete and has been replaced with 'variant.getJavaCompileProvider()'.
It will be removed at the end of 2019.

当然还有另一个问题

Android resource compilation failed
G:\as320work\jfsmart\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:3795: error: duplicate value for resource 'attr/layout_anchorGravity' with config ''.
G:\as320work\jfsmart\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:3795: error: resource previously defined here.

猜测这个也是由于api等内容不对造成的,看了一下,项目中引用的一个依赖包targetSdkVersion 仍然用的是22,决定改成28试试

仍然不行, 更新一下项目中引用的其他依赖版本,就是报警告的那些,尤其是v7,v4,design包,这几个比较重要。

漫长的编译,下载一些东西。。。

第三条

然鹅,之前将gradle插件版本更新到了

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

提示当前工具不能支持,让我升级as,去官网看了一些,果然as3.4版本已经出来了

本着不作不死的精神,决定更到最新(短期小版本更新改动应该不大)

漫长下载....

第四条

然鹅,还是那个will remove end of 2019, 当前as,gradle插件版本,gradle版本,api也是最新的,继续看报错详情

org.gradle.execution.MultipleBuildFailures: Build completed with 1 failures.
    at org.gradle.initialization.DefaultGradleLauncher$ExecuteTasks.run(DefaultGradleLauncher.java:386)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:301)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:293)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:175)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:91)
    at org.gradle.internal.operations.DelegatingBuildOperationExecutor.run(DelegatingBuildOperationExecutor.java:31)
    at org.gradle.tooling.internal.provider.runner.BuildModelActionRunner.run(BuildModelActionRunner.java:54)
    at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35)
    at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35)
    at org.gradle.launcher.daemon.server.exec.ExecuteBuild.doBuild(ExecuteBuild.java:67)
    at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
    at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:104)

Caused by: org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:mergeDebugResources'.
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:95)
    at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:91)
    at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:57)
    at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:119)
    at org.gradle.api.internal.tasks.execution.ResolvePreviousStateExecuter.execute(ResolvePreviousStateExecuter.java:43)
    at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:93)
    at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker$1.execute(DefaultPlanExecutor.java:134)
    at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker$1.execute(DefaultPlanExecutor.java:129)
    at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.execute(DefaultPlanExecutor.java:202)
    at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.executeNextNode(DefaultPlanExecutor.java:193)
    at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.run(DefaultPlanExecutor.java:129)
    ... 6 more
Caused by: com.android.ide.common.workers.WorkerExecutorException: 1 exception was raised by workers:
com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource compilation failed
D:\androidSDK\.gradle\caches\transforms-2\files-2.1\b5660f198583de4443198b08ec4402b9\res\values\values.xml:19:5-827: AAPT: error: duplicate value for resource 'attr/layout_anchorGravity' with config ''.
    
D:\androidSDK\.gradle\caches\transforms-2\files-2.1\b5660f198583de4443198b08ec4402b9\res\values\values.xml:19:5-827: AAPT: error: resource previously defined here.

感觉像是在说sdk有什么问题,打开sdk manager,瞅瞅吧,貌似也没啥大问题,除了AndroidQ的相关内容没下载,android pd的内容相关都有下载,难不成把报错这个删除了试试看?

然而并没有卵用

求助google,又说values下文件报错的,那就排查一下。然而并没有发现任何的不规范写法

第五条

尝试添加:android.enableAapt2=false(这句遭废弃了,删除没用)

依然没有什么卵用,查看sync下的日志,发现:

WARNING: The following project options are deprecated and have been removed:
android.enableAapt2
This property has no effect, AAPT2 is now always used.
Affected Modules: SmallVideoLib, app

引入的一个SmallVideoLib 视频录制插件报错,决定删除,毕竟这个功能不用了,开始删除。。

没用

第六条

开始搞成Android X,我还就不信了

Android resource compilation failed
G:\as320work\jfsmart\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:3749: error: duplicate value for resource 'attr/layout_anchorGravity' with config ''.
G:\as320work\jfsmart\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:3749: error: resource previously defined here.
G:\as320work\jfsmart\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml: error: file failed to compile.

第六条

删除了不用的依赖,升级为androidX ,一切问题貌似都解决了

果然,第三方的东西要谨慎使用

build : complete successfully

相关文章

网友评论

      本文标题:AndroidStudio 3.2+ AndroidX 爬坑

      本文链接:https://www.haomeiwen.com/subject/mygxictx.html