iBotPeaches / Apktool

A tool for reverse engineering Android apk files
https://apktool.org/
Apache License 2.0
20.29k stars 3.59k forks source link

[BUG] crash after recompile even without edit the apk #2671

Closed ibrahemashraf closed 1 year ago

ibrahemashraf commented 3 years ago

Information

  1. **Apktool Version 2.6.0
  2. **Operating System Linux
  3. **APK From? Playstore

Questions to ask before submission

  1. Have you tried apktool d, apktool b without changing anything? yes
  2. If you are trying to install a modified apk, did you resign it? yes
  3. Are you using the latest apktool version? yes

    I used apktool -d and apktool -b without edit anything and after recompile the app crashes on startup is there any way to fix this problem? this is the app that i tested on : https://apkpure.com/yalla-free-voice-chat-rooms/com.weieyu.yalla please help me i searched everywhere to fix it :(

iBotPeaches commented 3 years ago

please help me i searched everywhere to fix it :(

Do you have a logcat of the crash on startup?

LeandroVanolli commented 2 years ago

I'm facing an almost similar problem. I'm running -d and -b without editing anything, and the apk built can't be installed anymore.

The app is: WIFIAV-HD. I'm using the 2.6.0 version, JRE 1.8.0, Windows 10. Zenfone 4 PRO running Android 8.

If somebody could help, I would be glad :)

miaotaoii commented 2 years ago

same issue for me. crashed after install ,i rebuild apk with apktool 2.4.1 & 2.6.1,same result,and i can't found any useful error stackTrace in logcat after crash . don't know how to slove ;@iBotPeaches

iBotPeaches commented 2 years ago

Welcome to my struggle. If you can't find a noticeable error in logcat and its crashing, then we have a problem that I don't think I can solve.

miaotaoii commented 2 years ago

what a pity; i have rebuilt many apks succeed used apktool , but not for this apk, i can't see why it didn't work...;i believe i will find out the reason

PeroKetStory commented 2 years ago

Hi! For what it worth, I gave it a try with the app @ibrahemashraf provided. Decompiled/Built with apktool 2.6.1, resigned with uber-apk-signer. Installation without any issue, but at start time, it indeed crash. But I have a stack trace in logcat:

