Tencent / tinker

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

生成patch时发生异常 #605

Closed soarhe closed 7 years ago

soarhe commented 7 years ago

异常类型:编译new apk成功以后,生成patch异常

手机型号:Nexus 6

手机系统版本:7.1.1

tinker版本:1.8.0

gradle版本:2.2.2

是否使用热更新SDK: 未使用

系统:mac

堆栈/日志: Final normal zip resource: resources_out.zip, size=20238183, md5=5c3a7a0b2bc2e3511d446bc43543d485 Final 7zip resource: resources_out_7z.zip, size=20238122, md5=1e2a98a21469a99b7ba9b931152b4da0

java.lang.NullPointerException at java.util.Hashtable.put(Hashtable.java:459) at com.tencent.tinker.build.info.PatchInfoGen.gen(PatchInfoGen.java:68) at com.tencent.tinker.build.info.PatchInfo.gen(PatchInfo.java:40) at com.tencent.tinker.build.patch.Runner.tinkerPatch(Runner.java:70) 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:84) 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:75) at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.doExecute(AnnotationProcessingTaskFactory.java:228) at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:221) at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:210) at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:621) at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:604) at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:80) at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:61) at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:46) at org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExecuter.execute(PostExecutionAnalysisTaskExecuter.java:35) at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:66) at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58) at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.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:53) at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43) at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:203) at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:185) at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.processTask(AbstractTaskPlanExecutor.java:66) at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.run(AbstractTaskPlanExecutor.java:50) at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:54) at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:40) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:748)

shwenzhang commented 7 years ago

看代码不太应该为空,你把编译的日志也给一下。

soarhe commented 7 years ago

-----------------------Tinker patch begin----------------------- configuration: oldApk:/Users/admin/GitProject/4.0.0/Android/tinker/bakApk/flavor/dev/soarhe-dev-debug.apk newApk:/Users/admin/GitProject/4.0.0/Android/soarhe/build/outputs/apk/soarhe-dev-debug.apk outputFolder:/Users/admin/GitProject/4.0.0/Android/soarhe/build/outputs/tinkerPatch/dev/debug isIgnoreWarning:false isProtectedApp:false 7-ZipPath:/Users/admin/.gradle/caches/modules-2/files-2.1/com.tencent.mm/SevenZip/1.1.10/cc390e6c704b74496d9ba0e9b46d2cf8a2a96b84/SevenZip-1.1.10-osx-x86_64.exe useSignAPk:true package meta fields: filed name:patchMessage, filed value:tinker is sample to use filed name:platform, filed value:all filed name:patchVersion, filed value:null dex configs: dexMode: jar dexPattern:assets/secondary-dex-..jar dexPattern:classes..dex dex loader:soarhe.AppApplication dex loader:com.tencent.tinker.loader. dex loader:tinker.sample.android.app.BaseBuildInfo dex loader:tinker.sample.android.app.SampleApplication lib configs: libPattern:lib/./..so resource configs: resPattern:AndroidManifest.xml resPattern:resources.arsc resPattern:res/. resPattern:assets/. resIgnore change:assets/sample_meta.txt largeModSize:100kb useApplyResource:true

Analyze old and new apk files: old apk: soarhe-dev-debug.apk, size=42317242, md5=c93156015dcc2eabc02aee9dde69de13 new apk: soarhe-dev-debug.apk, size=42562633, md5=e1b6b75ecc73e65db3b28009c869312c

UnZipping apk to /Users/admin/GitProject/4.0.0/Android/soarhe/build/outputs/tinkerPatch/dev/debug/soarhe-dev-debug-old UnZipping apk to /Users/admin/GitProject/4.0.0/Android/soarhe/build/outputs/tinkerPatch/dev/debug/soarhe-dev-debug-new found modify resource: AndroidManifest.xml, but it is AndroidManifest.xml, just ignore! Check for loader classes in dex: classes.dex Check for loader classes in dex: classes2.dex Check for loader classes in dex: classes3.dex

以下是各种FoundModify,例如: Found modify resource: res/drawable-xxhdpi-v4/xxx.png

ApkParser: resources.arsc is not equal, reason: file size is changed Found large modify resource: resources.arsc size:1150360

Gen classes.dex patch file:/Users/admin/GitProject/4.0.0/Android/soarhe/build/outputs/tinkerPatch/dev/debug/tinker_result/classes.dex, size:413638, md5:239a016ab4250f8dbda40c1fc227faa6 Verifying if patched new dex is logically the same as original new dex: soarhe-dev-debug-new/classes.dex ...

Gen classes.dex for dalvik full dex file:/Users/admin/GitProject/4.0.0/Android/soarhe/build/outputs/tinkerPatch/dev/debug/tempPatchedDexes/classes.dex, size:7485336, md5:b898524d8e9f1d02b8a384cd3bc0cb80

Gen classes2.dex patch file:/Users/admin/GitProject/4.0.0/Android/soarhe/build/outputs/tinkerPatch/dev/debug/tinker_result/classes2.dex, size:501185, md5:c50716f92ee1ffe8899dcab11358a6f2 Verifying if patched new dex is logically the same as original new dex: soarhe-dev-debug-new/classes2.dex ...

Gen classes2.dex for dalvik full dex file:/Users/admin/GitProject/4.0.0/Android/soarhe/build/outputs/tinkerPatch/dev/debug/tempPatchedDexes/classes2.dex, size:7738212, md5:44b6da8ea20cb106dc5802683cce9953

Gen classes3.dex patch file:/Users/admin/GitProject/4.0.0/Android/soarhe/build/outputs/tinkerPatch/dev/debug/tinker_result/classes3.dex, size:471747, md5:cb612ea5041a035065335a2a8499d88d Verifying if patched new dex is logically the same as original new dex: soarhe-dev-debug-new/classes3.dex ...

Gen classes3.dex for dalvik full dex file:/Users/admin/GitProject/4.0.0/Android/soarhe/build/outputs/tinkerPatch/dev/debug/tempPatchedDexes/classes3.dex, size:4693216, md5:b462e9942cbb0ad0a348838d0d42b04f DexDecoder:write meta file data: classes.dex,,b898524d8e9f1d02b8a384cd3bc0cb80,b898524d8e9f1d02b8a384cd3bc0cb80,239a016ab4250f8dbda40c1fc227faa6,1927384426,3960533068,jar DexDecoder:write meta file data: classes2.dex,,44b6da8ea20cb106dc5802683cce9953,44b6da8ea20cb106dc5802683cce9953,c50716f92ee1ffe8899dcab11358a6f2,260000770,3089334983,jar DexDecoder:write meta file data: classes3.dex,,b462e9942cbb0ad0a348838d0d42b04f,b462e9942cbb0ad0a348838d0d42b04f,cb612ea5041a035065335a2a8499d88d,2428158891,3877389369,jar

Warning:Class Moved. Some classes are just moved from one dex to another. This behavior may leads to unnecessary enlargement of patch file. you should try to check them: 以下是具体的类移动,例如: {classDesc:类名; from:classes2.dex;to classes3.dex}

Add test install result dex: /Users/admin/GitProject/4.0.0/Android/soarhe/build/outputs/tinkerPatch/dev/debug/tinker_result/test.dex, size:584 DexDecoder:write test dex meta file data: test.dex,,56900442eb5b7e1de45449d0685e6e00,56900442eb5b7e1de45449d0685e6e00,0,0,0,jar Add Test resource file: assets/only_use_to_test_tinker_resource.txt

以下是一楼贴的堆栈

shwenzhang commented 7 years ago

image 需要填值

soarhe commented 7 years ago

问题已解决,感谢。