Skip to content

TCStringDecoder base64 encoding failed on android api level <=25  #140

Open

Description

@af-jja

Version
2.0.10

Module (core, cmpapi, cli, stub, or testing)
iabtcf-decoder

Error
java.lang.NoClassDefFoundError: Failed resolution of: Ljava/util/Base64; at com.iabtcf.decoder.TCStringDecoder.vectorFromString(TCStringDecoder.java:37) at com.iabtcf.decoder.TCStringDecoder.decode(TCStringDecoder.java:57) at com.iabtcf.decoder.TCString.decode(TCString.java:43)

Describe with reproduction steps – What is the expected behavior?
TCString decoding failed with an exception.

On andorid api level 25 and below, java.util.Base64 is not available. it should be replaced with android.util.Base64
see: https://stackoverflow.com/questions/48697766/android-studio-noclassdeffounderror-with-java-util-base64

is it possible to support an android/kotlin lib on maven as well?

Activity

  1. abhayIOS commented on Apr 11, 2023

    @abhayIOS

    Any update on this issue?

  2. laktech commented on Apr 11, 2023

    @laktech
    Collaborator

    Ideally, we would vendorize the Base64 class and include it in the project. Are you familiar with any other android issues?

  3. abhayIOS commented on Apr 11, 2023

    @abhayIOS

    I am not familiar with 'vendorize the Base64 class and include it' Can you please share an example?

  4. laktech commented on Apr 11, 2023

    @laktech
    Collaborator

    it means to include the code in the project so both android and non-android platforms can be supported. we essentially remove the dependency from the standard library. however, this approach only makes sense if all android dependencies are identified. if this is not possible other tactics would be required like creating two builds, one for each platform.

  5. abhayIOS commented on Apr 11, 2023

    @abhayIOS

    So you want us to include the lib code in the project replacing the Base64 import. Replacing the library reference.

  6. laktech commented on Apr 11, 2023

    @laktech
    Collaborator

    correct, but again, all dependencies must be identified since some may be more feasible to include than others. in the event that a dependency cannot be easily included, this approach would not be successful.

  7. coldcode001 commented on Jul 4, 2023

    @coldcode001

    If java.util.Base64 is the only one issue, then the reflection would make a workaround for Android. Just try and fallback with the android.util.Base64 instead in a helper class and use it for all cases.
    I saw there's similar issue in decoder lib.

  8. silvagoncalodev commented on Jul 7, 2023

    @silvagoncalodev

    @laktech
    I've been using the decoder library on Android projects, I might be able to help with this.

    I downloaded your project, converted it to an Android Studio project and executed all unit tests as instrumentation tests on an Android device.

    Currently, there are 2 hidden dependencies that result in crashes at runtime, on versions older than API 26:

    1. The java.time libraries introduced in Java 8 - this isn't an issue anymore because of Android Studio API desugaring, which supports older APIs;
    2. The java.util.Base64 class - this needs to be replaced with something that works on older Android APIs.

    I replaced java.util.Base64 with android.util.Base64 equivalent methods, and all your unit tests complete successfully.
    So you just need to find an alternative to java.util.Base64 to officially support Android devices.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions