Giter VIP home page Giter VIP logo

apkeditor's Introduction

👈 Click arrows to expand/collapse details on this page

APKEditor

Powerful android apk resources editor

This tool uses ARSCLib to edit any apk resources and has six main features

java -jar APKEditor.jar -h
$ java -jar APKEditor.jar -h
APKEditor - x.x.x
Using: ARSCLib-x.x.x
https://github.com/REAndroid/APKEditor
Android binary resource files editor
Usage: 
 java -jar APKEditor.jar <command> <args>
 commands: 
  1)  d | decode     -   Decodes android resources binary to readable json
  2)  b | build      -   Builds android binary from json
  3)  m | merge      -   Merges split apk files from directory or XAPK, APKM, APKS ...
  4)  x | refactor   -   Refactors obfuscated resource names
  5)  p | protect    -   Protects/Obfuscates apk resource
  6)  info           -   Prints information of apk
 run with <command> -h to get detailed help about each command
 

1- Decompile

  • Decompiles resources of apk to human readable json string.
  • Decompiles resources of apk to XML source code (for un-obfuscated apk only). Use -t xml
java -jar APKEditor.jar d -i path/to/your-file.apk
$ java -jar APKEditor.jar d -i test.apk -o test_json
00.000 I: [DECOMPILE] Decompiling ...
 Input: test.apk
Output: test_json
 ---------------------------- 
00.036 I: [DECOMPILE] Loading ...
00.129 I: [DECOMPILE] Decompiling to json ...
30.093 I: [DECOMPILE] Done

2- Build

Builds back to apk from decompiled json/XML files

java -jar APKEditor.jar b -i path/to/decompiled-directory
$ java -jar APKEditor.jar b -i test_json -o test_edited.apk

00.000 I: [BUILD] Building ...
 Input: test_json/base
Output: test_edited.apk
 ---------------------------- 
00.048 I: [BUILD] Scanning directory ...
00.247 I: [BUILD] Writing apk...
22.032 [BUILD] Writing: method=STORED total=284921526 bytes : resources.arsc  
25.009 I: [BUILD] Zip align ...
27.101 I: [BUILD] Saved to: test_edited.apk
30.217 I: [BUILD] Done

3- Merge

Merges multiple splitted apk files (directory, xapk, apkm, apks ...) to standalone apk

java -jar APKEditor.jar m -i path/to/input
$ java -jar APKEditor.jar m -i apk_files
00.049 I: [MERGE] Merging ...
  Input: apk_files
Output: apk_files_merged.apk
---------------------------- 
00.050 I: [MERGE] Searching apk files ...
00.060 I: [MERGE] Found apk files: 3           
00.192 I: [MERGE] Found modules: 3
00.302 I: [MERGE] Merging: base
00.307 I: [MERGE] Added [base] classes.dex -> classes.dex
00.308 I: [MERGE] Merging resource table: base
01.302 I: [MERGE] Merging: config.xxhdpi-1
01.304 I: [MERGE] Merging resource table: config.xxhdpi-1
01.386 [MERGE] tum_ic_visibility_white_24.png
01.386 I: [MERGE] Merging: config.arm64_v8a-1
01.390 [MERGE] : lib/arm64-v8a/libnativeai.so

01.475 I: [MERGE] Sanitizing manifest ...
01.478 I: [MERGE] Removed: extractNativeLibs
01.480 I: [MERGE] Removed: isSplitRequired

01.480 I: [MERGE] Writing apk...
03.686 [MERGE] Writing: total=47693672 bytes : resources.arsc
03.729 I: [MERGE] Zip align ... 
04.611 I: [MERGE] Saved to: apk_files_merged.apk
04.700 I: [MERGE] Done

apkmerger

4- Refactor

Refactors obfuscated resource entry names

java -jar APKEditor.jar x -i path/to/input.apk
$ java -jar APKEditor.jar x -i input.apk
00.000 I: [REFACTOR] Refactoring ...
  Input: input.apk
Output: input_refactored.apk
---------------------------- 
00.017 I: [REFACTOR] Loading apk: input.apk
00.952 I: [REFACTOR] Renamed entries: 5888
00.954 I: [REFACTOR] Writing apk ...
03.268 [REFACTOR] Writing: total=47589184 bytes : resources.arsc              
03.350 I: [REFACTOR] Zip align ...
03.504 I: [REFACTOR] Saved to: input_refactored.apk
03.504 I: [REFACTOR] Done

5- Protect

Protects apk resources against almost all known decompile/modify tools.

java -jar APKEditor.jar p -i path/to/input.apk
00.026 I: [PROTECT] Protecting ...
  Input: test.apk
Output: test_protected.apk
---------------------------- 
00.027 I: [PROTECT] Loading apk file ...
00.052 I: [PROTECT] Protecting files ..
00.454 I: [PROTECT] Protecting resource table ..
00.474 I: [PROTECT] Writing apk ...
02.264 [PROTECT] Writing: total=47654392 bytes : resources.arsc              
02.346 I: [PROTECT] Zip align ...
02.451 I: [PROTECT] Saved to: test_protected.apk
02.451 I: [PROTECT] Done

6- Info (⭐NEW⭐)

Prints/dumps from basic up to detailed information of apk.

java -jar APKEditor.jar info -v -resources -i input.apk
Package name=com.mypackage id=0x7f
 type string id=1 entryCount=1
   resource 0x7f010000 string/app_name
     () My Application
     (-de) Meine Bewerbung
     (-ru-rRU) Мое заявление
 type mipmap id=2 entryCount=1
   resource 0x7f020000 mipmap/ic_launcher_round
     () res/mipmap/ic_launcher_round.png
 type drawable id=3 entryCount=1
   resource 0x7f030000 drawable/ic_launcher
     () #006400

Build executable jar

./gradlew fatJar
# NB: Due to my lazyness , the dependency ARSCLib.jar is pre-built and placed under APKEditor/libs/ARSCLib.jar or you can build yourself and replace it.
git clone https://github.com/REAndroid/APKEditor
cd APKEditor
./gradlew fatJar
# Executable jar will be placed ./build/libs/APKEditor-x.x.x.jar

Downloads

Contribute

  • Everyone is so welcome in this project, if you have some code improvements please make a pull request
  • Please share your ideas / thoughts in discussions
  • Please create issue you faced while using this tool along with your apk
Contact

apkeditor's People

Contributors

kirlif avatar reandroid avatar sv99 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

apkeditor's Issues

A problem with resource id

The resource id is negative number in resources-ids.json.

There are new features in an APP, and its resources.arsc has two package names, their package names are com.miui.mediaeditor[package id is 127] and com.miui.mediaeditor.dynamicfeature_beauty[package id is 128].
If the apk resource is decompiled into a file in xml format, then the resource id of "com.miui.mediaeditor.dynamicfeature_beauty" is correct; if the apk resource is decompiled into a file in json format, there is a problem with the id of the resources-ids.json, which is a negative number, while It is no problem to calculate the id number in the resources-arsc.json.
For example, the id of "beauty_i18n" in resources-arsc.json: 0x80 * 0x1000000 + 0x7 * 0x10000 + 0 = 0x80070000, which is consistent with the result in the public.xml.

new features in AndroidManifest.xml
<meta-data android:name="com.android.dynamic.apk.fused.modules" android:value="base,dynamicfeature_beauty" />

Snap1
Snap2
Snap3

APP is here:app

-keep-meta gives an error

when trying to run
java -jar APKEditor-1.2.1.jar m -keep-meta -i com.kwai.bulldog/
i get the message - Unknown option: -keep-meta

can anyone give a hint?

Repacking error (xml mode)

Describe the bug
When simply repacking the attached apk, it no longer runs

To Reproduce
Steps to reproduce the behavior:

  1. Used version: APKEditor - 1.2.8, ARSCLib - 1.2.3
  2. Operating system: WSL Ubuntu 22.04
  3. Command: java -jar apkeditor.jar d -i app.apk and java -jar apkeditor.jar b -i app_decompiled_xml

Log/Stacktrace

FATAL EXCEPTION: main
Process: com.starbucks.mobilecard, PID: 4198
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.starbucks.mobilecard/o.Xe}: android.view.InflateException: Binary XML file line #22 in com.starbucks.mobilecard:layout/layout_0x7f0d00d1: Binary XML file line #22 in com.starbucks.mobilecard:layout/layout_0x7f0d00d1: Error inflating class o.lr
	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3644)
	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3781)
	at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:101)
	at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:138)
	at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2306)
	at android.os.Handler.dispatchMessage(Handler.java:106)
	at android.os.Looper.loopOnce(Looper.java:201)
	at android.os.Looper.loop(Looper.java:288)
	at android.app.ActivityThread.main(ActivityThread.java:7918)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)
Caused by: android.view.InflateException: Binary XML file line #22 in com.starbucks.mobilecard:layout/layout_0x7f0d00d1: Binary XML file line #22 in com.starbucks.mobilecard:layout/layout_0x7f0d00d1: Error inflating class o.lr
Caused by: android.view.InflateException: Binary XML file line #22 in com.starbucks.mobilecard:layout/layout_0x7f0d00d1: Error inflating class o.lr
Caused by: java.lang.reflect.InvocationTargetException
	at java.lang.reflect.Constructor.newInstance0(Native Method)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:343)
	at android.view.LayoutInflater.createView(LayoutInflater.java:858)
	at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:1010)
	at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:965)
	at android.view.LayoutInflater.rInflate(LayoutInflater.java:1127)
	at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1088)
	at android.view.LayoutInflater.rInflate(LayoutInflater.java:1130)
	at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1088)
	at android.view.LayoutInflater.inflate(LayoutInflater.java:686)
	at android.view.LayoutInflater.inflate(LayoutInflater.java:538)
	at android.view.LayoutInflater.inflate(LayoutInflater.java:485)
	at o.Context.asBinder(:775)
	at o.ComponentCallbacks2.setContentView(:197)
	at o.Xe.setContentView(:79)
	at o.Xe.onCreate(:47)
	at android.app.Activity.performCreate(Activity.java:8342)
	at android.app.Activity.performCreate(Activity.java:8321)
	at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1417)
	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3625)
	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3781)
	at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:101)
	at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:138)
	at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2306)
	at android.os.Handler.dispatchMessage(Handler.java:106)
	at android.os.Looper.loopOnce(Looper.java:201)
	at android.os.Looper.loop(Looper.java:288)
	at android.app.ActivityThread.main(ActivityThread.java:7918)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)
Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x7f040163
	at android.content.res.ResourcesImpl.getValue(ResourcesImpl.java:230)
	at android.content.res.Resources.getValue(Resources.java:1437)
	at o.IllegalMonitorStateException.asBinder(:309)
	at o.IllegalMonitorStateException.read(:256)
	at o.IllegalMonitorStateException.RemoteActionCompatParcelizer(:236)
	at o.ClassNotFoundException.getColorStateList(:558)
	at o.Resources.onTransact(:48)
	at o.mB.read(:60)
	at com.google.android.material.navigation.NavigationBarView.<init>(:263)
	at o.lr.<init>(:108)
	at o.lr.<init>(:103)
	at o.lr.<init>(:98)
	... 32 more

Used apk file
https://drive.google.com/file/d/1SPZ1_HEYUfajk-aOlIBspaX3WtxkRrQp/view?usp=sharing

APKEditor can't find layout component by resource id

Describe the bug
I modified the Smali code using APKEditor and rebuilt it. However, the built apk says that there is a problem with the resource or that the related resource cannot be found. I didn't touch any of the resources prior to the build, only smali code. However, when decompiling with jadx, the resource seems to exist.
(It's not a smali problem though, it works if you apply the same changes in apktool)

To Reproduce
Steps to reproduce the behavior:

  1. Used version 1.2.5
  2. Operating system macOS 13.4.1
  3. Command java -jar ~/APKEditor-1.2.5.jar d -i kakaotalk-10-2-8.apk -o kakaotalk

Log/Stacktrace

07-10 21:24:31.662 21956 21956 E AndroidRuntime: java.lang.NullPointerException: Missing required view with ID: com.kakao.talk.contenttab:id/back
07-10 21:24:31.662 21956 21956 E AndroidRuntime: at com.kakao.talk.contenttab.kakaoview.presentation.screen.main.a.onCreateView(KvMainFragment.kt:21)
07-10 21:24:31.662 21956 21956 E AndroidRuntime: at androidx.fragment.app.Fragment.performCreateView(Fragment.java:4)
07-10 21:24:31.662 21956 21956 E AndroidRuntime: at androidx.fragment.app.i0.e(FragmentStateManager.java:30)
07-10 21:24:31.662 21956 21956 E AndroidRuntime: at androidx.fragment.app.i0.j(FragmentStateManager.java:29)
07-10 21:24:31.662 21956 21956 E AndroidRuntime: at androidx.fragment.app.FragmentManager.E(FragmentManager.java:126)
07-10 21:24:31.662 21956 21956 E AndroidRuntime: at androidx.fragment.app.FragmentManager.l0(FragmentManager.java:9)
07-10 21:24:31.662 21956 21956 E AndroidRuntime: at androidx.fragment.app.FragmentManager.D(FragmentManager.java:5)
07-10 21:24:31.662 21956 21956 E AndroidRuntime: at androidx.fragment.app.a.i(BackStackRecord.java:2)

Used apk file
Attach/share your apk

Additional context
At this time, a simple change in Smali is just a bypass of forgery detection.

parse error

I am getting this error when running with the following commands

"java -jar APKEditor-1.1.7-UPDATE-3.jar d -i file.apk"

image

Can't protect large APK

Describe the bug
APKEditor fail to protect large APK file. I'm using Java 19.0.2 on Windows 11

To Reproduce
Steps to reproduce the behavior:

  1. java -jar APKEditor.jar p -i (apk)

Log/Stacktrace

00.027 I: [PROTECT] Loading apk ...

Unexpected error:
arraycopy: source index -1826102770 out of bounds for byte[102400]
java.lang.ArrayIndexOutOfBoundsException: arraycopy: source index -1826102770 out of bounds for byte[102400]
        at java.base/java.lang.System.arraycopy(Native Method)
        at com.reandroid.common.FileChannelInputStream.readBuffer(FileChannelInputStream.java:99)
        at com.reandroid.common.FileChannelInputStream.read(FileChannelInputStream.java:77)
        at com.reandroid.archive2.block.ZipHeader.readBasic(ZipHeader.java:45)
        at com.reandroid.archive2.block.ZipHeader.readBytes(ZipHeader.java:33)
        at com.reandroid.archive2.block.LocalFileHeader.read(LocalFileHeader.java:92)
        at com.reandroid.archive2.model.LocalFileDirectory.visitLocalFile(LocalFileDirectory.java:55)
        at com.reandroid.archive2.model.LocalFileDirectory.visit(LocalFileDirectory.java:41)
        at com.reandroid.archive2.Archive.<init>(Archive.java:45)
        at com.reandroid.archive2.Archive.<init>(Archive.java:63)
        at com.reandroid.apk.ApkModule.loadApkFile(ApkModule.java:1126)
        at com.reandroid.apkeditor.protect.Protector.run(Protector.java:48)
        at com.reandroid.apkeditor.protect.Protector.execute(Protector.java:158)
        at com.reandroid.apkeditor.Main.execute(Main.java:80)
        at com.reandroid.apkeditor.Main.main(Main.java:41)

Used apk file
https://mega.nz/file/HMYGDJqR#6gb1g-scoQI_j3m7Tg9GzfMsOI9kHHlVj2M4HVSxqXs

[Question] Compression ratio

Is there any planned control over the compression ratio of the apk? For example, the initial APK weighing 108 MB after simply recompiling resources begins to weigh 9 MB more (117 MB).

APK rebuild error

Hi.
I am new to using this project. I tried to decompile an apk and then build exactly the same folder again.

decompile apk:

java -jar .\APKEditor-1.2.1.jar d -i '.\example.apk' -t xml -o .\decompile
00.000 I: [DECOMPILE] Decompiling ...
   Input: .\example.apk
 Output: .\decompile
 Type: xml
 ----------------------------
00.022 I: [DECOMPILE] Loading ...
00.200 I: [DECOMPILE] Initializing android framework ...
00.202 I: [DECOMPILE] Loading android framework for version: 27
00.253 I: [DECOMPILE] Initialized framework: android-27 (8.1.0)
00.254 I: [DECOMPILE] Decompiling to XML ...
00.270 I: [DECOMPILE] [SANITIZE]: Sanitizing paths ...
00.271 I: [DECOMPILE] [SANITIZE]: DONE = 752
00.272 I: [DECOMPILE] Decoding ...
00.273 I: [DECOMPILE] Validating resource names ...
00.337 I: [DECOMPILE] Decoding: AndroidManifest.xml
00.427 I: [DECOMPILE] Decoding public.xml: 0-comexample
00.447 I: [DECOMPILE] Decoding resource files ...
02.283 [DECOMPILE] Decoding: res\xml\global_tracker.xml
02.294 I: [DECOMPILE] Decoding values: 0-com.example
02.387 I: [DECOMPILE] Extracting root files
02.483 I: [DECOMPILE] Saved to: .\decompile
02.483 I: [DECOMPILE] Done

I tried to recompile some apk files, Most of them were success, But this specific apk failed with this error:

java -jar .\APKEditor-1.2.1.jar b -i .\decompile -o .\recompile\example.recompile.apk
00.000 I: [BUILD] Building ...
  Input: .\decompile 
Output: .\recompile\example.recompile.apk
----------------------------
00.022 I: [BUILD] Scanning XML directory ...
00.043 I: [BUILD] Scanning: decompile 
00.051 [BUILD] Searching public.xml: .\decompile 
00.081 I: [BUILD] Loading string pool ...
00.538 [BUILD] 3518 building pool: values-zu
00.654 I: [BUILD] Missing attribute: 'compileSdkVersion', skip loading frameworks
00.654 I: [BUILD] Set main package id from manifest: @drawable/icon
00.657 I: [BUILD] Main package id initialized: id = 0x7f, from: @drawable/icon
00.657 I: [BUILD] Encoding attrs ...
00.669 [BUILD] Encoding: values\attrs.xml
00.714 I: [BUILD] Encoding values ...
00.742 [BUILD] Encoding: values\styles.xml
ERROR:
Local entry not found: type=style, name=Theme.Light

The row that includes this style:
<style name="CustomDialog" parent="@android:style/Theme.Light">

Note that the apk name and package id changed in the result.

1.1.9

Its seem execute protect apk now looks very too clean, is it do it any protect on the resources like old version ? Not very sure where the part resources protect

Protected apk failed to intalled

Describe the bug
Protected apk failed to install. I've signed the zip with latest apk signer and apktool m and applied protected after.

To Reproduce
Steps to reproduce the behavior:

  1. Used version 'V1.2.4'
  2. Operating system 'windows'
  3. Command 'java -jar APKEditor.jar p -i path/to/input.apk' and 'java -jar APKEditor.jar p -skip-manifest -i path/to/input.apk'

Log/Stacktrace

00.044 I: [PROTECT] Loading apk ...
00.269 I: [PROTECT] Confusing AndroidManifest ...
00.295 I: [PROTECT] Protecting files ..
00.296 I: [PROTECT] Protecting files ..
00.324 I: [PROTECT]   Ignored: res/font/roboto_medium_numbers.ttf
00.329 I: [PROTECT] Protecting resource table ..
00.329 I: [PROTECT] METHOD-1 Protecting resource table ..
00.335 I: [PROTECT] METHOD-2 Protecting resource table ..
00.351 I: [PROTECT] Writing apk ...
00.365 I: [PROTECT] Buffering compress changed files ...
00.474 I: [PROTECT] Zip align ...
00.496 I: [PROTECT] Writing files: 1795
00.685 I: [PROTECT] Writing signature block ...
00.698 I: [PROTECT] Saved to: <name>

Used apk file
Attach/share your apk

Additional context
Android version: 11
RealmeUI

App crashes after merging APK

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

Repacking error (xml mode) #2

It may be related to #60 and will close with it.

Describe the bug
After a simple repacking, part of the functionality of the application does not work. Namely, in the registration window, when selecting a date from the datepicker, a crash occurs. I am not sure that you will be able to check it, because there you need a phone number and receive an sms to it.

To Reproduce
Steps to reproduce the behavior:

  1. Used version: APKEditor - 1.2.8, ARSCLib - 1.2.3
  2. Operating system: WSL Ubuntu 22.04
  3. Command: java -jar apkeditor.jar d -i app.apk and java -jar apkeditor.jar b -i app_decompiled_xml

Log/Stacktrace

input-mask-android:
input-mask-android:                     WARNING! Your text field is not configured for the MaskedTextChangedListener!
input-mask-android:                     For more information please refer to
input-mask-android:
input-mask-android:                     InputMask vs. android:inputType and IndexOutOfBoundsException
input-mask-android:                     https://github.com/RedMadRobot/input-mask-android#inputmask-vs-androidinputtype-and-indexoutofboundsexception
input-mask-android:
FATAL EXCEPTION: main
Process: com.icemobile.lenta.prod, PID: 27468
java.lang.IndexOutOfBoundsException: setSpan (10 ... 10) ends beyond length 6
       at android.text.SpannableStringBuilder.checkRange(SpannableStringBuilder.java:1326)
       at android.text.SpannableStringBuilder.setSpan(SpannableStringBuilder.java:685)
       at android.text.SpannableStringBuilder.setSpan(SpannableStringBuilder.java:677)
       at androidx.emoji2.text.n.setSpan(SpannableBuilder.java:4)
       at android.text.Selection.setSelection(Selection.java:94)
       at android.text.Selection.setSelection(Selection.java:78)
       at android.text.Selection.setSelection(Selection.java:153)
       at android.widget.EditText.setSelection(EditText.java:136)
       at com.a65apps.lentamain.ui.f.e(InputEx.kt:4)
       at com.a65apps.lentamain.ui.f.f(InputEx.kt:1)
       at com.a65apps.registration.update.user.g$b.a(UpdateUserFragment.kt:3)
       at com.a65apps.registration.update.user.g$b.d(UpdateUserFragment.kt:15)
       at com.a65apps.registration.update.user.g$k.a(UpdateUserFragment.kt:1)
       at com.a65apps.registration.update.user.g$k.invoke(UpdateUserFragment.kt:1)
       at com.a65apps.registration.update.user.g$m.d(Unknown Source:2)
       at androidx.lifecycle.LiveData.d(LiveData.java:6)
       at androidx.lifecycle.LiveData.e(LiveData.java:8)
       at androidx.lifecycle.LiveData.q(LiveData.java:4)
       at androidx.lifecycle.c0.q(MutableLiveData.java:1)
       at androidx.lifecycle.LiveData$a.run(LiveData.java:5)
       at android.os.Handler.handleCallback(Handler.java:942)
       at android.os.Handler.dispatchMessage(Handler.java:99)
       at android.os.Looper.loopOnce(Looper.java:201)
       at android.os.Looper.loop(Looper.java:288)
       at android.app.ActivityThread.main(ActivityThread.java:7918)
       at java.lang.reflect.Method.invoke(Native Method)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)
