NXP lib not working on Android 7+ due to missing Apache HTTP client

Forum / MIFARE SDK / NXP lib not working on Android 7+ due to missing Apache HTTP client

  • 8. September 2020 at 12:40
    The title says it all. The NXP lib (v1.7) still uses the very old (and removed) Apache HTTP client to communicate. This requires the developers to add the removed lib to the Android build process (see https://developer.android.com/about/versions/marshmallow/android-6.0-changes#behavior-apache-http-client) which is bad if we consider that Android 11 is just around the corner...

    Stack trace:

    `Caused by java.lang.ClassNotFoundException: Didn't find class "org.apache.http.params.BasicHttpParams" on path: DexPathList[...]
    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:196)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
    at com.nxp.nfclib.ι$iF$1.run(:752)`

    Also, the lib leaks memory because the Activity is saved in the `NxpNfcLib` instance that is saved as a static variable, so this code is just a mess.
    + 2  |  - 0

    Re: NXP lib not working on Android 7+ due to missing Apache HTTP client

    8. September 2020 at 12:46
    Hi Norbert,

    Sorry, but I used the 1.7 version in test apps and there is no explicit reference to Apache HTTP required. But you are right, this was used in old releases of TapLinx. I assume there must be an incorrect setting in your Gradle file.

    The TapLinx team
    + 0  |  - 0

    Re: NXP lib not working on Android 7+ due to missing Apache HTTP client

    10. November 2020 at 9:27
    There's no incorrect setting in the gradle file. The log clearly shows the class that uses it: "ι". I followed the link from logcat and it definitely uses Apache HTTP client in a class that extends `AsyncTask`. The following is a partial copy of the generated (obfuscated) class:

    `public final void run() {
    Looper.prepare();
    DeviceDetails var1x = new DeviceDetails(ι.this.ॱˊ);
    String var2 = ι.this.ॱˊ.getPackageName();
    String var3 = var1x.getDeviceName();
    String var4 = var1x.getCountryLocation(ι.this.ॱˊ);
    String var5 = var1x.getDate();
    String var6 = var1x.getSdkVersion();
    String var7 = ι.ˏ(ι.this.ॱˊ);
    String var8 = (new StringBuilder("... long soap message here ...").toString();
    BasicHttpParams var9; // --> org.apache.http.params.BasicHttpParams
    HttpConnectionParams.setConnectionTimeout(var9 = new BasicHttpParams(), 15000); // --> org.apache.http.params.HttpConnectionParams
    HttpConnectionParams.setSoTimeout(var9, 35000);

    // [...]
    }`
    + 0  |  - 0

    Re: NXP lib not working on Android 7+ due to missing Apache HTTP client

    10. November 2020 at 9:27
    I am also facing the same issue,
    My gradle file settings are,
    implementation fileTree(dir: "libs", include: ["*.aar"])
    implementation 'androidx.appcompat:appcompat:1.2.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.1'
    implementation 'com.google.firebase:firebase-core:17.2.2'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test.ext:junit:1.1.2'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'

    implementation files('libs/nxpnfcandroidlib-1.7.aar')

    But I get the following error,

    java.lang.NoClassDefFoundError: Failed resolution of: Lorg/apache/http/params/BasicHttpParams;
    at com.nxp.nfclib.ι$iF$1.run(:752)
    Caused by: java.lang.ClassNotFoundException: Didn't find class "org.apache.http.params.BasicHttpParams" on path: DexPathList[[zip file "/data/app/com.example.desfiresdklogic-LiEY84vPfw9mjz1PO1XFaQ==/base.apk"],nativeLibraryDirectories=[/data/app/com.example.desfiresdklogic-LiEY84vPfw9mjz1PO1XFaQ==/lib/arm64, /system/lib64, /system/product/lib64]]
    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:196)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
    at com.nxp.nfclib.ι$iF$1.run(:752)

    Could you please let me know regarding the same.
    + 0  |  - 0

    Re: NXP lib not working on Android 7+ due to missing Apache HTTP client

    10. November 2020 at 9:38
    Hi Anitha and Norbert,

    I found this post on Stackoverflow:

    https://stackoverflow.com/questions/54806903/java-lang-noclassdeffounderror-failed-resolution-of-lorg-apache-http-params-ba

    It seems that using Apache HTTP client needs some modifications in the project settings for current releases.

    The TapLinx team
    + 0  |  - 0
Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.