REAndroid / APKEditor

Powerful android apk editor - aapt/aapt2 independent
Apache License 2.0
647 stars 95 forks source link

App crashes after merging APK #4

Closed AntonPripyat closed 1 year ago

AntonPripyat commented 1 year ago

Not all apps work when they are merged. The following apps immediately crashes after merging APK. These apps used to work before XAPK is enforced

I'm using Windows 11 with java version "19.0.1" 2022-10-18

App: https://apkcombo.com/bitlife/com.candywriter.bitlife/download/apk

PS E:\APKEditor> java -jar "E:\APKEditor\APKEditor-1.1.1.jar" m -i "E:\BitLife\xapk" -o "E:\BitLife\xapk.apk"
00.000 I: [MERGE] Merging ...
   Input: E:\BitLife\xapk
 Output: E:\BitLife\xapk.apk
 ----------------------------
00.057 I: [MERGE] Searching apk files ...
00.061 I: [MERGE] Found apk files: 3
00.859 [MERGE] oading: config.armeabi_v7a.apk
00.861 I: [MERGE] Found modules: 3
00.936 I: [MERGE] Merging: com.candywriter.bitlife
00.942 I: [MERGE] Added [com.candywriter.bitlife] classes.dex -> classes.dex
00.942 I: [MERGE] Added [com.candywriter.bitlife] classes2.dex -> classes2.dex
00.942 I: [MERGE] Added [com.candywriter.bitlife] classes3.dex -> classes3.dex
00.943 I: [MERGE] Added [com.candywriter.bitlife] classes4.dex -> classes4.dex
00.943 I: [MERGE] Added [com.candywriter.bitlife] classes5.dex -> classes5.dex
00.943 I: [MERGE] Added [com.candywriter.bitlife] classes6.dex -> classes6.dex
00.943 I: [MERGE] Added [com.candywriter.bitlife] classes7.dex -> classes7.dex
00.943 I: [MERGE] Merging resource table: com.candywriter.bitlife
02.780 [MERGE] 4/notification_bg_normal.9.png
02.781 I: [MERGE] Merging: config.arm64_v8a
02.794 [MERGE] v8a/libFirebaseCppApp-9_4_0.so
02.795 I: [MERGE] Merging: config.armeabi_v7a
02.808 [MERGE] ed: lib/armeabi-v7a/libmain.so
02.855 I: [MERGE] Sanitizing manifest ...
02.857 I: [MERGE] Removed: extractNativeLibs
02.858 I: [MERGE] Removed: isSplitRequired
02.859 I: [MERGE] Removed: <meta-data android:name(@0x01010003)="com.android.vending.splits.required" android:value(@0x01010024)="true"/>
02.859 I: [MERGE] Removed: <meta-data android:name(@0x01010003)="com.android.stamp.source" android:value(@0x01010024)="https://play.google.com/store"/>
02.859 I: [MERGE] Removed: <meta-data android:name(@0x01010003)="com.android.stamp.type" android:value(@0x01010024)="STAMP_TYPE_DISTRIBUTION_APK"/>
02.861 I: [MERGE] Removed from table: res/xml/splits0.xml
02.867 I: [MERGE] Removed: <meta-data android:name(@0x01010003)="com.android.vending.splits" android:value(@0x01010025)="[REFERENCE] 2132082698"/>
02.867 I: [MERGE] Removed: <meta-data android:name(@0x01010003)="com.android.vending.derived.apk.id" android:value(@0x01010024)="[INT_DEC] 2"/>
02.868 I: [MERGE] Writing apk ...
17.181 [MERGE] Writing: total=334349632 bytes : -messaging-platform.properties
17.407 I: [MERGE] Zip align ...
17.658 I: [MERGE] Saved to: E:\BitLife\xapk.apk
17.658 I: [MERGE] Done

App: https://apkcombo.com/dead-ahead-zombie-warfare/com.mobirate.DeadAheadTactics/

PS E:\APKEditor> java -jar "E:\APKEditor\APKEditor-1.1.1.jar" m -i "E:\Dead Ahead Zombie Warfare\xapk" -o "E:\Dead Ahead Zombie Warfare\xapk.apk"
00.000 I: [MERGE] Merging ...
   Input: E:\Dead Ahead Zombie Warfare\xapk
 Output: E:\Dead Ahead Zombie Warfare\xapk.apk
 ----------------------------
00.021 I: [MERGE] Searching apk files ...
00.024 I: [MERGE] Found apk files: 2
00.041 [MERGE] oading: config.armeabi_v7a.apk
00.043 I: [MERGE] Found modules: 2
00.074 I: [MERGE] Merging: com.mobirate.DeadAheadTactics
00.080 I: [MERGE] Added [com.mobirate.DeadAheadTactics] classes.dex -> classes.dex
00.080 I: [MERGE] Added [com.mobirate.DeadAheadTactics] classes2.dex -> classes2.dex
00.080 I: [MERGE] Added [com.mobirate.DeadAheadTactics] classes3.dex -> classes3.dex
00.081 I: [MERGE] Added [com.mobirate.DeadAheadTactics] classes4.dex -> classes4.dex
00.081 I: [MERGE] Merging resource table: com.mobirate.DeadAheadTactics
01.902 [MERGE] 4/notification_bg_normal.9.png
01.903 I: [MERGE] Merging: config.armeabi_v7a
01.913 [MERGE]  lib/armeabi-v7a/libsqlite3.so
01.957 I: [MERGE] Sanitizing manifest ...
01.958 I: [MERGE] Removed: extractNativeLibs
01.959 I: [MERGE] Removed: isSplitRequired
01.959 I: [MERGE] Removed: <meta-data android:name(@0x01010003)="com.android.vending.splits.required" android:value(@0x01010024)="true"/>
01.960 I: [MERGE] Removed: <meta-data android:name(@0x01010003)="com.android.stamp.source" android:value(@0x01010024)="https://play.google.com/store"/>
01.960 I: [MERGE] Removed: <meta-data android:name(@0x01010003)="com.android.stamp.type" android:value(@0x01010024)="STAMP_TYPE_DISTRIBUTION_APK"/>
01.960 I: [MERGE] Removed from table: res/xml/splits0.xml
01.966 I: [MERGE] Removed: <meta-data android:name(@0x01010003)="com.android.vending.splits" android:value(@0x01010025)="[REFERENCE] 2132082696"/>
01.966 I: [MERGE] Removed: <meta-data android:name(@0x01010003)="com.android.vending.derived.apk.id" android:value(@0x01010024)="[INT_DEC] 2"/>
01.967 I: [MERGE] Writing apk ...
12.371 [MERGE] Writing: total=190488826 bytes : -messaging-platform.properties
12.536 I: [MERGE] Zip align ...
12.786 I: [MERGE] Saved to: E:\Dead Ahead Zombie Warfare\xapk.apk
12.786 I: [MERGE] Done
Kirlif commented 1 year ago

Let's launch the merged app to get: java.lang.RuntimeException: Unable to instantiate application com.pairip.application.Application package com.candywriter.bitlife: com.pairip.SignatureCheck$SignatureTamperedException: Apk signature is invalid.

The merging process for this bundle is perfect. You will have to break some protection to make it functional.

This issue has nothing to do with this project.

AntonPripyat commented 1 year ago

Oh, I didn't know it, let's see if I can bypass it.

I try to re-compile this merged APK using apktool but there is an error with xml. It happens without making changes to it

[18:35:43] Using Apktool 2.7.0
[18:35:43] Smaling smali folder into classes.dex...
[18:36:24] Smaling smali_classes2 folder into classes2.dex...
[18:37:02] Smaling smali_classes3 folder into classes3.dex...
[18:37:41] Smaling smali_classes4 folder into classes4.dex...
[18:38:08] Building resources...
[18:38:17] D:\Portable Apps\APK Tool GUI\Decompiled APK\xapk\res\values\xmls.xml:3: error: invalid value for type 'xml'. Expected a reference.
[18:38:17] D:\Portable Apps\APK Tool GUI\Decompiled APK\xapk\res\values\xmls.xml: error: file failed to compile.
[18:38:17] brut.androlib.AndrolibException: brut.common.BrutException: could not exec (exit code = 1): [C:\Users\Gaming\AppData\Local\Temp\brut_util_Jar_108838152226493056663636610440191230131.tmp, compile, --dir, D:\Portable Apps\APK Tool GUI\Decompiled APK\xapk\res, --legacy, -o, D:\Portable Apps\APK Tool GUI\Decompiled APK\xapk\build\resources.zip]
[18:38:17] Compiling failed

The xmls.xml contaned this

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <item type="xml" name="splits0">false</item>
</resources>
Quicker666 commented 1 year ago

The merge isnt the issue, this game you need to bypass the license check from pairipcore

AntonPripyat commented 1 year ago

The merge isnt the issue, this game you need to bypass the license check from pairipcore

Yes, I know but there is an issue with re-compiling

REAndroid commented 1 year ago
<?xml version="1.0" encoding="utf-8"?>
<resources>
    <item type="xml" name="splits0">false</item>
</resources>

Fixed with this commit