C_LOG]AGConnectCrashHandler: exception catch:'java.lang.IndexOutOfBoundsException: setSpan (10 ... 10) ends beyond length 6' from thread main

Used apk file
Attach/share your apk

Building back from decompilation to apk fails

1.APKEditor version: 1.2.0
2.apk file: Settings.apk

3.run: java -jar APKEditor.jar d -i Settings.apk

00.000 I: [DECOMPILE] Decompiling ...
   Input: Settings.apk
 Output: Settings_decompile_null
 Type: json
 Split: false
 ---------------------------- 
00.020 I: [DECOMPILE] Loading ...
00.579 I: [DECOMPILE] Initializing android framework ...
00.579 I: [DECOMPILE] Loading android framework for version: 33
00.614 I: [DECOMPILE] Initialized framework: android-33
00.614 I: [DECOMPILE] Decompiling to JSON ...
00.659 I: [DECOMPILE] [SANITIZE]: Sanitizing paths ...
00.663 [DECOMPILE] [SANITIZE]: REN: 'META-INF/external__kotlinx.coroutines__android_common__kotlinx_cor                                                                                                       00.663 [DECOMPILE] [SANITIZE]: REN: 'META-INF/packages__apps__MiuiSettingsLib__android_common__MiuiSettingsLib.kotlin_module' -> 'META-INF/alias_45341996'
00.667 I: [DECOMPILE] [SANITIZE]: DONE = 10572
03.648 I: [DECOMPILE] Dumping signatures ...
03.648 I: [DECOMPILE] Saved to: Settings_decompile_null
03.648 I: [DECOMPILE] Done

do not make any changes.

4.run: java -jar APKEditor.jar b -i Settings_decompile_null

00.000 I: [BUILD] Building ...
   Input: Settings_decompile_null/base
 Output: Settings_decompile_null_out.apk
 ---------------------------- 
00.019 I: [BUILD] Scanning JSON directory ...
00.103 I: [BUILD] Restoring file path ...
00.104 I: [BUILD] Building resources table: resources.arsc

Unexpected error:
java.io.IOException: resources.arsc: JSONObject["style"] not found.
java.lang.IllegalArgumentException: java.io.IOException: resources.arsc: JSONObject["style"] not found.
	at com.reandroid.apk.ApkModule.getTableBlock(ApkModule.java:566)
	at com.reandroid.apk.ApkModule.getTableBlock(ApkModule.java:573)
	at com.reandroid.apk.ApkModule.listResFiles(ApkModule.java:398)
	at com.reandroid.apk.ApkModule.listResFiles(ApkModule.java:394)
	at com.reandroid.apk.PathMap.restore(PathMap.java:37)
	at com.reandroid.apk.ApkJsonEncoder.restorePathMap(ApkJsonEncoder.java:82)
	at com.reandroid.apk.ApkJsonEncoder.scanDirectory(ApkJsonEncoder.java:48)
	at com.reandroid.apkeditor.compile.Builder.buildJson(Builder.java:69)
	at com.reandroid.apkeditor.compile.Builder.run(Builder.java:49)
	at com.reandroid.apkeditor.compile.Builder.execute(Builder.java:159)
	at com.reandroid.apkeditor.Main.execute(Main.java:65)
	at com.reandroid.apkeditor.Main.main(Main.java:38)
Caused by: java.io.IOException: resources.arsc: JSONObject["style"] not found.
	at com.reandroid.apk.SingleJsonTableInputSource.getTableBlock(SingleJsonTableInputSource.java:68)
	at com.reandroid.apk.ApkModule.loadTableBlock(ApkModule.java:652)
	at com.reandroid.apk.ApkModule.getTableBlock(ApkModule.java:560)
	... 11 more

Program Crashes while decompiling to xml on Android

Describe the bug
A clear and concise description of what the bug is.
I have been using since version 1.1.5 so far it was perfect , updating to 1.3.2 didn't go well.
Trying to decompile any APK since 1.3.+ causes the program to crash (Android APK).
Since Android 8, restrictions were introduced to block access to hidden API (com Android.org.kxml2.io.KxmlParser) which APK Editor makes use of.
I changed the package name which prevents the crashes but gives this result
#76

To Reproduce
Steps to reproduce the behavior:

  1. Used version '1.3.1 and 1.3.2'
  2. Operating system ' Android 12 API 31'
  3. Command 'Main.main(new String[] {"d","-i",paths,"-o",outputdir});'

Log/Stacktrace
Dropping screenshot as the mobile IDE (code assist on Playstore)I use doesn't support copy logs as plain text (sorry for the stress :( )
Screenshot_20231002-052359
Screenshot_20231001-234629
Screenshot_20231001-232518

Used apk file
Attach/share your apk
Crashes for all APK files

Additional context
Add any other context about the problem here.

Apk decompilation error (xml type)

hi!

I use the latest version - 1.2.1.
previously I used the json type for decompilation, now I switched to xml and immediately caught an error where it was not on json.
if you try to disassemble the attached apk using the json type, then everything happens correctly.
but if you try to parse it in xml, the utility crashes with an error at the moment of decompilation

here is the decompilation log in xml:

java -jar .\bin\apkeditor.jar d -t xml -i .\app.apk
00.000 I: [DECOMPILE] Decompiling ...
   Input: .\app.apk
 Output: .\app_decompile_xml
 Type: xml
 ----------------------------
00.019 I: [DECOMPILE] Loading ...
00.244 I: [DECOMPILE] Initializing android framework ...
00.244 I: [DECOMPILE] Loading android framework for version: 31
00.299 I: [DECOMPILE] Initialized framework: android-31
00.299 I: [DECOMPILE] Decompiling to XML ...
00.322 I: [DECOMPILE] [SANITIZE]: Sanitizing paths ...
00.327 I: [DECOMPILE] [SANITIZE]: DONE = 1703
00.328 I: [DECOMPILE] Decoding ...
00.328 I: [DECOMPILE] Validating resource names ...
00.397 I: [DECOMPILE] Decoding: AndroidManifest.xml
00.452 I: [DECOMPILE] Decoding public.xml: 0-com.perm.kate
00.477 I: [DECOMPILE] Decoding resource files ...
06.384 [DECOMPILE] Decoding: res\layout\sticker_preview.xml
06.390 I: [DECOMPILE] Decoding values: 0-com.perm.kate

ERROR:
Cannot invoke "String.indexOf(int)" because "value" is null
java.io.IOException: Cannot invoke "String.indexOf(int)" because "value" is null
        at com.reandroid.apkeditor.decompile.Decompiler.run(Decompiler.java:72)
        at com.reandroid.apkeditor.decompile.Decompiler.execute(Decompiler.java:131)
        at com.reandroid.apkeditor.Main.execute(Main.java:61)
        at com.reandroid.apkeditor.Main.main(Main.java:38)
Caused by: java.lang.NullPointerException: Cannot invoke "String.indexOf(int)" because "value" is null
        at com.android.org.kxml2.io.KXmlSerializer.attribute(KXmlSerializer.java:432)
        at com.reandroid.apk.xmldecoder.EntryWriterSerializer.attribute(EntryWriterSerializer.java:52)
        at com.reandroid.apk.xmldecoder.EntryWriterSerializer.attribute(EntryWriterSerializer.java:23)
        at com.reandroid.apk.xmldecoder.BagDecoderAttr.decode(BagDecoderAttr.java:58)
        at com.reandroid.apk.xmldecoder.BagDecoderAttr.decode(BagDecoderAttr.java:27)
        at com.reandroid.apk.xmldecoder.DecoderResTableEntryMap.decode(DecoderResTableEntryMap.java:40)
        at com.reandroid.apk.xmldecoder.XMLEntryDecoder.decode(XMLEntryDecoder.java:61)
        at com.reandroid.apk.xmldecoder.XMLEntryDecoder.decode(XMLEntryDecoder.java:92)
        at com.reandroid.apk.xmldecoder.XMLEntryDecoderSerializer.decode(XMLEntryDecoderSerializer.java:86)
        at com.reandroid.apk.xmldecoder.XMLEntryDecoderSerializer.decodeUniqueConfigs(XMLEntryDecoderSerializer.java:73)
        at com.reandroid.apk.xmldecoder.XMLEntryDecoderSerializer.decode(XMLEntryDecoderSerializer.java:51)
        at com.reandroid.apk.ApkModuleXmlDecoder.decodeValues(ApkModuleXmlDecoder.java:296)
        at com.reandroid.apk.ApkModuleXmlDecoder.decodeValues(ApkModuleXmlDecoder.java:292)
        at com.reandroid.apk.ApkModuleXmlDecoder.decodeValues(ApkModuleXmlDecoder.java:279)
        at com.reandroid.apk.ApkModuleXmlDecoder.onDecodeTo(ApkModuleXmlDecoder.java:100)
        at com.reandroid.apk.ApkDecoder.decodeTo(ApkDecoder.java:37)
        at com.reandroid.apkeditor.decompile.Decompiler.run(Decompiler.java:70)
        ... 3 more

and here is the decompilation in json:

java -jar .\bin\apkeditor.jar d -t json -i .\app.apk
00.000 I: [DECOMPILE] Decompiling ...
   Input: .\app.apk
 Output: .\app_decompile_json
 Type: json
 Split: false
 ---------------------------- 
00.022 I: [DECOMPILE] Loading ...
00.222 I: [DECOMPILE] Initializing android framework ...
00.223 I: [DECOMPILE] Loading android framework for version: 31
00.272 I: [DECOMPILE] Initialized framework: android-31
00.272 I: [DECOMPILE] Decompiling to JSON ...
00.289 I: [DECOMPILE] [SANITIZE]: Sanitizing paths ...
00.291 I: [DECOMPILE] [SANITIZE]: DONE = 1703
01.958 I: [DECOMPILE] Dumping signatures ...
01.961 I: [DECOMPILE] Saved to: .\app_decompile_json
01.961 I: [DECOMPILE] Done

APK: https://drive.google.com/file/d/1Uc6-C3WrHgNDp_6DsfR3oyOy17gsq0NC/view?usp=sharing

Failed to Open Dex Files from Base.apk due to Out-of-Order Field Index for Annotation

Describe the bug
I just changed 'const/4 v1, 0x0' to 'const/4 v1, 0x1' and rebuilt the smali, but it still cannot be opened.
I tested DECOMPILE and BUILD without making any modifications, and it worked fine.

To Reproduce
Steps to reproduce the behavior:

  1. Used version
  • APKEditor - 1.2.4
  • Using: ARSCLib-1.2.0
  1. Operating system 'android 13'
  2. Command
  • java -jar APKEditor/APKEditor-1.2.4.jar d -i xxx.apk -f
  • java -jar APKEditor/APKEditor-1.2.4.jar b -i xxx

Log/Stacktrace

E  FATAL EXCEPTION: main
   Process: com.scb.phone, PID: 923
   java.lang.RuntimeException: Unable to instantiate application com.scb.phone.AndroidApplication package com.scb.phone: java.lang.ClassNotFoundException: Didn't find class "com.scb.phone.AndroidApplication" on path: DexPathList[[zip file "/data/app/~~-s0Q_Suv5SsIx0VboDh4Ow==/com.scb.phone-vsBiUTmjtF7yMjlw_LO87Q==/base.apk"],nativeLibraryDirectories=[/data/app/~~-s0Q_Suv5SsIx0VboDh4Ow==/com.scb.phone-vsBiUTmjtF7yMjlw_LO87Q==/lib/arm64, /data/app/~~-s0Q_Suv5SsIx0VboDh4Ow==/com.scb.phone-vsBiUTmjtF7yMjlw_LO87Q==/base.apk!/lib/arm64-v8a, /system/lib64, /system_ext/lib64]]
   	at android.app.LoadedApk.makeApplicationInner(LoadedApk.java:1573)
   	at android.app.LoadedApk.makeApplicationInner(LoadedApk.java:1502)
   	at android.app.ActivityThread.handleBindApplication(ActivityThread.java:7543)
   	at android.app.ActivityThread.-$$Nest$mhandleBindApplication(Unknown Source:0)
   	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2400)
   	at android.os.Handler.dispatchMessage(Handler.java:106)
   	at android.os.Looper.loopOnce(Looper.java:226)
   	at android.os.Looper.loop(Looper.java:313)
   	at android.app.ActivityThread.main(ActivityThread.java:8747)
   	at java.lang.reflect.Method.invoke(Native Method)
   	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571)
   	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1067)
   Caused by: java.lang.ClassNotFoundException: Didn't find class "com.scb.phone.AndroidApplication" on path: DexPathList[[zip file "/data/app/~~-s0Q_Suv5SsIx0VboDh4Ow==/com.scb.phone-vsBiUTmjtF7yMjlw_LO87Q==/base.apk"],nativeLibraryDirectories=[/data/app/~~-s0Q_Suv5SsIx0VboDh4Ow==/com.scb.phone-vsBiUTmjtF7yMjlw_LO87Q==/lib/arm64, /data/app/~~-s0Q_Suv5SsIx0VboDh4Ow==/com.scb.phone-vsBiUTmjtF7yMjlw_LO87Q==/base.apk!/lib/arm64-v8a, /system/lib64, /system_ext/lib64]]
   	at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:259)
   	at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
   	at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
   	at android.app.AppComponentFactory.instantiateApplication(AppComponentFactory.java:76)
   	at android.app.Instrumentation.newApplication(Instrumentation.java:1232)
   	at android.app.LoadedApk.makeApplicationInner(LoadedApk.java:1565)
   	at android.app.LoadedApk.makeApplicationInner(LoadedApk.java:1502) 
   	at android.app.ActivityThread.handleBindApplication(ActivityThread.java:7543) 
   	at android.app.ActivityThread.-$$Nest$mhandleBindApplication(Unknown Source:0) 
   	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2400) 
   	at android.os.Handler.dispatchMessage(Handler.java:106) 
   	at android.os.Looper.loopOnce(Looper.java:226) 
   	at android.os.Looper.loop(Looper.java:313) 
   	at android.app.ActivityThread.main(ActivityThread.java:8747) 
   	at java.lang.reflect.Method.invoke(Native Method) 
   	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571) 
   	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1067) 
   	Suppressed: java.io.IOException: Failed to open dex files from /data/app/~~-s0Q_Suv5SsIx0VboDh4Ow==/com.scb.phone-vsBiUTmjtF7yMjlw_LO87Q==/base.apk because: Failure to verify dex file '/data/app/~~-s0Q_Suv5SsIx0VboDh4Ow==/com.scb.phone-vsBiUTmjtF7yMjlw_LO87Q==/base.apk': Out-of-order field_idx for annotation: 63f then 63c
   		at dalvik.system.DexFile.openDexFileNative(Native Method)
   		at dalvik.system.DexFile.openDexFile(DexFile.java:371)
   		at dalvik.system.DexFile.<init>(DexFile.java:113)
   		at dalvik.system.DexFile.<init>(DexFile.java:86)
   		at dalvik.system.DexPathList.loadDexFile(DexPathList.java:438)
   		at dalvik.system.DexPathList.makeDexElements(DexPathList.java:397)
   		at dalvik.system.DexPathList.<init>(DexPathList.java:166)
   		at dalvik.system.BaseDexClassLoader.<init>(BaseDexClassLoader.java:160)
   		at dalvik.system.BaseDexClassLoader.<init>(BaseDexClassLoader.java:130)
   		at dalvik.system.PathClassLoader.<init>(PathClassLoader.java:146)
   		at com.android.internal.os.ClassLoaderFactory.createClassLoader(ClassLoaderFactory.java:93)
   		at com.android.internal.os.ClassLoaderFactory.createClassLoader(ClassLoaderFactory.java:134)
   		at android.app.ApplicationLoaders.getClassLoader(ApplicationLoaders.java:126)
   		at android.app.ApplicationLoaders.getClassLoaderWithSharedLibraries(ApplicationLoaders.java:61)
   		at android.app.LoadedApk.createOrUpdateClassLoaderLocked(LoadedApk.java:1059)
   		at android.app.LoadedApk.getClassLoader(LoadedApk.java:1151)
   		at android.app.LoadedApk.getResources(LoadedApk.java:1475)
   		at android.app.ContextImpl.createAppContext(ContextImpl.java:3264)
   		at android.app.ContextImpl.createAppContext(ContextImpl.java:3256)
E  App crashed on incremental package com.scb.phone which is 100% loaded.

logcat.txt

Used apk file
Attach/share your apk
https://apkcombo.com/th/scb-easy/com.scb.phone/download/apk
Additional context
Add any other context about the problem here.

Failed to install the apk after merged

While trying to install the app via adb

01.778 I: [MERGE] Writing apk ...
05.458 [MERGE] Writing: total=35638710 bytes : play-services-tasks.properties
05.558 I: [MERGE] Zip align ...
05.639 I: [MERGE] Saved to: out.apk
05.640 I: [MERGE] Done

└─$ adb install out.apk
Performing Streamed Install
adb: failed to install out.apk: 
Failure [INSTALL_PARSE_FAILED_NO_CERTIFICATES: Failed collecting certificates for /data/app/vmdl808427888.tmp/base.apk: 
Failed to collect certificates from /data/app/vmdl808427888.tmp/base.apk: Attempt to get length of null array]

Using protect feature breaks the apk file!

Hi,

I used this tool to decompile my own old application that removed from play store because my older account was suspended :(

The hacking tools are works great like ( decomile , rebuild , refactor ) but when i use new feature Protect APK file it build the apk but you can't use it like a normal apk file I think that because the protected file is not signed and there is no way to sign it with any signer tool.

The apk file that i used is this Kurdish Keyboard file I created my own keyboard for my language and layouts I used open source project AnySoftKeyboard

Whitespace collapsing, Backslash escaping, Quoted escaping not implemented

Describe the bug
Whitespace collapsing, Backslash escaping, Quoted escaping not implemented in APKEditor
See this link for how it should behave: https://developer.android.com/guide/topics/resources/string-resource#escaping_quotes

Build examples:

Input string given to APKEditor to build Expected text displayed in app Current text displayed in app
Whitespace collapsed Whitespace collapsed
Whitespace    collapsed
Unicode: \u00A9 Unicode: © Unicode: \u00A9
"That's cool!" That's cool! "That's cool!"
That's cool! Compile Error That's cool!
Backslash (\\) (\) Backslash (\) () Backslash (\\) (\)

Decompile example: (❌ incorrect, ✅ correct)

String in android studio Expected string extracted from apk (mutiple correct examples) String extracted from apk by APKEditor String Extracted from apk by apktool
"Tab ulated" Tab\u0009ulated
Tab\tulated
"Tab ulated"
Tab ulated Tab\u0009ulated
\'single\' \'single\'
"'single'"
"\'single\'"
'single' "'single'"
"\"double\"" "\"double\""
\"double\"
"double" \"double\"
(\\) (\) (\\) () (\) () (\\) ()
\u00A9 \u00A9
&copy;
©
© ©

To Reproduce
Steps to reproduce the behavior:

  1. Used version '1.2.6'
  2. Operating system 'Linux 5.15.90.1-microsoft-standard-WSL2 x86_64 GNU/Linux'
  3. Commands java -jar APKEditor-1.2.6.jar d -dex -i app-debug.apk and java -jar APKEditor-1.2.6.jar b -i app-debug_decompile_xml -o packed.apk

See the original strings used to build the apk at strings (original)
See the expected output in image strings (original) built with android studio
I also attached the output produced by apktool for reference strings (apktool decompilation output). The decompiled strings created by apktool are different than strings (original) but that is not a problem, as both XML files produce the same apk as seen on images strings (original) built with android studio and strings (apktool decompilation output) built with android studio

Problem 1: The output produced by unpacking with APKEditor is not compatible with the format that other tools such as android studio expect.

To reproduce unpack the attached apk. The unpacked strings.xml is not compatible with the format that Android Studio accepts. When trying to build my example apk I get an error due to the unescaped single quotes '. After escaping the single quotes with a backslash \ and building the app I get the output seen in the attached image strings (APKEditor decompilation output manually edited to escape single quotes) built with android studio.

Problem 2: The APKEditor packer doesn't recognise backslash \ escape codes and double quoted escapes as its input.

To reproduce unpack the attached apk. Edit the strings.xml to the attached strings (original) then pack/build with APKEditor. The built apk will produce the output shown in the image strings (original) packed with APKEditor with is not correct.

Used apk file
app-debug.apk.zip

Attached XML

strings (original)

    <string name="test_string">Android escape and quotation test
\n"Tab\tulated 1"
\n"Tab	ulated 2"
\nTab\tulated 3
\nTab	ulated 4
\nBackslash (\\) (\)
\nQuestion\?
\n"\"Double\"" \"quotes\"
\n\'Single\' "'quote'" "\'test\'"
\nmail\@example.com
\nUnicode: \u00A9
\n"Whitespace    Preserved"
\nWhitespace    collapsed
\n"Newlines

preserved"
\nNewlines\n\nPreserved
\nNewlines

collapsed
</string>

strings (APKEditor decompilation output)

  <string name="test_string">Android escape and quotation test 
Tab	ulated 1 
Tab	ulated 2 
Tab	ulated 3 
Tab ulated 4 
Backslash (\) () 
Question? 
"Double" "quotes" 
'Single' 'quote' 'test' 
[email protected] 
Unicode: © 
Whitespace    Preserved 
Whitespace collapsed 
Newlines

preserved 
Newlines

Preserved 
Newlines collapsed </string>
</resources>

strings (APKEditor decompilation output manually edited to escape single quotes)

  <string name="test_string">Android escape and quotation test 
Tab	ulated 1 
Tab	ulated 2 
Tab	ulated 3 
Tab ulated 4 
Backslash (\) () 
Question? 
"Double" "quotes" 
\'Single\' \'quote\' \'test\' 
[email protected] 
Unicode: © 
Whitespace    Preserved 
Whitespace collapsed 
Newlines

preserved 
Newlines

Preserved 
Newlines collapsed </string>
</resources>

strings (apktool decompilation output)

    <string name="test_string">"Android escape and quotation test 
Tab\u0009ulated 1 
Tab\u0009ulated 2 
Tab\u0009ulated 3 
Tab ulated 4 
Backslash (\\) () 
Question? 
\"Double\" \"quotes\" 
'Single' 'quote' 'test' 
[email protected] 
Unicode: © 
Whitespace    Preserved 
Whitespace collapsed 
Newlines

preserved 
Newlines

Preserved 
Newlines collapsed "</string>

Attached images

strings (original) built with android studio

image

strings (original) built with APKEditor

image

strings (apktool decompilation output) built with android studio

image

strings (APKEditor decompilation output manually edited to escape single quotes) built with android studio

image

xmlns:app breaks down

Describe the bug
During decompilation, the xmlns:app attribute of the FrameLayout root element turns into xmlns:ru.
Xml from the original apk obtained via JADX:

<?xml version="1.0" encoding="UTF-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/mainContentRoot" android:visibility="invisible" android:layout_width="match_parent" android:layout_height="match_parent">
   <FrameLayout android:id="@+id/mainTabContainer" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_marginBottom="@dimen/bottom_tab_bar_size" />
   <View android:layout_gravity="bottom" android:id="@+id/bottomBarShadow" android:layout_marginBottom="@dimen/bottom_tab_bar_size" style="@style/Widget.WB.BottomBarShadow" />
   <androidx.compose.ui.platform.ComposeView android:layout_gravity="bottom" android:id="@+id/bottomBarCompose" android:layout_width="match_parent" android:layout_height="56dp" app:cardCornerRadius="0dp" />
   <androidx.compose.ui.platform.ComposeView android:id="@+id/rateAppCompose" android:layout_width="match_parent" android:layout_height="match_parent" />
   <ru.wildberries.widgets.SimpleStatusView android:id="@+id/mainActivityStatusView" android:layout_width="match_parent" android:layout_height="match_parent" />
</FrameLayout>

Decompiled xml from apkeditor:

<?xml version="1.0" encoding="UTF-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:ru="http://schemas.android.com/apk/res-auto" android:id="@id/mainContentRoot" android:visibility="invisible" android:layout_width="fill_parent" android:layout_height="fill_parent">
   <FrameLayout android:id="@id/mainTabContainer" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_marginBottom="@dimen/bottom_tab_bar_size" />
   <View android:layout_gravity="bottom" android:id="@id/bottomBarShadow" android:layout_marginBottom="@dimen/bottom_tab_bar_size" style="@style/Widget.WB.BottomBarShadow" />
   <androidx.compose.ui.platform.ComposeView android:layout_gravity="bottom" android:id="@id/bottomBarCompose" android:layout_width="fill_parent" android:layout_height="56.0dp" ru:cardCornerRadius="0.0dp" />
   <androidx.compose.ui.platform.ComposeView android:id="@id/rateAppCompose" android:layout_width="fill_parent" android:layout_height="fill_parent" />
   <ru.wildberries.widgets.SimpleStatusView android:id="@id/mainActivityStatusView" android:layout_width="fill_parent" android:layout_height="fill_parent" />
</FrameLayout>

After the compilation of the same apk, this attribute disappears (xml from JADX):

<?xml version="1.0" encoding="UTF-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/mainContentRoot" android:visibility="invisible" android:layout_width="match_parent" android:layout_height="match_parent">
   <FrameLayout android:id="@+id/mainTabContainer" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_marginBottom="@dimen/bottom_tab_bar_size" />
   <View android:layout_gravity="bottom" android:id="@+id/bottomBarShadow" android:layout_marginBottom="@dimen/bottom_tab_bar_size" style="@style/Widget.WB.BottomBarShadow" />
   <androidx.compose.ui.platform.ComposeView android:layout_gravity="bottom" android:id="@+id/bottomBarCompose" android:layout_width="match_parent" android:layout_height="56dp" android:cardCornerRadius="0dp" />
   <androidx.compose.ui.platform.ComposeView android:id="@+id/rateAppCompose" android:layout_width="match_parent" android:layout_height="match_parent" />
   <ru.wildberries.widgets.SimpleStatusView android:id="@+id/mainActivityStatusView" android:layout_width="match_parent" android:layout_height="match_parent" />
</FrameLayout>

If you fix xmlns:ru to xmlns:app in the file with your hands, then after compilation the attribute disappears anyway

To Reproduce
Steps to reproduce the behavior:

  1. Used version: APKEditor - 1.2.3, ARSCLib - 1.2.0
  2. Operating system: Ubuntu 22.04 (WSL)
  3. Command: java -jar bin/arsclib.jar d -t xml -i ../../tests/app.apk

Log/Stacktrace

00.000 I: [DECOMPILE] Decompiling ...
   Input: ../../tests/app.apk
 Output: ../../tests/app_decompile_xml
 Type: xml
 ---------------------------- 
00.014 I: [DECOMPILE] Loading ...
00.270 I: [DECOMPILE] Initializing android framework ...
00.270 I: [DECOMPILE] Loading android framework for version: 33
00.332 I: [DECOMPILE] Initialized framework: android-33 (UpsideDownCake)
00.332 I: [DECOMPILE] Decompiling to XML ...
00.359 I: [DECOMPILE] [SANITIZE]: Sanitizing paths ...
00.362 I: [DECOMPILE] Validating resource names ...
00.414 I: [DECOMPILE] Spec names validated, duplicates = 0, bad = 2, removed specs = 2
00.414 I: [DECOMPILE] Decode: uncompressed-files.json
00.434 I: [DECOMPILE] Decoding: AndroidManifest.xml
00.486 I: [DECOMPILE] public.xml: com.wildberries.ru -> package_1
00.503 I: [DECOMPILE] Res files: resources
03.291 [DECOMPILE] classes5.dex                                                                 
03.344 I: [DECOMPILE] Extracting root files ...
04.067 I: [DECOMPILE] Dumping signatures ...
04.067 I: [DECOMPILE] Saved to: ../../tests/app_decompile_xml

Used apk file
https://drive.google.com/file/d/1IZDCRmzyaqWdMex2x4vXh6jqcHVu6c0z/view?usp=sharing

Problematic file
layout/activity_main.xml

META-INF folder is empty after merge

Hi,
after performing merge, in case there are files in the META-INF folder in the main APK and the other (such as config.en.apk,config.armeabi_v7a.apk) has an empty META-INF folder, the result is that the merged apk will have an empty (with folders only) META-INF folder.

Building apk failed after adding network_security_config

Using xml type decoded apk

java -jar APKEditor.jar d -t xml -i apk.apk

I've put network_security_config.xml in nameofapp/res/xml as usual and added it in AndroidManifest.xml

<application
...
android:networkSecurityConfig="@xml/network_security_config"
...

This error showed when building the apk

java -jar APKEditor.jar b -i apk_decompile_xml -o apk_edited.apk
...
Local entry not found: type=xml, name=network_security_config

Apk fails to run after no changes made

I have tried to use your tool on Starbucks app, you can download it here:
https://apkcombo.com/starbucks/com.starbucks.mobilecard/

I have tried to just decompile and build, no changes applied.
Build fails in this case:

00.019 I: [BUILD] Scanning JSON directory ...
00.063 I: [BUILD] Writing apk...
Exception in thread "main" java.lang.NullPointerException: Cannot invoke "com.reandroid.arsc.chunk.xml.ResXmlStartNamespace.getUriReference()" because "ns" is null
at com.reandroid.arsc.chunk.xml.ResXmlAttribute.fromJson(ResXmlAttribute.java:336)
at com.reandroid.arsc.array.ResXmlAttributeArray.fromJson(ResXmlAttributeArray.java:139)
at com.reandroid.arsc.chunk.xml.ResXmlElement.fromJson(ResXmlElement.java:785)
at com.reandroid.arsc.chunk.xml.ResXmlElement.fromJson(ResXmlElement.java:798)
at com.reandroid.arsc.chunk.xml.ResXmlDocument.fromJson(ResXmlDocument.java:224)
at com.reandroid.apk.JsonXmlInputSource.getResXmlBlock(JsonXmlInputSource.java:53)
at com.reandroid.apk.JsonXmlInputSource.write(JsonXmlInputSource.java:35)
at com.reandroid.archive.ZipSerializer.write(ZipSerializer.java:77)
at com.reandroid.archive.ZipSerializer.writeZip(ZipSerializer.java:67)
at com.reandroid.archive.ZipSerializer.writeZip(ZipSerializer.java:44)
at com.reandroid.apk.ApkModule.writeApk(ApkModule.java:164)
at com.reandroid.apk.ApkModule.writeApk(ApkModule.java:139)
at com.reandroid.apkeditor.compile.Builder.buildJson(Builder.java:62)
at com.reandroid.apkeditor.compile.Builder.run(Builder.java:44)
at com.reandroid.apkeditor.compile.Builder.execute(Builder.java:144)
at com.reandroid.apkeditor.Main.execute(Main.java:60)
at com.reandroid.apkeditor.Main.main(Main.java:38)

I have also tried to apply x command, to refactor the resource names. It made an apk file, and I have signed it, successfully installed it, but the app crashes on the very start.

Can you help me with this issue?

Failed to install the merged apk [INSTALL_PARSE_FAILED_NO_CERTIFICATES]

I tried to install a merged apk file using adb install.
Failure [INSTALL_PARSE_FAILED_NO_CERTIFICATES: Failed collecting certificates for /data/app/vmdl1926639033.tmp/base.apk: Failed to collect certificates from /data/app/vmdl1926639033.tmp/base.apk: Attempt to get length of null array]

APKEditor is unable to merged apks (Java heap space)

Android Version 12
Apk editor version 1.1.3

While merging the apks

$ java -jar APKEditor-1.1.3.jar m -i new/ -o out.apk
00.000 I: [MERGE] Merging ...
   Input: new
 Output: out.apk
 ----------------------------
00.043 I: [MERGE] Searching apk files ...
00.047 I: [MERGE] Found apk files: 11
00.080 [MERGE] ading: split_config.xxhdpi.apk
00.083 I: [MERGE] Found modules: 11
00.084 I: [MERGE] Merging string pools ...
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
        at com.reandroid.lib.arsc.item.BlockItem.setBytesLength(BlockItem.java:59)
        at com.reandroid.lib.arsc.item.StringItem.onReadBytes(StringItem.java:132)
        at com.reandroid.lib.arsc.base.Block.readBytes(Block.java:38)
        at com.reandroid.lib.arsc.array.OffsetBlockArray.onReadBytes(OffsetBlockArray.java:189)
        at com.reandroid.lib.arsc.base.Block.readBytes(Block.java:38)
        at com.reandroid.lib.arsc.base.BlockContainer.onReadBytes(BlockContainer.java:149)
        at com.reandroid.lib.arsc.chunk.BaseChunk.onReadBytes(BaseChunk.java:60)
        at com.reandroid.lib.arsc.base.Block.readBytes(Block.java:38)
        at com.reandroid.lib.arsc.pool.TableStringPool.readFromTable(TableStringPool.java:74)
        at com.reandroid.lib.apk.ApkModule.getVolatileTableStringPool(ApkModule.java:273)
        at com.reandroid.lib.apk.ApkBundle.mergeStringPools(ApkBundle.java:80)
        at com.reandroid.lib.apk.ApkBundle.mergeModules(ApkBundle.java:43)
        at com.reandroid.apkeditor.merge.Merger.run(Merger.java:55)
        at com.reandroid.apkeditor.merge.Merger.execute(Merger.java:195)
        at com.reandroid.apkeditor.Main.execute(Main.java:64)
        at com.reandroid.apkeditor.Main.main(Main.java:38)

Protectecd APK File Could NOT Upload to Play Store!

Hi and thank you for this amazing tool it's very good and helpful to protect our content from reverse engineering or modding the two main feature Refactor and Protect are so great to protect APK file against any editor or modder but it have a small bug when you want to upload the protected file to play store you get some errors that app not compiled properly or it doesn't have meta data com.android.vending.derived.apk.id my apk file is already included that meta data and it's compiled without any errors and it's signed with same signature certificate I can install on my devices but I don't know what is the problem play store console doesn't let me upload it to release new protected version.

Need some help please

Here is the screenshot:

Screenshot 2023-05-05 171213

Bug on android 13

i get the bug below 👇 when i use that command
To Reproduce
Steps to reproduce the behavior:

  1. Used version 'last version'
  2. Operating system 'android'
  3. Command 'p -i /storage/emulated/0/NewProject2.apk'

01:55.335 I: [PROTECT] Protecting ...
Input: /storage/emulated/0/NewProject2.apk
Output: /storage/emulated/0/NewProject2_protected.apk

01:55.335 I: [PROTECT] Loading apk ...
java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at com.my.newproject13.CmdTask.run(CmdTask.java:24)
at java.lang.Thread.run(Thread.java:1012)
Caused by: java.lang.NoClassDefFoundError: com.reandroid.archive.io.ArchiveFileEntrySource
at com.reandroid.archive.ArchiveFile.createInputSource(ArchiveFile.java:36)
at com.reandroid.archive.Archive.mapEntrySource(Archive.java:95)
at com.reandroid.archive.Archive.createZipEntryMap(Archive.java:52)
at com.reandroid.apk.ApkModule.loadApkFile(ApkModule.java:1095)
at com.reandroid.apkeditor.protect.Protector.run(Protector.java:48)
at com.reandroid.apkeditor.protect.Protector.execute(Protector.java:158)
at com.reandroid.apkeditor.Main.execute(Main.java:80)
at com.reandroid.apkeditor.Main.main(Main.java:41)
... 3 more
Caused by: java.lang.NoSuchMethodError: No static method metafactory(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodHandle;Ljava/lang/invoke/MethodType;)Ljava/lang/invoke/CallSite; in class Ljava/lang/invoke/LambdaMetafactory; or its super classes (declaration of 'java.lang.invoke.LambdaMetafactory' appears in /apex/com.android.art/javalib/core-oj.jar)
at com.reandroid.archive.InputSource.(InputSource.java:270)
at com.reandroid.archive.ArchiveFile.createInputSource(ArchiveFile.java:36)
at com.reandroid.archive.Archive.mapEntrySource(Archive.java:95)
at com.reandroid.archive.Archive.createZipEntryMap(Archive.java:52)
at com.reandroid.apk.ApkModule.loadApkFile(ApkModule.java:1095)
at com.reandroid.apkeditor.decompile.Decompiler.run(Decompiler.java:39)
at com.reandroid.apkeditor.decompile.Decompiler.execute(Decompiler.java:127)
at com.reandroid.apkeditor.Main.execute(Main.java:64)
... 4 more

Xml breaks when recompiling (xml mode)

Describe the bug
If the attached apk is decompiled (in xml mode, before that - deobfuscation of resources), and then compiled immediately, then it will no longer work - throws an error:

FATAL EXCEPTION: main
Process: com.perm.kate, PID: 31361
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.perm.kate/com.perm.kate.MainActivity}: android.view.InflateException: Binary XML file line #9 in com.perm.kate:layout/main: For input string: "?2130968955"
	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3449)
	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3601)
	at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85)
	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:2066)
	at android.os.Handler.dispatchMessage(Handler.java:106)
	at android.os.Looper.loop(Looper.java:223)
	at android.app.ActivityThread.main(ActivityThread.java:7656)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)

Just deobfuscation of resources does not break anything, the problem appears only after recompilation

To Reproduce
Steps to reproduce the behavior:

  1. Used version: APKEditor - 1.2.4, ARSCLib - 1.2.0
  2. Operating system: Ubuntu 22.04 (WSL)

Used apk file
https://drive.google.com/file/d/1cnfQrlXlVqHamIYzxkyqp55Sb3Lfze75/view?usp=sharing

error: invalid value for type 'xml'. Expected a reference.

After merging using APKEditor 1.1.5 and recompile APK using apktool.jar, I got the following error

I: Using Apktool 2.7.0
I: Copying D:\aa.apk classes.dex file...
I: Smaling smali_classes5 folder into classes5.dex...
I: Copying D:\aa.apk classes2.dex file...
I: Copying D:\aa.apk classes3.dex file...
I: Copying D:\aa.apk classes4.dex file...
I: Building resources...
W: D:\aa.apk\res\values\xmls.xml:3: error: invalid value for type 'xml'. Expected a reference.
W: D:\aa.apk\res\values\xmls.xml: error: file failed to compile.
brut.androlib.AndrolibException: brut.common.BrutException: could not exec (exit code = 1): [C:\Users\tomo\AppData\Local\Temp\brut_util_Jar_27089019280952996248214434835679478593.tmp, compile, --dir, D:\aa.apk\res, --legacy, -o, D:\aa.apk\build\resources.zip]

Link to APK: https://apkcombo.com/downloader/#package=com.ea.gp.simsmobile

The merged apk file is an invalid file.

I downloaded an apk file named GPark_1.3.0_apkcombo.com.xapk from apkcombo.com, and then used the following command to merge it into an apk file:
java -jar APKEditor-1.2.1.jar m -i GPark_1.3.0_apkcombo.com.xapk

The command executed successfully and generated an output file named GPark_1.3.0_apkcombo.com_merged.apk.
However, I cannot install it on my device, and I'm unable to open it using jadx as well. Jadx gives the following error message:

Caused by: java.util.zip.ZipException: invalid CEN header (bad entry name)
	at java.base/java.util.zip.ZipFile$Source.zerror(ZipFile.java:1598)
	at java.base/java.util.zip.ZipFile$Source.checkAndAddEntry(ZipFile.java:1209)
	at java.base/java.util.zip.ZipFile$Source.initCEN(ZipFile.java:1537)
	at java.base/java.util.zip.ZipFile$Source.<init>(ZipFile.java:1315)
	at java.base/java.util.zip.ZipFile$Source.get(ZipFile.java:1277)
	at java.base/java.util.zip.ZipFile$CleanableResource.<init>(ZipFile.java:709)
	at java.base/java.util.zip.ZipFile.<init>(ZipFile.java:243)
	at java.base/java.util.zip.ZipFile.<init>(ZipFile.java:172)
	at java.base/java.util.zip.ZipFile.<init>(ZipFile.java:186)
	at jadx.api.plugins.utils.ZipSecurity.visitZipEntries(ZipSecurity.java:97)
	... 8 common frames omitted

Here is the attachment link for the APK, Do you have any suggestions?

APKEditor can't handle tags in string resources

Describe the bug
If you decompile with APKEditor and build again, tag processing, which was originally good, does not work.
Please refer to the picture for related information

image

To Reproduce
Steps to reproduce the behavior:

  1. Used version 1.2.5
  2. Operating system macOS 13.4.1
  3. Command

decompile: java -jar ~/APKEditor-1.2.5.jar d -i kakaotalk.apk -o kakaotalk
compile: java -jar ~/APKEditor-1.2.5.jar b -i kakaotalk -o kakaotalk.apk

Log/Stacktrace
Nothing.

Used apk file
Attach/share your apk

Additional context
Related classes are the same as xc.f, and you can refer to the label_multi_photo_guide resource.

Merging massive split APK generates broken APK

Describe the bug
It merges apk just fine without errors but apk is broken. Trying to modify apk via Winrar causes "archive is broken" and signing error causes "Exception in thread "main" com.android.apksig.apk.ApkFormatException: Malformed ZIP Central Directory record #1 at file offset 606531584"
I'm using Java 20.0.1 on Windows 11

To Reproduce
Steps to reproduce the behavior:
java -jar APKEditor.jar m -i (apk folder)

Log/Stacktrace:

00.000 I: [MERGE] Merging ...
   Input: E:\Downloads\apk
 Output: E:\Downloads\apk_merged.apk
 ----------------------------
00.027 I: [MERGE] Searching apk files ...
00.031 I: [MERGE] Found apk files: 15
00.986 [MERGE] Loading: split_Weapon.apk
00.989 I: [MERGE] Found modules: 15
01.055 I: [MERGE] Merging string pools ...
01.071 I: [MERGE] Merged string pools=1, style=0, strings=1506
01.093 I: [MERGE] Merging: base
01.099 I: [MERGE] Added [base] classes.dex -> classes.dex
01.099 I: [MERGE] Added [base] classes2.dex -> classes2.dex
01.099 I: [MERGE] Merging resource table: base
22.982 [MERGE] Added: assets/bin/Data/96689ea54b64b9b48993d6d312021c56
22.983 I: [MERGE] Merging: split_MovieMapAb
23.015 [MERGE] Added: assets/assetpack/Movie/MapAbility/jp/mapability_32.usm
23.016 I: [MERGE] Merging: split_MovieEvent
23.043 [MERGE] Added: assets/assetpack/Movie/Event/sif.usm
23.044 I: [MERGE] Merging: split_Sound
23.060 [MERGE] Added: assets/assetpack/SEP.acb
23.061 I: [MERGE] Merging: split_Map
23.750 [MERGE] Added: assets/assetpack/AssetBundle/map/map1fe.bytes
23.751 I: [MERGE] Merging: split_Gallery
23.845 [MERGE] Added: assets/assetpack/AssetBundle/gallery/illust_007.bytes
23.846 I: [MERGE] Merging: split_GraCom
24.084 [MERGE] Added: assets/assetpack/AssetBundle/disc/jp/gracom/grac0f4_2.bytes
24.085 I: [MERGE] Merging: split_MiniMap
24.443 [MERGE] Added: assets/assetpack/AssetBundle/minimap/minimap_vf_gld02.bytes
24.444 I: [MERGE] Merging: split_MapObj
24.756 [MERGE] Added: assets/assetpack/AssetBundle/mapobj/mapobj0dc.bytes
24.757 I: [MERGE] Merging: split_BgEvent
24.811 [MERGE] Added: assets/assetpack/AssetBundle/disc/jp/bg_event/bg_event25.bytes
24.813 I: [MERGE] Merging: split_Disc
53.002 [MERGE] Added: assets/assetpack/AssetBundle/disc/jp/chranimext/11102/00231.aba.bytes
53.007 I: [MERGE] Merging: split_Weapon
53.141 [MERGE] Added: assets/assetpack/AssetBundle/weapon/w11109.bytes
53.142 I: [MERGE] Merging: split_Chr
53.928 [MERGE] Added: assets/assetpack/AssetBundle/chr/w11103.bytes
53.929 I: [MERGE] Merging: split_Effect
59.136 [MERGE] Added: assets/assetpack/AssetBundle/effect/tex_btl/b0069.bytes
59.139 I: [MERGE] Merging: split_Voice
59.153 [MERGE] Added: assets/assetpack/VOICE_JP.awb
59.416 I: [MERGE] Sanitizing manifest ...
59.417 I: [MERGE] Removed: extractNativeLibs
59.417 I: [MERGE] Removed: <meta-data android:name(@0x01010003)="com.android.stamp.source" android:value(@0x01010024)="https://play.google.com/store"/>
59.418 I: [MERGE] Removed: <meta-data android:name(@0x01010003)="com.android.stamp.type" android:value(@0x01010024)="STAMP_TYPE_DISTRIBUTION_APK"/>
59.426 I: [MERGE] Table size changed = 162904, 163020
59.426 I: [MERGE] Removed xml strings = 1
Xml size changed = 10416, 10408
59.427 I: [MERGE] Writing apk ...
01:00.237 I: [MERGE] Buffering compress changed files ...
01:00.323 I: [MERGE] Zip align ...
01:00.394 I: [MERGE] Writing files: 44616
01:46.498 I: [MERGE] Writing signature block ...
01:46.732 I: [MERGE] Saved to: E:\Downloads\apk_merged.apk

Used apk file
https://mega.nz/file/3UwCRKjI#MnrptonVXIrg3IEZTc9YI4n50uNs7hiqR6Eic7-R4CA

Additional context
There is an error when choosing zip file as input instead directory

java -jar APKEditor.jar m -i (zip file)

   Input: E:\Downloads\romancing-saga-minstrel-song-1.0.0.zip
 Output: E:\Downloads\romancing-saga-minstrel-song-1.0.0_merged.apk
 ----------------------------
00.026 I: [MERGE] Extracting to: E:\Downloads\tmp_ddb3b536
00.036 I: [MERGE] Searching apk files ...

ERROR:
No such directory: E:\Downloads\tmp_ddb3b536
java.io.FileNotFoundException: No such directory: E:\Downloads\tmp_ddb3b536
        at com.reandroid.apk.ApkBundle.loadApkDirectory(ApkBundle.java:146)
        at com.reandroid.apkeditor.merge.Merger.run(Merger.java:60)
        at com.reandroid.apkeditor.merge.Merger.execute(Merger.java:229)
        at com.reandroid.apkeditor.Main.execute(Main.java:72)
        at com.reandroid.apkeditor.Main.main(Main.java:41)

XML entity shows up as "&amp;" instead of "&" after repacking apk

Describe the bug
It appears that APKEditor cannot correctly handle XML entities in resource strings.
String in source code: <string name="test_string">\"Alma\" &amp; Körte</string>.
Expected behaviour: The string should show up as "Alma" & Körte after repacking the apk.
Actual behaviour: The string shows up as "Alma" &amp; Körte after repacking the apk.

To Reproduce
Steps to reproduce the behavior:

  1. Used version '1.2.5'
  2. Operating system 'Linux 5.15.90.1-microsoft-standard-WSL2 x86_64 GNU/Linux'
  3. Commands java -jar APKEditor-1.2.5.jar d -dex -i app-debug.apk and java -jar APKEditor-1.2.5.jar b -i app-debug_decompile_xml -o packed.apk

