0

I tried to make a simple foreground service android application using xamarin... then decompile and inject it into another apk...but it always crashes.

here is adb logcat :

05-31 23:57:34.158  7680  7680 W Activity: Slow Operation: Activity com.injected.app/org.injected.cpp.AppActivity onCreate took 1440ms
05-31 23:57:34.169  7680  7680 D injectedActivity: onResume()
05-31 23:57:34.172  7680  7680 W AudioManager: Use of stream types is deprecated for operations other than volume control
05-31 23:57:34.172 7680  7680 W AudioManager: See the documentation of requestAudioFocus() for what to use instead with android.media.AudioAttributes to qualify your playback use case
05-31 23:57:34.180  7680  7680 D AudioFocusManager: requestAudioFocus succeed
05-31 23:57:34.190  7436  7465 I ui.cloudservic: ProcessProfilingInfo new_methods=0 is saved saved_to_disk=0 resolve_classes_delay=8000
05-31 23:57:34.196  7680  8021 I DpmTcmClient: RegisterTcmMonitor from: $Proxy0
05-31 23:57:34.202  1617  4424 E WindowManager: App trying to use insecure INPUT_FEATURE_NO_INPUT_CHANNEL flag. Ignoring
05-31 23:57:34.208  7680 7680 W Looper  : PerfMonitor longMsg : seq=3 plan=23:57:32.356 late=338ms wall=1514ms running=916ms runnable=174ms io=223ms h=android.app.ActivityThread$H w=159 procState=2
05-31 23:57:34.208  7680  7680 W Looper  : PerfMonitor looperActivity : package=com.injected.app/org.injected.cpp.AppActivity time=1514ms latency=338ms running=916ms  procState=2 ClientTransaction{ callbacks=[android.app.servertransaction.LaunchActivityItem] lifecycleRequest=android.app.servertransaction.ResumeActivityItem } historyMsgCount=2 (msgIndex=2 wall=327ms seq=2 running=05ms runnable=83ms io=8ms late=20ms h=android.app.ActivityThread$H w=110)
05-31 23:57:34.227 28 05 28517 W ocessService0:: Reducing the number of considered missed Gc histogram windows from 162 to 100
05-31 23:57:34.232  7680  7680 W Looper  : PerfMonitor looperActivity : package=com.injected.app/org.injected.cpp.AppActivity time=0ms latency=1875ms running=0ms  procState=2 ClientTransaction{ callbacks=[android.app.servertransaction.TopResumedActivityChangeItem] } historyMsgCount=3 (msgIndex=2 wall=327ms seq=2 running=05ms runnable=83ms io=8ms late=20ms h=android.app.ActivityThread$H w=110) (msgIndex=3 wall=1514ms seq=3 running=916ms runnable=174ms io=223ms late=338ms h=android.app.ActivityThread$H w=159)
05-31 23:57:34.233  7711  8033 I SecurityDevice: getService: sService == null. 
05-31 23:57:34.233  7711  8033 W SecurityDevice: getService: binder not alive. 
05-31 23:57:34.234  7680  7680 E m.injected.app: No implementation found for void mono.android.Runtime.register(java.lang.String, java.lang.Class, java.lang.String) (tried Java_mono_android_Runtime_register and Java_mono_android_Runtime_register__Ljava_lang_String_2Ljava_lang_Class_2Ljava_lang_String_2)
05-31 23:57:34.241  7680  7680 D AndroidRuntime: Shutting down VM
05-31 23:57:34.242  7680  7680 E AndroidRuntime: FATAL EXCEPTION: main
05-31 23:57:34.242  7680  7680 E AndroidRuntime: Process: com.injected.app, PID: 7680
05-31 23:57:34.242  7680  7680 E AndroidRuntime: java.lang.UnsatisfiedLinkError: No implementation found for void mono.android.Runtime.register(java.lang.String, java.lang.Class, java.lang.String) (tried Java_mono_android_Runtime_register and Java_mono_android_Runtime_register__Ljava_lang_String_2Ljava_lang_Class_2Ljava_lang_String_2)
05-31 23:57:34.242  7680  7680 E AndroidRuntime:    at mono.android.Runtime.register(Native Method)
05-31 23:57:34.242  7680  7680 E AndroidRuntime:    at crc6464567c73758a9f18.MainService.<clinit>(MainService.java:18)
05-31 23:57:34.242  7680  7680 E AndroidRuntime:    at java.lang.Class.newInstance(Native Method)
05-31 23:57:34.242  7680  7680 E AndroidRuntime:    at android.app.AppComponentFactory.instantiateService(AppComponentFactory.java:129)
05-31 23:57:34.242  7680  7680 E AndroidRuntime:    at androidx.core.app.CoreComponentFactory.instantiateService(CoreComponentFactory.java:75)
05-31 23:57:34.242  7680  7680 E AndroidRuntime:    at android.app.ActivityThread.handleCreateService(ActivityThread.java:4013)
05-31 23:57:34.242  7680  7680 E AndroidRuntime:    at android.app.ActivityThread.access$1600(ActivityThread.java:229)
05-31 23:57:34.242  7680  7680 E AndroidRuntime:    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1917)
05-31 23:57:34.242  7680  7680 E AndroidRuntime:    at android.os.Handler.dispatchMessage(Handler.java:107)
05-31 23:57:34.242  7680  7680 E AndroidRuntime:    at android.os.Looper.loop(Looper.java:226)
05-31 23:57:34.242  7680  7680 E AndroidRuntime:    at android.app.ActivityThread.main(ActivityThread.java:7592)
05-31 23:57:34.242  7680  7680 E AndroidRuntime:    at java.lang.reflect.Method.invoke(Native Method)
05-31 23:57:34.242  7680  7680 E AndroidRuntime:    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539)
05-31 23:57:34.242  7680  7680 E AndroidRuntime:    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)
05-31 23:57:34.249  3690 14633 I CryptauthV2: [EnrollCryptauthFramework] SyncKeysRequest successfully completed
05-31 23:57:34.251   634  8029 E ResolverController: No valid NAT64 prefix (109, <unspecified>/0)
05-31 23:57:34.263  7974  7974 I FeatureParser: can't find citrus.xml in assets/device_features/,it may be in /vendor/etc/device_features
05-31 23:57:34.266  7680  7680 D OOMEventManagerFK: checkEventAndDumpForJE: 0
05-31 23:57:34.266  7974  7974 I SpaceUtils: owner space
05-31 23:57:34.267  7680  7680 E m.injected.app: No implementation found for void mono.android.Runtime.propagateUncaughtException(java.lang.Thread, java.lang.Throwable) (tried Java_mono_android_Runtime_propagateUncaughtException and Java_mono_android_Runtime_propagateUncaughtException__Ljava_lang_Thread_2Ljava_lang_Throwable_2)
05-31 23:57:34.284  7680  7680 I m.injected.app: Waiting for a blocking GC ProfileSaver
05-31 23:57:34.314  7680  7680 I m.injected.app: WaitForGcToComplete blocked ProfileSaver on ClassLinker for 30.622ms
4
  • Android can not directly execute Xamarin code, that is done by the Mono execution environment which has to be included into the APK file as well. That means the .so files and all the dot net Xamarin dll files needed to be included as well. And it seems you have to properly register Mono engine on Java level. Decompile a standard Xamarin app to see what code you have to add.
    – Robert
    Commented May 31, 2022 at 21:18
  • what if the target apps is made with xamarin too?
    – akunguti
    Commented Jun 1, 2022 at 3:22
  • Then it could happen that the service uses a different code path and thus does not load the native mono libraries. Check the original APK code for System.loadLibrary and similar calls where native libraries are loaded.
    – Robert
    Commented Jun 1, 2022 at 6:58
  • ok, i'll try to check the original APK code for System.loadLibrary. Thanks @Robert
    – akunguti
    Commented Jun 1, 2022 at 8:45

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.