KeepSafe/ReLinker

It go wrong on Android M (AVD)

barnett-yuxiang opened this issue · 5 comments

Log as follow:

05-26 15:11:56.804  4747  4747 E art     : No implementation found for java.lang.String com.getkeepsafe.relinker.sample.Native.helloJni() (tried Java_com_getkeepsafe_relinker_sample_Native_helloJni and Java_com_getkeepsafe_relinker_sample_Native_helloJni__)
05-26 15:11:56.805  4747  4747 D ReLinker: Beginning load of hellojni...
05-26 15:11:56.826  4747  4764 D ReLinker: Loading the library normally failed: java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.getkeepsafe.relinker.sample-1/base.apk"],nativeLibraryDirectories=[/data/app/com.getkeepsafe.relinker.sample-1/lib/x86, /data/app/com.getkeepsafe.relinker.sample-1/base.apk!/lib/x86, /vendor/lib, /system/lib]]] couldn't find "libhellojni.so"
05-26 15:11:56.826  4747  4764 D ReLinker:  at java.lang.Runtime.loadLibrary(Runtime.java:367)
05-26 15:11:56.826  4747  4764 D ReLinker:  at java.lang.System.loadLibrary(System.java:1076)
05-26 15:11:56.826  4747  4764 D ReLinker:  at com.getkeepsafe.relinker.SystemLibraryLoader.loadLibrary(SystemLibraryLoader.java:24)
05-26 15:11:56.826  4747  4764 D ReLinker:  at com.getkeepsafe.relinker.ReLinkerInstance.loadLibraryInternal(ReLinkerInstance.java:163)
05-26 15:11:56.826  4747  4764 D ReLinker:  at com.getkeepsafe.relinker.ReLinkerInstance.access$000(ReLinkerInstance.java:31)
05-26 15:11:56.826  4747  4764 D ReLinker:  at com.getkeepsafe.relinker.ReLinkerInstance$1.run(ReLinkerInstance.java:142)
05-26 15:11:56.826  4747  4764 D ReLinker:  at java.lang.Thread.run(Thread.java:818)
05-26 15:11:56.826  4747  4764 D ReLinker: hellojni (1.0) was not loaded normally, re-linking...
05-26 15:11:56.826  4747  4764 D ReLinker: yuxiang getWorkaroundLibFile: /data/user/0/com.getkeepsafe.relinker.sample/app_lib/libhellojni.so.1.0
05-26 15:11:56.826  4747  4764 D ReLinker: Forcing a re-link of hellojni (1.0)...
05-26 15:11:56.827  4747  4764 D ReLinker: Looking for lib/x86/libhellojni.so in APK...
05-26 15:11:56.827  4747  4764 D ReLinker: Found lib/x86/libhellojni.so! Extracting...
05-26 15:11:56.834  4747  4764 D ReLinker: Beginning load of hello...
05-26 15:11:56.834  4747  4764 D ReLinker: Loading the library normally failed: java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.getkeepsafe.relinker.sample-1/base.apk"],nativeLibraryDirectories=[/data/app/com.getkeepsafe.relinker.sample-1/lib/x86, /data/app/com.getkeepsafe.relinker.sample-1/base.apk!/lib/x86, /vendor/lib, /system/lib]]] couldn't find "libhello.so"
05-26 15:11:56.834  4747  4764 D ReLinker:  at java.lang.Runtime.loadLibrary(Runtime.java:367)
05-26 15:11:56.834  4747  4764 D ReLinker:  at java.lang.System.loadLibrary(System.java:1076)
05-26 15:11:56.834  4747  4764 D ReLinker:  at com.getkeepsafe.relinker.SystemLibraryLoader.loadLibrary(SystemLibraryLoader.java:24)
05-26 15:11:56.834  4747  4764 D ReLinker:  at com.getkeepsafe.relinker.ReLinkerInstance.loadLibraryInternal(ReLinkerInstance.java:163)
05-26 15:11:56.834  4747  4764 D ReLinker:  at com.getkeepsafe.relinker.ReLinkerInstance.loadLibrary(ReLinkerInstance.java:136)
05-26 15:11:56.834  4747  4764 D ReLinker:  at com.getkeepsafe.relinker.ReLinkerInstance.loadLibrary(ReLinkerInstance.java:92)
05-26 15:11:56.834  4747  4764 D ReLinker:  at com.getkeepsafe.relinker.ReLinkerInstance.loadLibraryInternal(ReLinkerInstance.java:190)
05-26 15:11:56.834  4747  4764 D ReLinker:  at com.getkeepsafe.relinker.ReLinkerInstance.access$000(ReLinkerInstance.java:31)
05-26 15:11:56.834  4747  4764 D ReLinker:  at com.getkeepsafe.relinker.ReLinkerInstance$1.run(ReLinkerInstance.java:142)
05-26 15:11:56.834  4747  4764 D ReLinker:  at java.lang.Thread.run(Thread.java:818)
05-26 15:11:56.834  4747  4764 D ReLinker: hello (null) was not loaded normally, re-linking...
05-26 15:11:56.834  4747  4764 D ReLinker: yuxiang getWorkaroundLibFile: /data/user/0/com.getkeepsafe.relinker.sample/app_lib/libhello.so
05-26 15:11:56.834  4747  4764 D ReLinker: Forcing a re-link of hello (null)...
05-26 15:11:56.835  4747  4764 D ReLinker: Looking for lib/x86/libhello.so in APK...
05-26 15:11:56.835  4747  4764 D ReLinker: Found lib/x86/libhello.so! Extracting...
05-26 15:11:56.854  4747  4764 D ReLinker: Beginning load of stdc++...
05-26 15:11:56.857  4747  4764 D ReLinker: stdc++ (null) was loaded normally!
05-26 15:11:56.857  4747  4764 D ReLinker: Beginning load of m...
05-26 15:11:56.887  4747  4764 D ReLinker: m (null) was loaded normally!
05-26 15:11:56.887  4747  4764 D ReLinker: Beginning load of c...
05-26 15:11:56.887  4747  4764 D ReLinker: c (null) was loaded normally!
05-26 15:11:56.887  4747  4764 D ReLinker: Beginning load of dl...
05-26 15:11:56.920  4747  4764 D ReLinker: Loading the library normally failed: java.lang.UnsatisfiedLinkError: dlopen failed: cannot locate symbol "__cxa_finalize" referenced by "/system/lib/libdl.so"...
05-26 15:11:56.920  4747  4764 D ReLinker:  at java.lang.Runtime.loadLibrary(Runtime.java:372)
05-26 15:11:56.920  4747  4764 D ReLinker:  at java.lang.System.loadLibrary(System.java:1076)
05-26 15:11:56.920  4747  4764 D ReLinker:  at com.getkeepsafe.relinker.SystemLibraryLoader.loadLibrary(SystemLibraryLoader.java:24)
05-26 15:11:56.920  4747  4764 D ReLinker:  at com.getkeepsafe.relinker.ReLinkerInstance.loadLibraryInternal(ReLinkerInstance.java:163)
05-26 15:11:56.920  4747  4764 D ReLinker:  at com.getkeepsafe.relinker.ReLinkerInstance.loadLibrary(ReLinkerInstance.java:136)
05-26 15:11:56.920  4747  4764 D ReLinker:  at com.getkeepsafe.relinker.ReLinkerInstance.loadLibrary(ReLinkerInstance.java:92)
05-26 15:11:56.920  4747  4764 D ReLinker:  at com.getkeepsafe.relinker.ReLinkerInstance.loadLibraryInternal(ReLinkerInstance.java:190)
05-26 15:11:56.920  4747  4764 D ReLinker:  at com.getkeepsafe.relinker.ReLinkerInstance.loadLibrary(ReLinkerInstance.java:136)
05-26 15:11:56.920  4747  4764 D ReLinker:  at com.getkeepsafe.relinker.ReLinkerInstance.loadLibrary(ReLinkerInstance.java:92)
05-26 15:11:56.920  4747  4764 D ReLinker:  at com.getkeepsafe.relinker.ReLinkerInstance.loadLibraryInternal(ReLinkerInstance.java:190)
05-26 15:11:56.920  4747  4764 D ReLinker:  at com.getkeepsafe.relinker.ReLinkerInstance.access$000(ReLinkerInstance.java:31)
05-26 15:11:56.920  4747  4764 D ReLinker:  at com.getkeepsafe.relinker.ReLinkerInstance$1.run(ReLinkerInstance.java:142)
05-26 15:11:56.920  4747  4764 D ReLinker:  at java.lang.Thread.run(Thread.java:818)
05-26 15:11:56.920  4747  4764 D ReLinker: dl (null) was not loaded normally, re-linking...
05-26 15:11:56.920  4747  4764 D ReLinker: yuxiang getWorkaroundLibFile: /data/user/0/com.getkeepsafe.relinker.sample/app_lib/libdl.so
05-26 15:11:56.920  4747  4764 D ReLinker: Forcing a re-link of dl (null)...
05-26 15:11:56.921  4747  4764 D ReLinker: Looking for lib/x86/libdl.so in APK...
05-26 15:11:59.895  1263  1325 D hwcomposer: hw_composer sent 825 syncs in 60s

