ReVanced / revanced-patches

🧩 Patches for ReVanced
https://revanced.app
GNU General Public License v3.0
2.43k stars 282 forks source link

bug: (TikTok): `SIM spoof` patch causing TikTok can not started #2891

Closed cyberboh closed 7 months ago

cyberboh commented 7 months ago

Bug description

  1. Patch with Revanced CLI with SIM spoof patch included:

java -jar revanced-cli-4.6.0-dev.1-all.jar patch -p -o Install\TikTok_32.5.3-all_ReVanced.apk --options options.json -b revanced-patches-4.4.0-dev.8.jar --keystore-entry-alias=******** --keystore-password=******** --keystore-entry-password=******** --keystore=********.keystore -m revanced-integrations-1.5.0-dev.6.apk Apps\com.ss.android.ugc.trill-32.5.3-all.apk -i "SIM spoof"

  1. Delete old TikTok and install newly patched
  2. Open it. It will crash

Error logs

03-17 15:39:22.567 27389 27433 E AndroidRuntime: FATAL EXCEPTION: tp-default-7
03-17 15:39:22.567 27389 27433 E AndroidRuntime: Process: com.ss.android.ugc.trill, PID: 27389
03-17 15:39:22.567 27389 27433 E AndroidRuntime: java.lang.ExceptionInInitializerError
03-17 15:39:22.567 27389 27433 E AndroidRuntime:    at app.revanced.integrations.shared.settings.BaseSettings.<clinit>(BaseSettings.java:14)
03-17 15:39:22.567 27389 27433 E AndroidRuntime:    at app.revanced.integrations.tiktok.spoof.sim.SpoofSimPatch.isEnable(SpoofSimPatch.java:8)
03-17 15:39:22.567 27389 27433 E AndroidRuntime:    at app.revanced.integrations.tiktok.spoof.sim.SpoofSimPatch.getCountryIso(SpoofSimPatch.java:11)
03-17 15:39:22.567 27389 27433 E AndroidRuntime:    at kotlin.jvm.internal.ApS191S0100000_6.invoke$54(SourceFile:33554445)
03-17 15:39:22.567 27389 27433 E AndroidRuntime:    at kotlin.jvm.internal.ApS191S0100000_6.invoke(Unknown Source:314)
03-17 15:39:22.567 27389 27433 E AndroidRuntime:    at kotlin.jvm.internal.ApS141S0200000_6.invoke$6(SourceFile:33554464)
03-17 15:39:22.567 27389 27433 E AndroidRuntime:    at kotlin.jvm.internal.ApS141S0200000_6.invoke(Unknown Source:146)
03-17 15:39:22.567 27389 27433 E AndroidRuntime:    at kotlin.jvm.internal.ApS166S0200000_15.invoke$113(SourceFile:16777224)
03-17 15:39:22.567 27389 27433 E AndroidRuntime:    at kotlin.jvm.internal.ApS166S0200000_15.invoke(Unknown Source:7)
03-17 15:39:22.567 27389 27433 E AndroidRuntime:    at X.Y8h.LIZ(SourceFile:33554444)
03-17 15:39:22.567 27389 27433 E AndroidRuntime:    at kotlin.jvm.internal.ApS150S0200000_15.invoke$71(SourceFile:33554691)
03-17 15:39:22.567 27389 27433 E AndroidRuntime:    at kotlin.jvm.internal.ApS150S0200000_15.invoke(Unknown Source:58)
03-17 15:39:22.567 27389 27433 E AndroidRuntime:    at X.Y8h.LIZIZ(SourceFile:67108883)
03-17 15:39:22.567 27389 27433 E AndroidRuntime:    at com.bytedance.bpea.core.checker.CorePowerProvider.check(SourceFile:33554448)
03-17 15:39:22.567 27389 27433 E AndroidRuntime:    at X.Ffm.LIZ(SourceFile:33554447)
03-17 15:39:22.567 27389 27433 E AndroidRuntime:    at X.FfU.LIZLLL(SourceFile:33554461)
03-17 15:39:22.567 27389 27433 E AndroidRuntime:    at kotlin.jvm.internal.ApS175S0100000_6.invoke$133(SourceFile:16777227)
03-17 15:39:22.567 27389 27433 E AndroidRuntime:    at kotlin.jvm.internal.ApS175S0100000_6.invoke(Unknown Source:182)
03-17 15:39:22.567 27389 27433 E AndroidRuntime:    at X.Fc8.LIZ(SourceFile:50331665)
03-17 15:39:22.567 27389 27433 E AndroidRuntime:    at X.FfU.LJ(SourceFile:16777236)
03-17 15:39:22.567 27389 27433 E AndroidRuntime:    at X.Z0N.LJ(SourceFile:45)
03-17 15:39:22.567 27389 27433 E AndroidRuntime:    at X.Z0N.LIZIZ(SourceFile:0)
03-17 15:39:22.567 27389 27433 E AndroidRuntime:    at X.YdR.LIZIZ(SourceFile:191)
03-17 15:39:22.567 27389 27433 E AndroidRuntime:    at X.YdR.<clinit>(SourceFile:0)
03-17 15:39:22.567 27389 27433 E AndroidRuntime:    at X.Yby.<clinit>(SourceFile:151)
03-17 15:39:22.567 27389 27433 E AndroidRuntime:    at com.ss.android.ugc.aweme.legoImp.task.StoreRegionInitTask.run(SourceFile:16777233)
03-17 15:39:22.567 27389 27433 E AndroidRuntime:    at X.DPh.LJFF(SourceFile:16777307)
03-17 15:39:22.567 27389 27433 E AndroidRuntime:    at X.DPO.LIZJ(SourceFile:16777223)
03-17 15:39:22.567 27389 27433 E AndroidRuntime:    at Y.ARunnableS27S0200000_6.run$84(SourceFile:16777241)
03-17 15:39:22.567 27389 27433 E AndroidRuntime:    at Y.ARunnableS27S0200000_6.run(Unknown Source:118)
03-17 15:39:22.567 27389 27433 E AndroidRuntime:    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
03-17 15:39:22.567 27389 27433 E AndroidRuntime:    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
03-17 15:39:22.567 27389 27433 E AndroidRuntime:    at Y.ARunnableS36S0200000_15.run$90(SourceFile:16777230)
03-17 15:39:22.567 27389 27433 E AndroidRuntime:    at Y.ARunnableS36S0200000_15.run(Unknown Source:314)
03-17 15:39:22.567 27389 27433 E AndroidRuntime:    at java.lang.Thread.run(Thread.java:929)
03-17 15:39:22.567 27389 27433 E AndroidRuntime: Caused by: java.lang.NullPointerException
03-17 15:39:22.567 27389 27433 E AndroidRuntime:    at java.util.Objects.requireNonNull(Objects.java:203)
03-17 15:39:22.567 27389 27433 E AndroidRuntime:    at app.revanced.integrations.shared.settings.preference.SharedPrefCategory.<init>(SharedPrefCategory.java:30)
03-17 15:39:22.567 27389 27433 E AndroidRuntime:    at app.revanced.integrations.shared.settings.Setting.<clinit>(Setting.java:79)
03-17 15:39:22.567 27389 27433 E AndroidRuntime:    ... 35 more