04-20 13:39:26.377  1601  1643 D EventSequenceValidator: Transition from ACTIVITY_CANCELLED to INTENT_STARTED
04-20 13:39:26.377  1601  1621 I ActivityTaskManager: START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.weieyu.yalla/com.yalla.yalla.ui.activity.StartActivity bnds=[841,334][1043,661]} from uid 10208
04-20 13:39:26.416  1601  1643 D CompatibilityChangeReporter: Compat change id reported: 135634846; UID 10253; state: DISABLED
04-20 13:39:26.416  1601  1643 D CompatibilityChangeReporter: Compat change id reported: 135754954; UID 10253; state: ENABLED
04-20 13:39:26.416  1601  1658 D CompatibilityChangeReporter: Compat change id reported: 143937733; UID 10253; state: ENABLED
04-20 13:39:26.416  1601  1643 D EventSequenceValidator: Transition from INTENT_STARTED to ACTIVITY_LAUNCHED
04-20 13:39:26.425   893   893 D Zygote  : Forked child process 6362
04-20 13:39:26.428  6362  6362 I Zygote  : SpecializeCommon process_name=zygote, nice_name=com.weieyu.yalla pid=6362 is_system_server=0
04-20 13:39:26.428  1601  1658 I ActivityManager: Start proc 6362:com.weieyu.yalla/u0a253 for pre-top-activity {com.weieyu.yalla/com.yalla.yalla.ui.activity.StartActivity}
04-20 13:39:26.440  6362  6362 E om.weieyu.yall: Not starting debugger since process cannot load the jdwp agent.
04-20 13:39:26.459  6362  6362 I om.weieyu.yall: The ClassLoaderContext is a special shared library.
04-20 13:39:26.470  6362  6362 D NetworkSecurityConfig: No Network Security Config specified, using platform default
04-20 13:39:26.470  6362  6362 D NetworkSecurityConfig: No Network Security Config specified, using platform default
04-20 13:39:26.471  6362  6362 I MultiDex: VM with version 2.1.0 has multidex support
04-20 13:39:26.471  6362  6362 I MultiDex: Installing application
04-20 13:39:26.471  6362  6362 I MultiDex: VM has multidex support, MultiDex support library is disabled.
04-20 13:39:26.487  6362  6362 I FirebaseInitProvider: FirebaseApp initialization successful
04-20 13:39:26.488  6362  6362 D WM-WrkMgrInitializer: Initializing WorkManager with default configuration.
04-20 13:39:26.493  6362  6362 I TetheringManager: registerTetheringEventCallback:com.weieyu.yalla
04-20 13:39:26.517  6362  6386 W om.weieyu.yall: Unsupported class loader
04-20 13:39:26.522  6362  6362 W com.facebook.UserSettingsManager: Please set a value for AutoLogAppEventsEnabled. Set the flag to TRUE if you want to collect app install, app launch and in-app purchase events automatically. To request user consent before collecting data, set the flag value to FALSE, then change to TRUE once user consent is received. Learn more: https://developers.facebook.com/docs/app-events/getting-started-app-events-android#disable-auto-events.
04-20 13:39:26.522  6362  6362 W com.facebook.UserSettingsManager: You haven't set a value for AdvertiserIDCollectionEnabled. Set the flag to TRUE if you want to collect Advertiser ID for better advertising and analytics results. To request user consent before collecting data, set the flag value to FALSE, then change to TRUE once user consent is received. Learn more: https://developers.facebook.com/docs/app-events/getting-started-app-events-android#disable-auto-events.
04-20 13:39:26.530  6362  6386 W om.weieyu.yall: Skipping duplicate class check due to unsupported classloader
04-20 13:39:26.531  6362  6386 W om.weieyu.yall: Unsupported class loader
04-20 13:39:26.538  1601  3277 E system_server: Invalid class loader spec: =UnsupportedClassLoaderContext=
04-20 13:39:26.538  1601  3277 E PackageDexUsage: Unsupported context?
04-20 13:39:26.539  6362  6386 I DynamiteModule: Considering local module com.google.android.gms.measurement.dynamite:20 and remote module com.google.android.gms.measurement.dynamite:55
04-20 13:39:26.540  6362  6386 I DynamiteModule: Selected remote version of com.google.android.gms.measurement.dynamite, version >= 55
04-20 13:39:26.541  6362  6386 V DynamiteModule: Dynamite loader version >= 2, using loadModule2NoCrashUtils
04-20 13:39:26.559  6362  6362 D AndroidAutoSize: designWidthInDp = 360, designHeightInDp = 640, screenWidth = 1080, screenHeight = 2160
04-20 13:39:26.559  6362  6362 D AndroidAutoSize: initDensity = 2.75, initScaledDensity = 2.75
04-20 13:39:26.579  1601  1621 D CompatibilityChangeReporter: Compat change id reported: 136274596; UID 10253; state: ENABLED
04-20 13:39:26.584  6362  6362 D AndroidRuntime: Shutting down VM
04-20 13:39:26.584  6362  6362 E AndroidRuntime: FATAL EXCEPTION: main
04-20 13:39:26.584  6362  6362 E AndroidRuntime: Process: com.weieyu.yalla, PID: 6362
04-20 13:39:26.584  6362  6362 E AndroidRuntime: java.lang.UnsatisfiedLinkError: JNI_ERR returned from JNI_OnLoad in "/data/app/~~veJvTrfH-VDiWVhH3XXw7w==/com.weieyu.yalla-LO43q6ygKijskmxwwfc4Qg==/lib/arm64/libencryption.so"
04-20 13:39:26.584  6362  6362 E AndroidRuntime:    at java.lang.Runtime.loadLibrary0(Runtime.java:1087)
04-20 13:39:26.584  6362  6362 E AndroidRuntime:    at java.lang.Runtime.loadLibrary0(Runtime.java:1008)
04-20 13:39:26.584  6362  6362 E AndroidRuntime:    at java.lang.System.loadLibrary(System.java:1664)
04-20 13:39:26.584  6362  6362 E AndroidRuntime:    at com.common.support.encryption.YlEncryption.<clinit>(SourceFile:1)
04-20 13:39:26.584  6362  6362 E AndroidRuntime:    at com.common.support.encryption.YlEncryption.iv(Native Method)
04-20 13:39:26.584  6362  6362 E AndroidRuntime:    at o00o0O0O.oOo0o00.<clinit>(SourceFile:1)
04-20 13:39:26.584  6362  6362 E AndroidRuntime:    at o00o0O0O.oOo0o00.OooO0OO(Unknown Source:0)
04-20 13:39:26.584  6362  6362 E AndroidRuntime:    at o0Oooo0o.o000O0.onChanged(SourceFile:2)
04-20 13:39:26.584  6362  6362 E AndroidRuntime:    at androidx.lifecycle.LiveData.considerNotify(SourceFile:6)
04-20 13:39:26.584  6362  6362 E AndroidRuntime:    at androidx.lifecycle.LiveData.dispatchingValue(SourceFile:5)
04-20 13:39:26.584  6362  6362 E AndroidRuntime:    at androidx.lifecycle.LiveData$ObserverWrapper.activeStateChanged(SourceFile:5)
04-20 13:39:26.584  6362  6362 E AndroidRuntime:    at androidx.lifecycle.LiveData.observeForever(SourceFile:5)
04-20 13:39:26.584  6362  6362 E AndroidRuntime:    at o0Oooo0o.o00O.<clinit>(SourceFile:11)
04-20 13:39:26.584  6362  6362 E AndroidRuntime:    at com.app.base.application.App.onCreate(SourceFile:16)
04-20 13:39:26.584  6362  6362 E AndroidRuntime:    at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1192)
04-20 13:39:26.584  6362  6362 E AndroidRuntime:    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6712)
04-20 13:39:26.584  6362  6362 E AndroidRuntime:    at android.app.ActivityThread.access$1300(ActivityThread.java:237)
04-20 13:39:26.584  6362  6362 E AndroidRuntime:    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1913)
04-20 13:39:26.584  6362  6362 E AndroidRuntime:    at android.os.Handler.dispatchMessage(Handler.java:106)
04-20 13:39:26.584  6362  6362 E AndroidRuntime:    at android.os.Looper.loop(Looper.java:223)
04-20 13:39:26.584  6362  6362 E AndroidRuntime:    at android.app.ActivityThread.main(ActivityThread.java:7656)
04-20 13:39:26.584  6362  6362 E AndroidRuntime:    at java.lang.reflect.Method.invoke(Native Method)
04-20 13:39:26.584  6362  6362 E AndroidRuntime:    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
04-20 13:39:26.584  6362  6362 E AndroidRuntime:    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
04-20 13:39:26.586  1601  2391 W ActivityTaskManager:   Force finishing activity com.weieyu.yalla/com.yalla.yalla.ui.activity.StartActivity
04-20 13:39:26.586  1601  6425 I DropBoxManagerService: add tag=data_app_crash isTagEnabled=true flags=0x2
04-20 13:39:26.592  6362  6424 W SSSSSS  : status-> 1 -->pid -->6362
04-20 13:39:26.601  1601  1657 W BroadcastQueue: Background execution not allowed: receiving Intent { act=android.intent.action.DROPBOX_ENTRY_ADDED flg=0x10 (has extras) } to com.google.android.gms/.stats.service.DropBoxEntryAddedReceiver
04-20 13:39:26.602  1601  1657 W BroadcastQueue: Background execution not allowed: receiving Intent { act=android.intent.action.DROPBOX_ENTRY_ADDED flg=0x10 (has extras) } to com.google.android.gms/.chimera.GmsIntentOperationService$PersistentTrustedReceiver
04-20 13:39:26.605  6362  6362 I Process : Sending signal. PID: 6362 SIG: 9
04-20 13:39:26.605  1601  1643 D EventSequenceValidator: Transition from ACTIVITY_LAUNCHED to ACTIVITY_CANCELLED

From what I see at first sight, the application crash on JNI_onLoad from libencryption.so lib. Imho, that application might be protected against repackaging and tampering (even Java packages have name obfuscation). So I think the issue is not related to anything regarding apktool. But I might be wrong... :man_shrugging:

haykeenss commented 1 year ago

Or is there any security measure against decompiling and building app from playstore, am having exact same issue. After decompiling and rebuild without modification and with no error, i signed it and install on both my device and emulator. app failed to launch.

iBotPeaches commented 1 year ago

Looking at the stacktrace above and replicated below:

04-20 13:39:26.584  6362  6362 E AndroidRuntime: java.lang.UnsatisfiedLinkError: JNI_ERR returned from JNI_OnLoad in "/data/app/~~veJvTrfH-VDiWVhH3XXw7w==/com.weieyu.yalla-LO43q6ygKijskmxwwfc4Qg==/lib/arm64/libencryption.so"
04-20 13:39:26.584  6362  6362 E AndroidRuntime:    at java.lang.Runtime.loadLibrary0(Runtime.java:1087)
04-20 13:39:26.584  6362  6362 E AndroidRuntime:    at java.lang.Runtime.loadLibrary0(Runtime.java:1008)
04-20 13:39:26.584  6362  6362 E AndroidRuntime:    at java.lang.System.loadLibrary(System.java:1664)
04-20 13:39:26.584  6362  6362 E AndroidRuntime:    at com.common.support.encryption.YlEncryption.<clinit>(SourceFile:1)
04-20 13:39:26.584  6362  6362 E AndroidRuntime:    at com.common.support.encryption.YlEncryption.iv(Native Method)
04-20 13:39:26.584  6362  6362 E AndroidRuntime:    at o00o0O0O.oOo0o00.<clinit>(SourceFile:1)
04-20 13:39:26.584  6362  6362 E AndroidRuntime:    at o00o0O0O.oOo0o00.OooO0OO(Unknown Source:0)
04-20 13:39:26.584  6362  6362 E AndroidRuntime:    at o0Oooo0o.o000O0.onChanged(SourceFile:2)
04-20 13:39:26.584  6362  6362 E AndroidRuntime:    at androidx.lifecycle.LiveData.considerNotify(SourceFile:6)
04-20 13:39:26.584  6362  6362 E AndroidRuntime:    at androidx.lifecycle.LiveData.dispatchingValue(SourceFile:5)
04-20 13:39:26.584  6362  6362 E AndroidRuntime:    at androidx.lifecycle.LiveData$ObserverWrapper.activeStateChanged(SourceFile:5)
04-20 13:39:26.584  6362  6362 E AndroidRuntime:    at androidx.lifecycle.LiveData.observeForever(SourceFile:5)
04-20 13:39:26.584  6362  6362 E AndroidRuntime:    at o0Oooo0o.o00O.<clinit>(SourceFile:11)
04-20 13:39:26.584  6362  6362 E AndroidRuntime:    at com.app.base.application.App.onCreate(SourceFile:16)
04-20 13:39:26.584  6362  6362 E AndroidRuntime:    at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1192)
04-20 13:39:26.584  6362  6362 E AndroidRuntime:    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6712)
04-20 13:39:26.584  6362  6362 E AndroidRuntime:    at android.app.ActivityThread.access$1300(ActivityThread.java:237)
04-20 13:39:26.584  6362  6362 E AndroidRuntime:    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1913)
04-20 13:39:26.584  6362  6362 E AndroidRuntime:    at android.os.Handler.dispatchMessage(Handler.java:106)
04-20 13:39:26.584  6362  6362 E AndroidRuntime:    at android.os.Looper.loop(Looper.java:223)
04-20 13:39:26.584  6362  6362 E AndroidRuntime:    at android.app.ActivityThread.main(ActivityThread.java:7656)
04-20 13:39:26.584  6362  6362 E AndroidRuntime:    at java.lang.reflect.Method.invoke(Native Method)
04-20 13:39:26.584  6362  6362 E AndroidRuntime:    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
04-20 13:39:26.584  6362  6362 E AndroidRuntime:    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)

This feels like anti-obfuscation measures. From the obfuscated classes and names regarding encryption - this must be a method to prevent disassembly and rebuilding.

Closing as I don't see Apktool able to do anything here.