/app_lib is created in Android OS

    @Override
    public File getDir(String name, int mode) {
        name = "app_" + name;
        File file = makeFilename(getDataDirFile(), name);
        if (!file.exists()) {
            file.mkdir();
            setFilePermissionsFromMode(file.getPath(), mode,
                    FileUtils.S_IRWXU|FileUtils.S_IRWXG|FileUtils.S_IXOTH);
        }
        return file;
    }

i print DexListPath

((BaseDexClassLoader) MainActivity.class.getClassLoader()).toString()
 
// KK
dalvik.system.PathClassLoader[DexPathList[[zip file    "/data/app/com.getkeepsafe.relinker.sample-2.apk"],
                              nativeLibraryDirectories=[/data/app-lib/com.getkeepsafe.relinker.sample-2,
                                                        /system/lib]]]
// M
dalvik.system.PathClassLoader[DexPathList[[zip file    "/data/app/com.getkeepsafe.relinker.sample-2/base.apk"],
                              nativeLibraryDirectories=[
                                                        /data/app/com.getkeepsafe.relinker.sample-2/lib/x86,
                                                        /data/app/com.getkeepsafe.relinker.sample-2/base.apk!/lib/x86,
                                                        /vendor/lib,
                                                        /system/lib]]]

Hi,
You can delete recursively and test again. "libdl.so" can't be loaded successfully. I think the recursive function is not needed.

ajalt commented

Closing due to inactivity. If you still have questions, I can reopen the issue.

so recursive function is important or not?