You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
TCStringDecoder base64 encoding failed on android api level <=25 #140
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.
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.
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.
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.
@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:
The java.time libraries introduced in Java 8 - this isn't an issue anymore because of Android Studio API desugaring, which supports older APIs;
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.
Activity
abhayIOS commentedon Apr 11, 2023
Any update on this issue?
laktech commentedon Apr 11, 2023
Ideally, we would vendorize the Base64 class and include it in the project. Are you familiar with any other android issues?
abhayIOS commentedon Apr 11, 2023
I am not familiar with 'vendorize the Base64 class and include it' Can you please share an example?
laktech commentedon Apr 11, 2023
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.
abhayIOS commentedon Apr 11, 2023
So you want us to include the lib code in the project replacing the Base64 import. Replacing the library reference.
laktech commentedon Apr 11, 2023
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.
coldcode001 commentedon Jul 4, 2023
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.
silvagoncalodev commentedon Jul 7, 2023
@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:
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.