ClaudiuGeorgiu / Obfuscapk

An automatic obfuscation tool for Android apps that works in a black-box fashion, supports advanced obfuscation features and has a modular architecture easily extensible with new techniques
MIT License
1.11k stars 288 forks source link

Kotlin coroutine Error after obfuscation #76

Closed TanWeiQi1800860 closed 3 years ago

TanWeiQi1800860 commented 3 years ago

Prerequisites

Before opening this issue, I tried the following steps:

Description

Steps to reproduce

  1. Run python -m obfuscapk.cli -o AssetEncryption -o DebugRemoval -o ArithmeticBranch -o LibEncryption -o ResStringEncryption -o Goto -o RandomManifest -o Rebuild -o NewSignature -o NewAlignment -i -p app-debug.apk
  2. Install app-debug_obfuscated.apk on the emulator (Warning: Do not install on your real device)
  3. Complete registration
  4. Login with the information you registered with
  5. App will crash

Expected behavior:

The obfuscation should complete without any error message and the obfuscated apk should not crash the program.

Actual behavior:

The obfuscation completes without errors, but when I install the obfuscated apk into a device, it crashes when a coroutines is activated.

FATAL EXCEPTION: main
    Process: edu.sunypoly.a2048, PID: 19971
    java.lang.IllegalStateException: Module with the Main dispatcher is missing. Add dependency providing the Main dispatcher, e.g. 'kotlinx-coroutines-android'
        at kotlinx.coroutines.internal.o.o(SourceFile:72)
        at kotlinx.coroutines.internal.o.m(SourceFile:53)
        at kotlinx.coroutines.c0.b(SourceFile:116)
        at kotlinx.coroutines.l1.a.a(SourceFile:25)
        at kotlinx.coroutines.v.a(SourceFile:109)
        at kotlinx.coroutines.a.k0(SourceFile:154)
        at kotlinx.coroutines.d.a(SourceFile:54)
        at kotlinx.coroutines.c.a(SourceFile:1)
        at kotlinx.coroutines.d.b(SourceFile:47)
        at kotlinx.coroutines.c.b(SourceFile:1)
        at edu.sunypoly.a2048.MainActivity.onCreate(SourceFile:178)
        at android.app.Activity.performCreate(Activity.java:7802)
        at android.app.Activity.performCreate(Activity.java:7791)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1299)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3245)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3409)
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2016)
        at android.os.Handler.dispatchMessage(Handler.java:107)
        at android.os.Looper.loop(Looper.java:214)
        at android.app.ActivityThread.main(ActivityThread.java:7356)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)

Versions

Additional information

Apk file(s):--

thomyfarhan commented 2 years ago

How to solve this issue?

thomyfarhan commented 2 years ago

in Proguard add: -keep class kotlinx.coroutines.** {*;}

in \src\obfuscapk\resources\libs_to_ignore.txt add: kotlinx/coroutines/