Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Native library not found on android pie #2490

Open
blackfa1con opened this issue Jan 1, 2021 · 4 comments
Open

[BUG] Native library not found on android pie #2490

blackfa1con opened this issue Jan 1, 2021 · 4 comments

Comments

@blackfa1con
Copy link

blackfa1con commented Jan 1, 2021

Information

  1. Apktool Version (2.5.0) -
  2. Operating System (Linux, Windows) -
  3. APK From? (Other) -

Stacktrace/Logcat

2021-01-01 16:25:05.626 3760-3760/? E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.xxx.xxxx, PID: 3760
    java.lang.UnsatisfiedLinkError: dlopen failed: library "/system/priv-app/xxxx/xxxxx.apk!/lib/arm64-v8a/xxxxx.so" not found
        at java.lang.Runtime.loadLibrary0(Runtime.java:1016)
        at java.lang.System.loadLibrary(System.java:1669)


Steps to Reproduce

  1. apktool
  2. Unpack the Original apk.
  3. Repack the apk and resign it.

Diagnose the problem

  1. Use apk tool (last version) and unpack then repack and sign without edit files.
  2. Diagnosis the problem.
  3. We find that the order when packing files into apk is important.
  4. When open the original apk by hex we see the first file in package is classes.
  5. When open the repacked apk by hex we see the first file in package is resources.
    original

repacked

Frameworks

If this APK is from an OEM ROM (Samsung, HTC, LG). Please attach framework files
(.apks that live in /system/framework or /system/priv-app)

APK

If this APK can be freely shared, please upload/attach a link to it.

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
@iBotPeaches
Copy link
Owner

We find that the order when packing files into apk is important.

How did you come to this conclusion? We leverage aapt/aapt2 to package the application and if order mattered - it would do it.

@blackfa1con
Copy link
Author

We find that the order when packing files into apk is important.

How did you come to this conclusion? We leverage aapt/aapt2 to package the application and if order mattered - it would do it.

When i resign the package only in windows, this break the native lib and the system give the error "dlopen failed".
then i moved to linux and used the apksigner, the error doesn't appear.

After compare the two files, original and resigned package i see the order difference.
Anyway i try to use apktool in linux, without resign package, the error back again and i can't use the new package after resign with apksigner/linux.

@Comnir
Copy link
Contributor

Comnir commented Jan 9, 2021

@blackfa1con , maybe it's related to extractNativeLibs in AndroidManifest.xml? It is set to "false" by default since Android Gradle plugin 3.6.0.
If it's compressed by Apktool, it might be related.

But you also say "When i resign the package only in windows, this break the native lib", so it means this problem occurs also without Apktool being involved?

@pashamcr
Copy link
Contributor

pashamcr commented Jan 9, 2021

@blackfa1con this is not an apktool bug

  1. The application is not installed correctly in /system/priv-app, the native library can be put next to it, i.e. So:
    /system/priv-app/xxxx/lib/arm64/xxxxx.so
  2. The application is not compiled correctly for installation in /system/priv-app, add to apktool.yml:
doNotCompress:
- lib/arm64-v8a/xxxxx.so

in addition, it is desirable to include classes.dex here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants