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.NoClassDefFoundError: Failed resolution of: Landroidx/preference/PreferenceManager; #76

Open
mmobin789 opened this issue Aug 7, 2020 · 7 comments

Comments

@mmobin789
Copy link

mmobin789 commented Aug 7, 2020

Describe the bug
Below exception is thrown when I init the trust kit for android using below line
TrustKit.initializeWithNetworkSecurityConfiguration(context)
java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/preference/PreferenceManager;
at com.datatheorem.android.trustkit.utils.VendorIdentifier.getOrCreate(VendorIdentifier.java:24)
at com.datatheorem.android.trustkit.TrustKit.(TrustKit.java:209)
at com.datatheorem.android.trustkit.TrustKit.initializeWithNetworkSecurityConfiguration(TrustKit.java:321)
at com.datatheorem.android.trustkit.TrustKit.initializeWithNetworkSecurityConfiguration(TrustKit.java:271)

To Reproduce
There are no steps just the init line causes this issue and this issue has nothing to do with network_security_config and thats added under application tag in app's manifest and in xml directory under res.
The pattern for my base url is added and I am using 64 char length pinset.
My network config is below for ref.

Expected behavior
I want to implement SSL pinning for Android 21 and above.

TrustKit configuration
<?xml version="1.0" encoding="utf-8"?> <network-security-config> <domain-config cleartextTrafficPermitted="false"> <domain includeSubdomains="true">abcd.abcd-abcd.com</domain> <pin-set> <pin digest="SHA-256">XXX</pin> <pin digest="SHA-256">XXX</pin> <pin digest="SHA-256">XXX</pin> </pin-set> <trustkit-config enforcePinning="true" /> </domain-config> </network-security-config>

App details:

  • App target SDK: 30
  • App Min SDK: 21
  • App language: Java, Kotlin
  • Android R or API 30 (Tested on pixel 2 emulator)
@mmobin789
Copy link
Author

mmobin789 commented Aug 7, 2020

This issue disappeared when I added below dependency which is already present in your build.gradle in my library build.gradle file.
But I should'nt add this its logically invalid my library isn't using below dependency.
implementation 'androidx.preference:preference:1.1.1'

@prcaen
Copy link

prcaen commented Sep 18, 2020

This issue occurs only in 1.1.3

@mmobin789
Copy link
Author

@prcaen is there any updated version you are using ? Kindly suggest.

The library still says its last version at bintray is 1.1.3

@prcaen
Copy link

prcaen commented Sep 18, 2020

We are using the 1.1.2

@mehdi-salehi
Copy link

same as above...

E/AndroidRuntime: FATAL EXCEPTION: main
java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/preference/PreferenceManager;

@IgorGanapolsky
Copy link

The resolution is to add the following dependency:
implementation 'androidx.preference:preference-ktx:1.1.1'

@ledlie
Copy link

ledlie commented Apr 29, 2021

I could be wrong here, but it looks like VendorIdentifier is only used by BackgroundReporter. So if you are not interested in using background reporting, then the code could be slightly re-written to avoid this additional dependency. Only if background reporting is enabled do you need to persist TRUSTKIT_VENDOR_ID. As the code is now, everyone has to save this whether or not they want to.

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

5 participants