Android Studio java.lang.NoSuchMethodError with dependency - android

Azure is calling:
URLEncoder.encode(encodeBase64String(...
which works fine on Android 9 and above. But on old phones I get:
Caused by: java.lang.NoSuchMethodError: No static method encodeBase64String([B)Ljava/lang/String; in class Lorg/apache/commons/codec/binary/Base64; or its super classes (declaration of 'org.apache.commons.codec.binary.Base64' appears in /system/framework/org.apache.http.legacy.boot.jar)
I have tried adding in :
implementation "commons-codec:commons-codec:1.14"
to build.gradle, but it does not seem to have an effect. What is the usual way to handle it when a class you didn't write that is part of an external SDK, is calling a method old phones don't support?

You should try with below code:
String encodedString = new String(Base64.encodeBase64(bytes));

Related

`java.lang.NoSuchMethodError: No static method create` after update tensorflow lite to 0.4.0

After updating org.tensorflow:tensorflow-lite-metadata, org.tensorflow:tensorflow-lite-task-vision and org.tensorflow:tensorflow-lite-support app falls with error:
java.lang.NoSuchMethodError: No static method create(Ljava/nio/ByteBuffer;Lorg/tensorflow/lite/InterpreterApi$Options;)Lorg/tensorflow/lite/InterpreterApi; in class Lorg/tensorflow/lite/InterpreterApi; or its super classes (declaration of 'org.tensorflow.lite.InterpreterApi' appears in /data/app/~~iBlhCFEsffVRgKI8jlh50w==/com.po4yka.dancer.debug-dw8TLYwUobxDEHmwOF5CSg==/base.apk!classes2.dex)
What could be wrong? I couldn't find any breaking changes in changelog.
If you're using Android Studio ML Binding, it has not been upgraded to tflite-support 0.4 yet. You should continue using tflite-support 0.3.1.
See: https://github.com/tensorflow/tflite-support/issues/824

Akka on android, "No field value in class Ljava/lang/String;"

I am trying to run Akka (typed) on Android 8. However when I try to create the ActorSystem it fails because the akka.util.Unsafe class try to access a missing "value" field on String:
// 'instance' being of type sun.misc.Unsafe
stringValueFieldOffset = instance.objectFieldOffset(String.class.getDeclaredField("value"));
Caused by: java.lang.NoSuchFieldException: No field value in class Ljava/lang/String; (declaration of 'java.lang.String' appears in /system/framework/core-oj.jar)
at java.lang.Class.getDeclaredField(Native Method)
at akka.util.Unsafe.(Unsafe.java:36)
I tried with Akka 2.6.19 and 2.5.32 but also 2.5.21 with Scala 2.11 but both fails at the same point. I am running it on Android 8.0 (which is a requirement).
Has anyone experienced the same issue and found a solution?
I cannot change the Android version. However, I can change Akka while I would like to use Akka-typed and a recent/supported version.
EDIT; I was not able to find a solution yet. However, I opened a discussion on the project: https://github.com/akka/akka/pull/23710#issuecomment-1091817062

Getting exception on switching from android activity to react activity

I am new to react-native.
We are integrating the react native source code into an existing android project.
We are following the below tutorial :
https://medium.com/mindorks/react-native-integration-with-existing-app-f2757c2e672d
After adding the required react-native classes and following all steps, we are facing some crash issues when we are switching android activity to react-native activity.
Here is the crash issue
Caused by: java.lang.IllegalAccessError: Method 'void
androidx.core.net.ConnectivityManagerCompat.()' is inaccessible
to class 'com.facebook.react.modules.netinfo.NetInfoModule'
(declaration of 'com.facebook.react.modules.netinfo.NetInfoModule'
appears in /data/app/com.ttl.reactintegrationdemo-2/base.apk)

Smack 4.2.1 api java.lang.NoSuchMethodError in class Lorg/jxmpp/util/cache/Cache

In Smack 4.2.1, with used jxmpp-core-0.5.0-alpha7.jar lib I have fetching following issue
com.deep.tasktowerchat fatal error : No interface method lookup(Ljava/lang/Object;)Ljava/lang/Object; in class Lorg/jxmpp/util/cache/Cache; or its super classes (declaration of 'org.jxmpp.util.cache.Cache' appears in /data/app/com.deep.tasktowerchat-1/base.apk)
java.lang.NoSuchMethodError: No interface method lookup(Ljava/lang/Object;)Ljava/lang/Object; in class Lorg/jxmpp/util/cache/Cache; or its super classes (declaration of 'org.jxmpp.util.cache.Cache' appears in /data/app/com.deep.tasktowerchat-1/base.apk)
at org.jivesoftware.smack.sasl.core.ScramMechanism.evaluateChallenge(ScramMechanism.java:179)
at org.jivesoftware.smack.sasl.SASLMechanism.challengeReceived(SASLMechanism.java:245)
at org.jivesoftware.smack.SASLAuthentication.challengeReceived(SASLAuthentication.java:253)
at org.jivesoftware.smack.SASLAuthentication.challengeReceived(SASLAuthentication.java:237)
at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.parsePackets(XMPPTCPConnection.java:1091)
at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.access$300(XMPPTCPConnection.java:982)
at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader$1.run(XMPPTCPConnection.java:998)
at java.lang.Thread.run(Thread.java:818)
it's work fine when i was used smack-android-4.2.0-beta3-SNAPSHOT.jar lib on my project but after change the smack lib version it will throw above error.
is it smack or jxmpp library version issue ?
You need to add following lib in your app with same version code. you can download here for more repository and jar file
jxmpp-core-0.5.0.jar
jxmpp-jid-0.5.0.jar
jxmpp-stringprep-libidn-0.5.0.jar
jxmpp-util-cache-0.5.0.jar
Then rebuild and clean your project. i hope it will work.

java.lang.IncompatibleClassChangeError after upgrading to kotlin RC1 (1.0.0-rc-1036)

After upgrading to kotlin RC1 (1.0.0-rc-1036), I get this error:
java.lang.IncompatibleClassChangeError: The method 'java.lang.Object kotlin.Lazy.getValue()' was expected to be of type interface but instead was found to be of type virtual (declaration of 'java.lang.reflect.ArtMethod' appears in /system/framework/core-libart.jar)
I use lazy in one of my class:
val api by lazy {
val client = OkHttpClient()
...
}
From the release notes:
Lazy is now an interface open for implementation
But I cannot figure out what I have to change to get my code running again...
When the code is being compiled against the standard library kotlin-stdlib-1.0.0-rc-1036.jar the compiler sees Lazy to be an interface and generates INVOKEINTERFACE instruction to get the value of its property:
INVOKEINTERFACE kotlin/Lazy.getValue ()Ljava/lang/Object;
In case if at run-time you get Lazy loaded from the pre-RC standard library it occurs to be a class and not an interface. Here is where JVM catches that inconsistency and throws an IncompatibleClassChangeError.
So you need to ensure you don't have an old standard library available to classloader at run-time.
If you use Gradle, follow the instructions at https://kotlinlang.org/docs/reference/using-gradle.html#configuring-dependencies to configure/update dependency on the standard library.

Categories

Resources