google / archive-patcher

Automatically exported from code.google.com/p/archive-patcher
Apache License 2.0
528 stars 73 forks source link

java.lang.NullPointerException: Inflater has been closed #160

Open aravindakv opened 4 years ago

aravindakv commented 4 years ago

I am usinng archive-patcher on Android. I am getting below exception while generating patch, please help me.

2020-07-24 16:19:56.145 920-920/? E/AndroidRuntime: FATAL EXCEPTION: main Process: com.example.apkpatcher, PID: 920 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.apkpatcher/com.example.apkpatcher.MainActivity}:java.lang.NullPointerException: Inflater has been closed at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3623) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3775) at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83) at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135) at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2261) at android.os.Handler.dispatchMessage(Handler.java:107) at android.os.Looper.loop(Looper.java:237) at android.app.ActivityThread.main(ActivityThread.java:8107) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:496) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1100)

Caused by: java.lang.NullPointerException: Inflater has been closed at java.util.zip.Inflater.ensureOpen(Inflater.java:416) at java.util.zip.Inflater.reset(Inflater.java:370) at com.google.archivepatcher.generator.DefaultDeflateCompressionDiviner.divineDeflateParameters(DefaultDeflateCompressionDiviner.java:173) at com.google.archivepatcher.generator.DefaultDeflateCompressionDiviner.divineDeflateParameters(DefaultDeflateCompressionDiviner.java:114) at com.google.archivepatcher.generator.PreDiffExecutor.generatePreDiffPlan(PreDiffExecutor.java:216) at com.google.archivepatcher.generator.PreDiffExecutor.prepareForDiffing(PreDiffExecutor.java:157) at com.google.archivepatcher.generator.FileByFileV1DeltaGenerator.generateDelta(FileByFileV1DeltaGenerator.java:81) at com.example.apkpatcher.DeltaCounter.generatePatch(DeltaCounter.java:97) at com.example.apkpatcher.MainActivity.onCreate(MainActivity.java:37) at android.app.Activity.performCreate(Activity.java:7957) at android.app.Activity.performCreate(Activity.java:7946) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1307) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3598) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3775)  at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)  at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)  at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2261)  at android.os.Handler.dispatchMessage(Handler.java:107)  at android.os.Looper.loop(Looper.java:237)  at android.app.ActivityThread.main(ActivityThread.java:8107)  at java.lang.reflect.Method.invoke(Native Method)  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:496)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1100)  2020-07-24 16:21:01.356 1578-1578/? E/AndroidRuntime: FATAL EXCEPTION: main Process: com.example.apkpatcher, PID: 1578 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.apkpatcher/com.example.apkpatcher.MainActivity}: java.lang.NullPointerException: Inflater has been closed at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3623) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3775) at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83) at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135) at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2261) at android.os.Handler.dispatchMessage(Handler.java:107) at android.os.Looper.loop(Looper.java:237) at android.app.ActivityThread.main(ActivityThread.java:8107) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:496) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1100) Caused by: java.lang.NullPointerException: Inflater has been closed at java.util.zip.Inflater.ensureOpen(Inflater.java:416) at java.util.zip.Inflater.reset(Inflater.java:370) at com.google.archivepatcher.generator.DefaultDeflateCompressionDiviner.divineDeflateParameters(DefaultDeflateCompressionDiviner.java:173) at com.google.archivepatcher.generator.DefaultDeflateCompressionDiviner.divineDeflateParameters(DefaultDeflateCompressionDiviner.java:114) at com.google.archivepatcher.generator.PreDiffExecutor.generatePreDiffPlan(PreDiffExecutor.java:216) at com.google.archivepatcher.generator.PreDiffExecutor.prepareForDiffing(PreDiffExecutor.java:157) at com.google.archivepatcher.generator.FileByFileV1DeltaGenerator.generateDelta(FileByFileV1DeltaGenerator.java:81) at com.example.apkpatcher.DeltaCounter.generatePatch(DeltaCounter.java:97)

andrewhayden commented 4 years ago

Hi there,

I can't speak for the team at this point, but archive-patcher was not designed to generate patches on Android. Apply, yes - generate, no. The zip implementation on Android is not the same as the Zip implementation elsewhere, and there are some minor differences that can, from time to time, result in behavioral differences. I believe this one is known, and has to do with the way Android resets (or does not reset) the internal flags of Inflater objects when trying to reset the Inflater for further use.

If possible, it's generally better to generate patches on another platform. Applying them on Android absolutely should work, but generating them there may not.

andrewhayden commented 4 years ago

For the record, this is a dupe of issue #138 , and a fix was made on a branch that is currently idle. It might be possible to fix in master as well, but like I said, I do not speak for the team.

aravindakv commented 4 years ago

Thanks Andrew,

I am able to generate and apply now with the help of #138 https://github.com/google/archive-patcher/issues/138, But the size of diff file on windows is 11KB and size on Android is 3.8MB, It would be great, if the same can be applied on master as well.

Thanks and Regards Aravinda K V, Bengaluru.

On Fri, Jul 24, 2020 at 6:42 PM Andrew Hayden notifications@github.com wrote:

For the record, this is a dupe of issue #138 https://github.com/google/archive-patcher/issues/138 , and a fix was made on a branch that is currently idle. It might be possible to fix in master as well, but like I said, I do not speak for the team.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/google/archive-patcher/issues/160#issuecomment-663531545, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAXGQR4OTQKZ7HKQ45TPRTDR5GCFVANCNFSM4PGUOKBQ .