Closed KieronQuinn closed 2 years ago
Load so directly from apk ("!") requires the so file "uncompressed and aligned". I found that android:extractNativeLibs
of com.google.android.as is not set (default value is false), so maybe so files are not "uncompressed and aligned".
You can try extract the so from the apk to somewhere like /data/local/tmp
and set librarySearchPath
to that location.
I had tried that with System.load()
and the extracted .so (which was in /data/local/tmp
, also tried from the sdcard as Shell has access), but it didn't seem to work either, very odd. What did work was copying the native methods into Java classes in my own code, then running it from that - with the same System.loadLibrary("sense")
call.
Unfortunately for me while this solved the "no such implementation" problem, it didn't actually work with the specific call I wanted as it seems to require some setup that's deep within obfuscated code. Instead I've managed to get it to recognise without being a system app, and can feed it audio recorded as Shell via Shizuku, so it will work without root!
Thanks for your help, I'll close this as it's very unlikely anyone else will hit it anyway.
I'm attempting to load an APK using DexClassLoader within the Shizuku service. It all seems to work well and I can call methods (and have also got LSPlant working via Aliucord's Hook library too), but when trying to call JNI from within the APK, it seems to stop working.
My intentions are to try to run the recognition code for Ambient Music within Shell, which in theory would work - I've already got a PoC working as a system app (no Xposed or model loading needed as LSPlant can stop the framework calls and instead trigger it manually), but the ultimate goal is to get it working with just Shizuku. Shell has access to record audio using the hotword mic, but simply recording the audio and sending it back to a client isn't sufficient as there's also something in the recognition (not this crash) that requires being a system app.
Minimal setup:
/data/local/tmp/aiai.apk
. Make sure it is this build, as for this setup we'll be using an obfuscated class name.libsense.so
from the APK into the project as a JNI libI've made the code identical to how Shizuku starts the Java code from a shell service, other than loading the source directory using PackageManager.
I've also tried:
static {}
None of these make any difference, the exception is identical.
I've also verified that the function in the library is exported:
There's no other relevant logcat output either.
What's really strange is that using Hook does work, even though it also uses native libraries in exactly the same way. Those are loaded fine, and methods are hooked without a problem.
Obviously this is quite a specific edge case, so if there's something that prevents this working in the system that simply isn't surfacing in the logcat, I'll happily move on and make the mod require a Magisk module to make it a system app.
Thanks!