Tencent / tinker

Tinker is a hot-fix solution library for Android, it supports dex, library and resources update without reinstall apk.
Other
17.18k stars 3.33k forks source link

android.enableAapt2和keepDexApply build异常 #811

Closed super-hu closed 6 years ago

super-hu commented 6 years ago

异常类型:编译异常

tinker版本:1.9.6

gradle版本:3.0.1

是否使用热更新SDK: 无

系统:windows

问题一: 打开 keepDexApply = true,buildToolsVersion '28.0.0-rc1' ,执行tinkerPatchDebug发生异常,是还不支持28的吗,回归27后正常。

堆栈/日志:
Warning:ignoreWarning is false, but we found some loader class has been changed in new primary dex. Such these changes will not take effect!! related classes: {Lcom/tencent/tinker/loader/hotplug/ActivityStubManager;,Lcom/tencent/tinker/loader/hotplug/interceptor/HandlerMessageInterceptor$CallbackWrapper;}
java.lang.RuntimeException: com.tencent.tinker.build.util.TinkerPatchException: some loader class has been changed in new primary dex. Such these changes will not take effect!! related classes: {Lcom/tencent/tinker/loader/hotplug/ActivityStubManager;,Lcom/tencent/tinker/loader/hotplug/interceptor/HandlerMessageInterceptor$CallbackWrapper;}
    at com.tencent.tinker.build.decoder.ApkDecoder$ApkFilesVisitor.visitFile(ApkDecoder.java:179)
    at com.tencent.tinker.build.decoder.ApkDecoder$ApkFilesVisitor.visitFile(ApkDecoder.java:138)
    at java.nio.file.Files.walkFileTree(Files.java:2670)
    at java.nio.file.Files.walkFileTree(Files.java:2742)
    at com.tencent.tinker.build.decoder.ApkDecoder.patch(ApkDecoder.java:113)
    at com.tencent.tinker.build.patch.Runner.tinkerPatch(Runner.java:65)
    at com.tencent.tinker.build.patch.Runner.run(Runner.java:48)
    at com.tencent.tinker.build.patch.Runner.gradleRun(Runner.java:41)
    at com.tencent.tinker.build.patch.Runner$gradleRun.call(Unknown Source)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)
    at com.tencent.tinker.build.gradle.task.TinkerPatchSchemaTask.tinkerPatch(TinkerPatchSchemaTask.groovy:86)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)
    at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.doExecute(DefaultTaskClassInfoStore.java:141)
    at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:134)
    at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:121)
    at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:731)
    at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:705)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.run(ExecuteActionsTaskExecuter.java:122)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:197)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:107)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:111)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:92)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:70)
    at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:63)
    at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54)
    at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
    at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:88)
    at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:52)
    at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
    at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54)
    at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
    at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.run(DefaultTaskGraphExecuter.java:248)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:197)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:107)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:241)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:230)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.processTask(DefaultTaskPlanExecutor.java:124)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.access$200(DefaultTaskPlanExecutor.java:80)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:105)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:99)
    at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.execute(DefaultTaskExecutionPlan.java:625)
    at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.executeWithTask(DefaultTaskExecutionPlan.java:580)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.run(DefaultTaskPlanExecutor.java:99)
    at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
    at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
    at java.lang.Thread.run(Thread.java:748)
Caused by: com.tencent.tinker.build.util.TinkerPatchException: some loader class has been changed in new primary dex. Such these changes will not take effect!! related classes: {Lcom/tencent/tinker/loader/hotplug/ActivityStubManager;,Lcom/tencent/tinker/loader/hotplug/interceptor/HandlerMessageInterceptor$CallbackWrapper;}
    at com.tencent.tinker.build.util.ExcludedClassModifiedChecker.checkIfExcludedClassWasModifiedInNewDex(ExcludedClassModifiedChecker.java:204)
    at com.tencent.tinker.build.decoder.DexDiffDecoder.patch(DexDiffDecoder.java:136)
    at com.tencent.tinker.build.decoder.UniqueDexDiffDecoder.patch(UniqueDexDiffDecoder.java:39)
    at com.tencent.tinker.build.decoder.ApkDecoder$ApkFilesVisitor.visitFile(ApkDecoder.java:176)
    ... 59 more

问题二: 打开android.enableAapt2 = true,正常的打包可以,开启buildWithTinker后,异常

:app:tinkerProcessDebugResourceId
we build app apk with apply resource mapping file F:\third\tinker\tinker-sample-android\app\build\bakApk/app-debug-0411-11-32-09-R.txt
tinker gen resource public.xml in build/intermediates/tinker_intermediates/public.xml
tinker gen resource idx.xml in build/intermediates/tinker_intermediates/idx.xml

:app:processDebugResources
F:\third\tinker\tinker-sample-android\app\build\intermediates\res\merged\debug\values\ids.xml: error: uncompiled XML file passed as argument. Must be compiled first into .flat file..
error: failed parsing overlays.

Failed to execute aapt
com.android.ide.common.process.ProcessException: Failed to execute aapt
...
Caused by: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
    at com.android.builder.png.AaptProcess$NotifierProcessOutput.handleOutput(AaptProcess.java:463)
    at com.android.builder.png.AaptProcess$NotifierProcessOutput.err(AaptProcess.java:415)
    at com.android.builder.png.AaptProcess$ProcessOutputFacade.err(AaptProcess.java:332)
    at com.android.utils.GrabProcessOutput$1.run(GrabProcessOutput.java:104)
pzhangleo commented 6 years ago

我也遇到问题2了

Chgocn commented 6 years ago

gradle版本3.1.2同样出现问题二,将gradle版本降级到版本3.0.0就可以了

PassQ commented 6 years ago

请问问题2该如何解决,感觉应该不是gradle版本的问题,我另一个demo Gradle版本一样,没有遇到问题2

tys282000 commented 6 years ago

aapt2的问题是tinker还不支持aapt2,升级到1.9.9版本就可以了。

thymleaf commented 6 years ago

gradle 3.0.0, tinker 1.9.9,同样出现AAPT2 error