Log/Stacktrace

Used apk file
app-debug.apk.zip

Additional context
image

Source code for apk (android studio, new project, empty activity)

strings.xml

<resources>
    <string name="app_name">APKEditorTest</string>
    <string name="test_string">\"Alma\" &amp; Körte</string>
</resources>

MainActivity.kt

package com.example.apkeditortest

import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import com.example.apkeditortest.ui.theme.APKEditorTestTheme

class MainActivity : ComponentActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContent {
            APKEditorTestTheme {
                // A surface container using the 'background' color from the theme
                Surface(
                    modifier = Modifier.fillMaxSize(),
                    color = MaterialTheme.colorScheme.background
                ) {
                    Greeting(getString(R.string.test_string))
                }
            }
        }
    }
}

@Composable
fun Greeting(name: String, modifier: Modifier = Modifier) {
    Text(
        text = "Hello $name!",
        modifier = modifier
    )
}

@Preview(showBackground = true)
@Composable
fun GreetingPreview() {
    APKEditorTestTheme {
        Greeting("Android")
    }
}

java.io.IOException: Can not decode without package

Describe the bug
I created the simplest possible "empty" application. When trying to decompile it in xml mode, apkeditor crashes :(
In json mode everything is ok.

To Reproduce
Steps to reproduce the behavior:

  1. Used version: 1.3.1
  2. Operating system: WSL Ubuntu 22.04
  3. Command: java -jar apkeditor.jar d -i app.apk -t xml

Log/Stacktrace

...
00.179 I: [DECOMPILE] Decoding: AndroidManifest.xml

ERROR:
java.io.IOException: Can not decode without package
        at com.reandroid.arsc.chunk.xml.ResXmlDocument.serialize(ResXmlDocument.java:456)
        at com.reandroid.apk.ApkModuleXmlDecoder.serializeXml(ApkModuleXmlDecoder.java:241)
        at com.reandroid.apk.ApkModuleXmlDecoder.decodeAndroidManifestXml(ApkModuleXmlDecoder.java:220)
        at com.reandroid.apk.ApkModuleXmlDecoder.decodeAndroidManifest(ApkModuleXmlDecoder.java:203)
        at com.reandroid.apk.ApkModuleDecoder.decode(ApkModuleDecoder.java:47)
        at com.reandroid.apkeditor.decompile.Decompiler.run(Decompiler.java:62)
        at com.reandroid.apkeditor.decompile.Decompiler.execute(Decompiler.java:127)
        at com.reandroid.apkeditor.Main.execute(Main.java:81)
        at com.reandroid.apkeditor.Main.execute(Main.java:64)
        at com.reandroid.apkeditor.Main.main(Main.java:36)

Used apk file
Attach/share your apk

ApplicationInfo.metaData very strange error

Describe the bug
The application has metadata specified in the application tag. In the original apk, you can get the value of the key com.push server.android.serverparyid with the ApplicationInfo.metaData.getString method. But after recompiling without making changes, this method starts returning null and only ApplicationInfo.metaData.getInt works. And I can't figure out why...

To Reproduce
Steps to reproduce the behavior:

  1. Used version: 1.2.9
  2. Operating system: WSL Ubuntu 22.04
  3. Command: java -jar apkeditor.jar d -i app.apk & java -jar apkeditor.jar b -i app_decompiled_xml

The problem appears in the method Lcom/edna/android/push_lite/repo/config/NetworkConfiguration;->initPrimaryServer(Landroid/os/Bundle;)V at line invoke-virtual {p1, v0}, Landroid/os/BaseBundle;->getString(Ljava/lang/String;)Ljava/lang/String; (it returns null on recompiled apk)
The value itself is specified in the manifest:

<application android:theme="@style/FaceliftTheme"
...
<meta-data android:name="com.pushserver.android.serverPrimaryId" android:value="@string/mfms_primary_id" />
...
</application>

Used apk file
Original apk: https://drive.google.com/file/d/1VGqz-vIoa70ESahvQTuIs0EqIq-vp2b1/view?usp=sharing

Additional context
I wrote a simple program that requests metadata from the application and shows the problematic key (the first line), and also outputs the entire contents of the Bundle: https://drive.google.com/file/d/14Xh4xnmDz5wcJx9a0v1TDp_ACw1WkCEi/view?usp=sharing
There you need to click on the FAB at the bottom to get the data. the original application must be installed accordingly
изображение

Input XAPK path?

Can you support input XAPK path to automatically extract it and proceed the merging process? I'm lazy to extract it manually just to use the input path

The latest version 1.2.2 fails to compile back with json

wrong information:

java -jar APKEditor.jar b -i Home_decompile_json

00.000 I: [BUILD] Building ...
   Input: Home_decompile_json
 Output: Home_decompile_json_out.apk
 ---------------------------- 
00.022 I: [BUILD] Scanning JSON directory ...
00.025 I: [BUILD] Scanning: Home_decompile_json
00.061 I: [BUILD] Building dex ...
00.062 [BUILD] classes2.dex
00.063 I: [BUILD] Scanning root directory ...
00.071 I: [BUILD] Restoring original file paths ...

Unexpected error:
java.io.IOException: No package sub directory found in : Home_decompile_json/resources
java.lang.IllegalArgumentException: java.io.IOException: No package sub directory found in : Home_decompile_json/resources
	at com.reandroid.apk.ApkModule.getTableBlock(ApkModule.java:754)
	at com.reandroid.apk.ApkModule.getTableBlock(ApkModule.java:789)
	at com.reandroid.apk.ApkModule.listResFiles(ApkModule.java:560)
	at com.reandroid.apk.ApkModule.listResFiles(ApkModule.java:556)
	at com.reandroid.apk.PathMap.restore(PathMap.java:37)
	at com.reandroid.apk.ApkModuleEncoder.restorePathMap(ApkModuleEncoder.java:95)
	at com.reandroid.apk.ApkModuleEncoder.scanDirectory(ApkModuleEncoder.java:42)
	at com.reandroid.apkeditor.compile.Builder.buildJson(Builder.java:65)
	at com.reandroid.apkeditor.compile.Builder.run(Builder.java:45)
	at com.reandroid.apkeditor.compile.Builder.execute(Builder.java:152)
	at com.reandroid.apkeditor.Main.execute(Main.java:68)
	at com.reandroid.apkeditor.Main.main(Main.java:41)
Caused by: java.io.IOException: No package sub directory found in : Home_decompile_json/resources
	at com.reandroid.apk.TableBlockJsonBuilder.scanDirectory(TableBlockJsonBuilder.java:41)
	at com.reandroid.apk.SplitJsonTableInputSource.getTableBlock(SplitJsonTableInputSource.java:56)
	at com.reandroid.apk.ApkModule.loadTableBlock(ApkModule.java:866)
	at com.reandroid.apk.ApkModule.getTableBlock(ApkModule.java:748)
	... 11 more

apk file: Home_test1.zip

Error while building apk (smali)

After decompiling an APK, modifified the smali files, when rebuilding the following error appears:

00.023 I: [BUILD] Scanning XML directory ...
00.053 I: [BUILD] Scanning: app
00.241 I: [BUILD] Initializing android framework ...
00.241 I: [BUILD] Loading android framework for version: 33
00.341 I: [BUILD] Initialized framework: android-33 (UpsideDownCake)
00.342 I: [BUILD] Encoding attrs ...
00.453 I: [BUILD] Encoding values ...                                                                                                                                                                                                            
00.657 I: [BUILD] Scan: package_1/res                                                                                                                                                                                                            
00.692 I: [BUILD] Scanned 1004 files: package_1/res
00.720 I: [BUILD] Add manifest: AndroidManifest.xml
00.721 I: [BUILD] Building dex ...
00.766 I: [BUILD] WARN: Ignore: app/smali/.DS_Store                                                                                                                                                                                              
00.848 I: [BUILD] (1/3) Cached: classes.dex
00.914 I: [BUILD] (2/3) Cached: classes2.dex
00.914 I: [BUILD] (3/3) Smali: classes3.dex

ERROR:
java.io.IOException: Failed to build smali, check the logs
	at com.reandroid.apkeditor.smali.SmaliCompiler.build(SmaliCompiler.java:87)
	at com.reandroid.apkeditor.smali.SmaliCompiler.build(SmaliCompiler.java:65)
	at com.reandroid.apkeditor.smali.SmaliCompiler.buildDexFiles(SmaliCompiler.java:57)
	at com.reandroid.apk.ApkModuleEncoder.encodeDexFiles(ApkModuleEncoder.java:112)
	at com.reandroid.apk.ApkModuleEncoder.scanDirectory(ApkModuleEncoder.java:40)
	at com.reandroid.apkeditor.compile.Builder.buildXml(Builder.java:116)
	at com.reandroid.apkeditor.compile.Builder.run(Builder.java:47)
	at com.reandroid.apkeditor.compile.Builder.execute(Builder.java:176)
	at com.reandroid.apkeditor.Main.execute(Main.java:85)
	at com.reandroid.apkeditor.Main.execute(Main.java:64)
	at com.reandroid.apkeditor.Main.main(Main.java:36)

Don't know where read the log, and why the error occurs.
Regards

Preserve multiplexed APK

Describe the bug
Since we bypass security with original APK inside modified APK, we needed to multiplex APK in order to reduce the size of APK.
APKEditor does not support multiplexed APK, so any modifications will lose multiplex and revert size to original. For example, multiplexed APK is 189 MB. After modification using APKEditor, the size reverts back to 369 MB

image

See the details how multiplex technique works. The source is written in Java too, makes it easier to adopt to your project! https://github.com/L-JINBIN/ApkDataMultiplexing

To Reproduce
Steps to reproduce the behavior:
I don't want to give details about bypassing but you can easly replicate it

  1. Put original APK inside an APK you want to be modified (e.g. /assets/sample.apk)
  2. Multiplex the APK file from /assets/sample.apk using ApkDataMultiplexing. You need your own jks file to sign and multiplex it
  3. Make any modifications using APKEditor

Used apk file
https://mega.nz/file/PRRRBBQJ#8EYVX3gI1ejL1cSZmfTQtWkyo5Ay69CMhIKGKqI7siw

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.