0

I've an application which has 32 bit native libraries. When I'm reinstalling the same app with 64-bit libraries, It's unable to create lib softlink which is present in data/data/application-package-name.

This lib softlink maps to data/app/app-package-name-hash/arm(in 32bit) or data/app/app-package-name-hash/arm64(in 64bit)

What's the problem?

Android build system is unable to create lib softlink inside the data/data/app_package_name which maps to data/app/app-package-name-hash/arm(in 32bit) or data/app/app-package-name-hash/arm64(in 64bit)

What error are you seeing? My native code isn’t able to find a file in the shared object which should be inside data/data/app_package_name/lib, hence giving unable to open file error

32-bit strucuture in data/data/application-package-name soft link lib is present which maps to legacyNativeLibraryDir/arm

64-bit strucuture in data/data/application-package-name soft link lib is missing, despite legacyNativeLibraryDir/arm64 being present

Project strucuture Project strucuture for 32 bit Project strucuture for 64 bit Referenced: https://stackoverflow.com/a/27523384/5047036

  • What's the problem? What error are you seeing? What do you expect to see? What does your project look like (build.gradle, CMakeLists.txt/Android.mk, etc)? There isn't enough information here for people to know what's wrong. – Dan Albert Jul 11 '19 at 07:35
  • @DanAlbert updated the question with required information. . . I tried manually creating the sofllink using ln -s data/app/app-package-name-hash/arm(in 32bit) or data/app/app-package-name-hash/arm64 lib and it works. . . How does this softlink gets created while installing the libs and loading native libraries? Any idea? – Shailendra Suriyal Jul 11 '19 at 09:31
  • Have you tried extracting the APK (it's just a zip file) to make sure the libraries did actually make it in to the APK? – Dan Albert Jul 11 '19 at 20:29
  • Yup. . . Apk has both armeabi libs as well as arm64-v8a – Shailendra Suriyal Jul 12 '19 at 02:35
  • File a platform bug maybe. Not sure what else to suggest. – Dan Albert Jul 12 '19 at 19:06
  • Thanks @DanAlbert filed bug on issue tracker – Shailendra Suriyal Jul 15 '19 at 04:22
  • https://issuetracker.google.com/issues/137210714 – Shailendra Suriyal Jul 19 '19 at 04:45
  • I'm able to reproduce the issue in Google samples as well – Shailendra Suriyal Jul 19 '19 at 04:46
  • @DanAlbert can you please cancel your downvote, as google has also passed this defect to their dev team? It may be useful for others as well. – Shailendra Suriyal Jul 22 '19 at 03:01
  • Why do you need this soft link? All you need from the native libraries – that `System.loadLibrary("vpn_bridge")` should work. Note that the best practice nowadays is [not to extract the native libraries](https://developer.android.com/guide/topics/manifest/application-element#extractNativeLibs) from the APK at all. – Alex Cohn Dec 15 '20 at 17:24

1 Answers1

0

Yes, I had same issue with 64 bits: I've missed the (not needed) softlink to legacyNativeLibraryDir arm64 in data/data/application-package-name

In order to find the path for native libs (regardless of device architecture) you should use getContext().getApplicationInfo().nativeLibraryDir

Reference: https://developer.android.com/ndk/guides/abis#aen

dnieto
  • 1
  • 1
  • Why do you need this soft link? All you need from the native libraries – that `System.loadLibrary()` should work. Note that the best practice nowadays is [not to extract the native libraries](https://developer.android.com/guide/topics/manifest/application-element#extractNativeLibs) from the APK at all. – Alex Cohn Dec 17 '20 at 07:51
  • 1
    Sorry for the confusion: it's not a _missing_ link, it's only I've _missed_ it :) I've fixed the answer. Thanks for the note on `android:extractNativeLibs` – dnieto Dec 18 '20 at 15:06