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

java.lang.UnsatisfiedLinkError: dlopen failed: library "libsecrets.so" not found #78

Open
deepanshugupta1876 opened this issue Jul 24, 2023 · 15 comments

Comments

@deepanshugupta1876
Copy link

Fatal Exception: java.lang.UnsatisfiedLinkError: dlopen failed: library "libsecrets.so" not found
at java.lang.Runtime.loadLibrary0(Runtime.java:1087)
at java.lang.Runtime.loadLibrary0(Runtime.java:1008)
at java.lang.System.loadLibrary(System.java:1664)

@deepanshugupta1876
Copy link
Author

deepanshugupta1876 commented Jul 24, 2023

After increasing the plugin version from 0.1.3 to 0.2.1, getting this crash in crashlytics for few users

@deepanshugupta1876
Copy link
Author

Please do let me know, if you need any additional information from my end.

Please help me resolve this issue.

@ben-j69
Copy link
Member

ben-j69 commented Jul 31, 2023

@deepanshugupta1876 upate version by version and check the CHANGELOG to understand why you have this error.

@ponvig
Copy link

ponvig commented Aug 10, 2023

I have the same problem..

@vitalyveldyasov
Copy link

I have the same issue

@vitalyveldyasov
Copy link

My solution:

  1. Add into CMakeLists.txt:
cmake_minimum_required(VERSION 3.18.1)

add_library( # Specifies the name of the library.
        secrets

        # Sets the library as a shared library.
        SHARED

        # Provides a relative path to your source file(s).
        secrets.cpp )

version (in my case 3.18.1) can be depended on your project

  1. run ./gradlew hideSecret -Pkey=yourKeyToObfuscate [-PkeyName=YourSecretKeyName] [-Ppackage=com.your.package]
    this command generates 4 files: secrets.cpp, secrets.hpp, sha256.cpp, sha256.hpp and you need to set path to secrets.cpp in CMakeLists.txt. In my case both files are located in the same dir, so I put secrets.cpp
  2. You should remove secrets.cpp, secrets.hpp, sha256.cpp, sha256.hpp , Secrets.kt every time before executing ./gradlew hideSecret -Pkey=yourKeyToObfuscate [-PkeyName=YourSecretKeyName] [-Ppackage=com.your.package]. It is better to create separate gradle task for it.

@ben-j69
Copy link
Member

ben-j69 commented Sep 18, 2023

Hello @vitalyveldyasov thanks for the solution if it is working it is great.

How should I fix the library ? There is already a CMakeLists.

Thanks

@vitalyveldyasov
Copy link

What exactly should be fixed in library? Try to add into CMakesLists.txt a library name as I mentioned above, build the project and run gradle task like : ./gradlew hideSecretFromPropertiesFile -PpropertiesFileName=credentials.properties
where there are your keys in credentials.properties file

after that .so files should be generated and located in
build/intermediates/merged_native_libs/experimentalRelease/out/lib/<platform_name>/libsecrets.so

@ben-j69
Copy link
Member

ben-j69 commented Sep 27, 2023

@vitalyveldyasov there is already a CMakesList.txt https://github.com/klaxit/hidden-secrets-gradle-plugin/blob/master/src/main/resources/cpp/CMakeLists.txt

The problem might happen when the project already contain one.

@sherbaev
Copy link

I am also facing this issue

Fatal Exception: java.lang.UnsatisfiedLinkError
dlopen failed: couldn't map "/mnt/asec/com.sherbaev.me-1/base.apk!/lib/arm64-v8a/libsecrets.so" segment 0: Permission denied

@patelayush
Copy link

I have been facing the same issue. This exception is coming up for a few of the devices in Crashlytics. Has anyone found any solution to the issue.? I am on the latest version of sdk v0.2.1.

@georgehany309
Copy link

i have the same issue with small portion of users, and i cannot figure out why it's working with some users and not working with others.
anyone have found a solution yet?

@boy12hoody
Copy link

if you guys use R8 Obfuscation then you must include this rule in you proguard-rules.pro

-keepclasseswithmembers class * { native <methods>; }

This will instruct ProGuard to keep all native methods in any class it processes.

@tudor07
Copy link

tudor07 commented Feb 7, 2024

I have the same issue, a very very small percentage of users run into this issue.
Not sure how much Android version matter but the users with this problem have Android 10, Android 11 and Android 13.

@b-wissa
Copy link

b-wissa commented Dec 2, 2024

My solution:

  1. Add into CMakeLists.txt:
cmake_minimum_required(VERSION 3.18.1)

add_library( # Specifies the name of the library.
        secrets

        # Sets the library as a shared library.
        SHARED

        # Provides a relative path to your source file(s).
        secrets.cpp )

version (in my case 3.18.1) can be depended on your project

  1. run ./gradlew hideSecret -Pkey=yourKeyToObfuscate [-PkeyName=YourSecretKeyName] [-Ppackage=com.your.package]
    this command generates 4 files: secrets.cpp, secrets.hpp, sha256.cpp, sha256.hpp and you need to set path to secrets.cpp in CMakeLists.txt. In my case both files are located in the same dir, so I put secrets.cpp
  2. You should remove secrets.cpp, secrets.hpp, sha256.cpp, sha256.hpp , Secrets.kt every time before executing ./gradlew hideSecret -Pkey=yourKeyToObfuscate [-PkeyName=YourSecretKeyName] [-Ppackage=com.your.package]. It is better to create separate gradle task for it.

This is what worked for me, thanks 🚀

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

No branches or pull requests

10 participants