Solution

Disable SIM spoof patch

Additional context

This tested on Android 10 device.

Acknowledgements

LisoUseInAIKyrios commented 7 months ago

It appears Utils.context is not set before the first call to Settings. The context is set by the TikTok integrations patch.

Can you confirm that patching with main release cause the same issue?

cyberboh commented 7 months ago

It appears Utils.context is not set before the first call to Settings. The context is set by the TikTok integrations patch.

Can you confirm that patching with main release cause the same issue?

Yes, main release is working. But i get this error in main release https://github.com/ReVanced/revanced-patches/issues/2879

LisoUseInAIKyrios commented 7 months ago

I am not able to reproduce the issue with the latest dev release - TikTok SIM spoof works correctly, and no crash is observed.

But I also don't use TikTok or have an account.

Post the full debug logs. You'll need to:

cyberboh commented 7 months ago

I am not able to reproduce the issue with the latest dev release - TikTok SIM spoof works correctly, and no crash is observed.

But I also don't use TikTok or have an account.

Post the full debug logs. You'll need to:

* Patch and install without `SIM spoof`

* Enable debug loggin in TikTok ReVanced settings

* Repatch and install with `SIM spoof`

* clear the logs using adb (`adb logcat -c`)

* launch the app, let it crash

* collect the logs via ADB

With this way, it does not crash. It crash only on fresh install.

I just tried clear data of installed TikTok, and it crashes.

03-18 04:37:44.937 25220 25220 W System.err: java.lang.NoSuchFieldException
03-18 04:37:44.937 25220 25220 W System.err:    at X.ALc.LIZLLL(SourceFile:33554456)
03-18 04:37:44.937 25220 25220 W System.err:    at X.ALc.LIZJ(SourceFile:33554432)
03-18 04:37:44.937 25220 25220 W System.err:    at com.ss.android.ugc.aweme.sp.SharedPreferencesManager.getSharedPreferences(SourceFile:33554532)
03-18 04:37:44.937 25220 25220 W System.err:    at X.Dhn.LIZ(SourceFile:50331702)
03-18 04:37:44.937 25220 25220 W System.err:    at X.Dhn.LIZIZ(SourceFile:50331683)
03-18 04:37:44.937 25220 25220 W System.err:    at X.DnW.LIZIZ(SourceFile:16777219)
03-18 04:37:44.937 25220 25220 W System.err:    at X.DnW.LIZ(SourceFile:16777216)
03-18 04:37:44.937 25220 25220 W System.err:    at X.DnW.LIZJ(SourceFile:16777264)
03-18 04:37:44.937 25220 25220 W System.err:    at X.Dcq.LIZ(SourceFile:16777523)
03-18 04:37:44.937 25220 25220 W System.err:    at com.ss.android.ugc.aweme.app.host.AwemeHostApplication.attachBaseContext(SourceFile:16777385)
03-18 04:37:44.937 25220 25220 W System.err:    at android.app.Application.attach(Application.java:358)
03-18 04:37:44.937 25220 25220 W System.err:    at android.app.Instrumentation.newApplication(Instrumentation.java:1168)
03-18 04:37:44.937 25220 25220 W System.err:    at android.app.LoadedApk.makeApplication(LoadedApk.java:1451)
03-18 04:37:44.937 25220 25220 W System.err:    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:7554)
03-18 04:37:44.937 25220 25220 W System.err:    at android.app.ActivityThread.access$2600(ActivityThread.java:260)
03-18 04:37:44.937 25220 25220 W System.err:    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2435)
03-18 04:37:44.937 25220 25220 W System.err:    at android.os.Handler.dispatchMessage(Handler.java:110)
03-18 04:37:44.937 25220 25220 W System.err:    at android.os.Looper.loop(Looper.java:219)
03-18 04:37:44.937 25220 25220 W System.err:    at android.app.ActivityThread.main(ActivityThread.java:8668)
03-18 04:37:44.937 25220 25220 W System.err:    at java.lang.reflect.Method.invoke(Native Method)
03-18 04:37:44.937 25220 25220 W System.err:    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:513)
03-18 04:37:44.937 25220 25220 W System.err:    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1109)
03-18 04:37:44.939 25220 25220 W System.err: method id config:
03-18 04:37:44.979 25220 25220 E AndroidRuntime: FATAL EXCEPTION: main
03-18 04:37:44.979 25220 25220 E AndroidRuntime: Process: com.ss.android.ugc.trill, PID: 25220
03-18 04:37:44.979 25220 25220 E AndroidRuntime: java.lang.NoClassDefFoundError: app.revanced.integrations.shared.settings.BaseSettings
03-18 04:37:44.979 25220 25220 E AndroidRuntime:    at app.revanced.integrations.shared.Logger.printDebug(Logger.java:61)
03-18 04:37:44.979 25220 25220 E AndroidRuntime:    at app.revanced.integrations.shared.Utils.setContext(Utils.java:238)
03-18 04:37:44.979 25220 25220 E AndroidRuntime:    at com.ss.android.ugc.aweme.app.host.AwemeHostApplication.onCreate(Unknown Source:0)
03-18 04:37:44.979 25220 25220 E AndroidRuntime:    at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1202)
03-18 04:37:44.979 25220 25220 E AndroidRuntime:    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:7588)
03-18 04:37:44.979 25220 25220 E AndroidRuntime:    at android.app.ActivityThread.access$2600(ActivityThread.java:260)
03-18 04:37:44.979 25220 25220 E AndroidRuntime:    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2435)
03-18 04:37:44.979 25220 25220 E AndroidRuntime:    at android.os.Handler.dispatchMessage(Handler.java:110)
03-18 04:37:44.979 25220 25220 E AndroidRuntime:    at android.os.Looper.loop(Looper.java:219)
03-18 04:37:44.979 25220 25220 E AndroidRuntime:    at android.app.ActivityThread.main(ActivityThread.java:8668)
03-18 04:37:44.979 25220 25220 E AndroidRuntime:    at java.lang.reflect.Method.invoke(Native Method)
03-18 04:37:44.979 25220 25220 E AndroidRuntime:    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:513)
03-18 04:37:44.979 25220 25220 E AndroidRuntime:    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1109)
03-18 04:37:44.979 25220 25220 E AndroidRuntime: Caused by: java.lang.ExceptionInInitializerError
03-18 04:37:44.979 25220 25220 E AndroidRuntime:    at app.revanced.integrations.shared.settings.BaseSettings.<clinit>(BaseSettings.java:14)
03-18 04:37:44.979 25220 25220 E AndroidRuntime:    at app.revanced.integrations.tiktok.spoof.sim.SpoofSimPatch.isEnable(SpoofSimPatch.java:8)
03-18 04:37:44.979 25220 25220 E AndroidRuntime:    at app.revanced.integrations.tiktok.spoof.sim.SpoofSimPatch.getCountryIso(SpoofSimPatch.java:11)
03-18 04:37:44.979 25220 25220 E AndroidRuntime:    at kotlin.jvm.internal.ApS191S0100000_6.invoke$54(SourceFile:33554445)
03-18 04:37:44.979 25220 25220 E AndroidRuntime:    at kotlin.jvm.internal.ApS191S0100000_6.invoke(Unknown Source:314)
03-18 04:37:44.979 25220 25220 E AndroidRuntime:    at kotlin.jvm.internal.ApS141S0200000_6.invoke$6(SourceFile:33554464)
03-18 04:37:44.979 25220 25220 E AndroidRuntime:    at kotlin.jvm.internal.ApS141S0200000_6.invoke(Unknown Source:146)
03-18 04:37:44.979 25220 25220 E AndroidRuntime:    at kotlin.jvm.internal.ApS166S0200000_15.invoke$113(SourceFile:16777224)
03-18 04:37:44.979 25220 25220 E AndroidRuntime:    at kotlin.jvm.internal.ApS166S0200000_15.invoke(Unknown Source:7)
03-18 04:37:44.979 25220 25220 E AndroidRuntime:    at X.Y8h.LIZ(SourceFile:33554444)
03-18 04:37:44.979 25220 25220 E AndroidRuntime:    at kotlin.jvm.internal.ApS150S0200000_15.invoke$71(SourceFile:33554691)
03-18 04:37:44.979 25220 25220 E AndroidRuntime:    at kotlin.jvm.internal.ApS150S0200000_15.invoke(Unknown Source:58)
03-18 04:37:44.979 25220 25220 E AndroidRuntime:    at X.Y8h.LIZIZ(SourceFile:67108883)
03-18 04:37:44.979 25220 25220 E AndroidRuntime:    at com.bytedance.bpea.core.checker.CorePowerProvider.check(SourceFile:33554448)
03-18 04:37:44.979 25220 25220 E AndroidRuntime:    at X.Ffm.LIZ(SourceFile:33554447)
03-18 04:37:44.979 25220 25220 E AndroidRuntime:    at X.FfU.LIZLLL(SourceFile:33554461)
03-18 04:37:44.979 25220 25220 E AndroidRuntime:    at kotlin.jvm.internal.ApS175S0100000_6.invoke$133(SourceFile:16777227)
03-18 04:37:44.979 25220 25220 E AndroidRuntime:    at kotlin.jvm.internal.ApS175S0100000_6.invoke(Unknown Source:182)
03-18 04:37:44.979 25220 25220 E AndroidRuntime:    at X.Fc8.LIZ(SourceFile:50331665)
03-18 04:37:44.979 25220 25220 E AndroidRuntime:    at X.FfU.LJ(SourceFile:16777236)
03-18 04:37:44.979 25220 25220 E AndroidRuntime:    at X.Z0N.LJ(SourceFile:45)
03-18 04:37:44.979 25220 25220 E AndroidRuntime:    at X.Z0N.LIZIZ(SourceFile:0)
03-18 04:37:44.979 25220 25220 E AndroidRuntime:    at X.YdR.LIZIZ(SourceFile:191)
03-18 04:37:44.979 25220 25220 E AndroidRuntime:    at X.YdR.<clinit>(SourceFile:0)
03-18 04:37:44.979 25220 25220 E AndroidRuntime:    at X.Yby.<clinit>(SourceFile:151)
03-18 04:37:44.979 25220 25220 E AndroidRuntime:    at com.ss.android.ugc.aweme.legoImp.task.StoreRegionInitTask.run(SourceFile:16777233)
03-18 04:37:44.979 25220 25220 E AndroidRuntime:    at X.DPh.LJFF(SourceFile:16777307)
03-18 04:37:44.979 25220 25220 E AndroidRuntime:    at X.DPO.LIZJ(SourceFile:16777223)
03-18 04:37:44.979 25220 25220 E AndroidRuntime:    at Y.ARunnableS27S0200000_6.run$84(SourceFile:16777241)
03-18 04:37:44.979 25220 25220 E AndroidRuntime:    at Y.ARunnableS27S0200000_6.run(Unknown Source:118)
03-18 04:37:44.979 25220 25220 E AndroidRuntime:    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
03-18 04:37:44.979 25220 25220 E AndroidRuntime:    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
03-18 04:37:44.979 25220 25220 E AndroidRuntime:    at Y.ARunnableS36S0200000_15.run$90(SourceFile:16777230)
03-18 04:37:44.979 25220 25220 E AndroidRuntime:    at Y.ARunnableS36S0200000_15.run(Unknown Source:314)
03-18 04:37:44.979 25220 25220 E AndroidRuntime:    at java.lang.Thread.run(Thread.java:929)
03-18 04:37:44.979 25220 25220 E AndroidRuntime: Caused by: java.lang.NullPointerException
03-18 04:37:44.979 25220 25220 E AndroidRuntime:    at java.util.Objects.requireNonNull(Objects.java:203)
03-18 04:37:44.979 25220 25220 E AndroidRuntime:    at app.revanced.integrations.shared.settings.preference.SharedPrefCategory.<init>(SharedPrefCategory.java:30)
03-18 04:37:44.979 25220 25220 E AndroidRuntime:    at app.revanced.integrations.shared.settings.Setting.<clinit>(Setting.java:79)
03-18 04:37:44.979 25220 25220 E AndroidRuntime:    ... 35 more

Log file: logcat.txt

oSumAtrIX commented 7 months ago

Did you merge integrations?

LisoUseInAIKyrios commented 7 months ago

Integrations looks to be included because the stack trace shows calls into integrations that are more than 1 level deep.

@cyberboh try uninstalling ReVanced TikTok, then patch and installing the main release, just to completely verify the issue is something with the dev release or if it affects both main and dev.

Because I don't see why just dev would have this issue, and it looks like the spoof sim hook is getting called before the integrations hook can set the context (which should have nothing to do with the changes on dev).

cyberboh commented 7 months ago

@oSumAtrIX Yes, already merged it.

@LisoUseInAIKyrios Main release is fine. Only dev release error appear. I'll try figure out which dev release started causing this error by merged dev release one by one

LisoUseInAIKyrios commented 7 months ago

The only dev change that might cause the issue, is the changes in patches v4.4.0-dev.3 and the associated integrations release.

LisoUseInAIKyrios commented 7 months ago

The issue started acting up for me just now, and the fix is two changes. Will PR soon.

LisoUseInAIKyrios commented 7 months ago

@cyberboh try again with the latest dev

cyberboh commented 7 months ago

@cyberboh try again with the latest dev

Personally tested. Working perfectly on my device running android 10. Great job. 🙏