Android Runtime NoSuchMethodError - android

I recently started getting this error in certain scenarios at run time in my app...
I have already tried the following :
Add proguard rules to include com.google.common.
Mutlidex rules so that all the classes get packaged in main dex file
I have checked the apk contents to make sure the classes are present in the dex file...
Updgraded my guava android lib to latest 27.0.0-android
Updated gradle plugin and gradle version to the latest
AndroidRuntime: java.lang.NoSuchMethodError: No static method
checkArgument(ZLjava/lang/String;I)V in class
Lcom/google/common/base/Preconditions; or its super classes
(declaration of 'com.google.common.base.Preconditions' appears in
/data/app/com.myapp.dev.test-Xip2SNDMljPc2_BN0p3iRg==/base.apk!classes2.dex)
03-26 13:49:19.167 14658 14751 E AndroidRuntime: at
com.google.common.util.concurrent.RateLimiter.checkPermits(RateLimiter.java:424)
03-26 13:49:19.167 14658 14751 E AndroidRuntime: at
com.google.common.util.concurrent.RateLimiter.tryAcquire(RateLimiter.java:341)
03-26 13:49:19.167 14658 14751 E AndroidRuntime: at
com.google.common.util.concurrent.RateLimiter.tryAcquire(RateLimiter.java:325)
Not sure where to go from here now. Any ideas what else can I do ?

Try to add below proguard configuration
-keep class com.google.common.base.**

Related

Android : Proguard build is failing for joda time

I am getting the following error when I build the app with proguard. This failure is new. I updated some of the libraries used in the app to latest (including the target and compile sdk version to 30)but the joda library version is not changed. It is implementation 'net.danlew:android.joda:2.8.2'
Any idea why this error is coming now and how it can be resolved.
I already have the rule -keep class org.joda.** { *; } in my progurad rules.
java.lang.RuntimeException: Unable to create application com.xxx.xxx.xxx: java.lang.RuntimeException: Could not read ZoneInfoMap
at android.app.ActivityThread.handleMakeApplication(ActivityThread.java:7506)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:7440)
at android.app.ActivityThread.access$1500(ActivityThread.java:301)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2148)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:246)
at android.app.ActivityThread.main(ActivityThread.java:8506)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:602)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1130)
Caused by: java.lang.RuntimeException: Could not read ZoneInfoMap
at net.a.a.a.a.a(SourceFile:42)
at com.xxx.xxx.xxx.onCreate(SourceFile:116)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1192)
EDIT
Updating joda version to the latest 2.10.9.1 fixes the issue.
I am not adding this as answer as I wanted to know why this error appeared all of a sudden? Can any other version update can lead to this.

Android coreLibraryDesugaringEnabled, connected test crash with NoSuchMethodError

I added coreLibraryDesugaringEnabled to our app, and it works fine for normal app runs.
compileOptions {
coreLibraryDesugaringEnabled true
}
and
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.0.9'
However, when I run a connected test it crashes with no such method error on the Stream class:
16:03:56.426 11998 12041 E AndroidRuntime: FATAL EXCEPTION: com....
16:03:56.426 11998 12041 E AndroidRuntime: Process: ...
16:03:56.426 11998 12041 E AndroidRuntime: java.lang.NoSuchMethodError: No static method e([Ljava/lang/Object;)Lj$/util/stream/Stream; in class Lj$/util/n; or its super classes (declaration of 'j$.util.n' appears in /data/app/com....-qU6nwXthxze4O_9rcf1hGg==/base.apk!classes2.dex)
16:03:56.426 11998 12041 E AndroidRuntime: at j$.util.stream.Stream$-CC.of(:1000)
16:03:56.426 11998 12041 E AndroidRuntime: at ...
I found some vague reference that this might be because the class is referenced prior to the call to Multidex.install? I'm first referencing the class as a static initializer so it is accessed very early. Not sure if this is a red herring but thought I'd mention it.
If it helps the tests are run with AndroidJUnit4ClassRunner.
EDIT: I found a vague reference, in only one article stating that this is not supported in instrumentation tests:
Please note in Android Studio 4.0 using these library desugared types
in instrumented tests is not supported.
https://medium.com/androiddevelopers/support-for-newer-java-language-apis-bca79fc8ef65
but even the embedded video from Google on the feature doesn't say anything about that. Also not sure what the AS version would have to do with it. Perhaps they meant the AGP version.
This problem was fixed in com.android.tools:desugar_jdk_libs version 1.1.8 (at least).

Jacoco: IllegalStateException: Can't add different class with same name

I am trying to generate Jacoco XML reports for this Android project. I am using the gradle-android-junit-jacoco-plugin version 0.16.0 (latest as of today).
When I run the jacocoTestReportMerged task it fails with the following error:
Caused by: java.io.IOException: Error while analyzing XmlPullParsers.class.
at org.jacoco.core.analysis.Analyzer.analyzerError(Analyzer.java:170)
at org.jacoco.core.analysis.Analyzer.analyzeClass(Analyzer.java:142)
at org.jacoco.core.analysis.Analyzer.analyzeClass(Analyzer.java:165)
at org.jacoco.core.analysis.Analyzer.analyzeAll(Analyzer.java:201)
at org.jacoco.ant.ReportTask.createBundle(ReportTask.java:570)
at org.jacoco.ant.ReportTask.createReport(ReportTask.java:542)
at org.jacoco.ant.ReportTask.execute(ReportTask.java:495)
... 210 more
Caused by: java.lang.IllegalStateException: Can't add different class with same name:
info/metadude/android/eventfahrplan/network/serialization/XmlPullParsers
at org.jacoco.core.analysis.CoverageBuilder.visitCoverage(CoverageBuilder.java:107)
at org.jacoco.core.analysis.Analyzer$1.visitEnd(Analyzer.java:98)
at org.objectweb.asm.ClassVisitor.visitEnd(ClassVisitor.java:338)
at org.jacoco.core.internal.flow.ClassProbesAdapter.visitEnd(ClassProbesAdapter.java:98)
at org.objectweb.asm.ClassReader.accept(ClassReader.java:683)
at org.objectweb.asm.ClassReader.accept(ClassReader.java:391)
at org.jacoco.core.analysis.Analyzer.analyzeClass(Analyzer.java:124)
at org.jacoco.core.analysis.Analyzer.analyzeClass(Analyzer.java:140)
... 215 more
I started configuring exclude rules such as ...
junitJacoco {
excludes = [
"**/XmlPullParsers.*"
]
}
... but then the task fails at the next file - so this does not seem to be the correct way.
I also tried 0.17.0-SNAPSHOT and version prior to 0.16.0, without success though. Gradle 6.3 is used in this project.
How can I configure the Gradle plugin for my project?

Problems getting started with Chirp SDKs for Android

I have downloaded SDK for Android from
https://developers.chirp.io/downloads
After that I added *.aar library as was explain here:
https://developer.android.com/studio/projects/android-library.html#AddDependency
Hurrah. I can build the project.
Now I want to install the test App on the phone. But the application crashes like this:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: io.chirp.sdkdemoapp, PID: 12979
java.lang.NoClassDefFoundError: Failed resolution of: Lkotlin/jvm/internal/Intrinsics;
at io.chirp.chirpsdk.ChirpSDK.<init>(Unknown Source:2)
at io.chirp.chirpsdk.ChirpSDK.<init>(Unknown Source:5)
at io.chirp.chirpsdk.ChirpSDK.<init>(Unknown Source:8)
at io.chirp.sdkdemoapp.MainActivity.onCreate(MainActivity.java:77)
As I understand it, a problem arose with dependencies when packaging * aar
So I added in build.gradle (marked as Module) dependency for kotlin like:
implementation 'org.jetbrains.kotlin:kotlin-stdlib:1.2.61'
After that my ERROR has changed.
E/AndroidRuntime: FATAL EXCEPTION: main
Process: io.chirp.sdkdemoapp, PID: 13395
java.lang.NoClassDefFoundError: Failed resolution of: Lokhttp3/MediaType;
at io.chirp.b.a.<init>(Unknown Source:24)
at io.chirp.chirpsdk.a.<init>(Unknown Source:36)
at io.chirp.chirpsdk.ChirpSDK.<init>(Unknown Source:20)
at io.chirp.chirpsdk.ChirpSDK.<init>(Unknown Source:5)
at io.chirp.chirpsdk.ChirpSDK.<init>(Unknown Source:8)
at io.chirp.sdkdemoapp.MainActivity.onCreate(MainActivity.java:77)
I have wrong paths to io.chirp internal libraries.
What should I do to resolve dependency related errors?
You have to import the okhttp 3.12.x dependency required by the ChirpSDK.
However, you don't need to explicitly import the dependency if you are using the SDK from the maven repository as this will be already included:
implementation 'io.chirp:chirpsdk:3.10.0'
and add the repository in your parent maven file:
repositories {
maven {
url "https://maven.chirp.io/release"
}
}
Thanks Dinu for your answer!
Maven repository doesn't work in my case (proxy issues or something else but this is the topic of another discussion).
The problem with using offline ChirpSDK was solved by adding two dependencies:
implementation 'com.squareup.okhttp3:okhttp:3.12.6'
implementation 'org.jetbrains.kotlin:kotlin-stdlib:1.3.50'

Appsflyer Crash : Fatal Exception: java.lang.NoSuchMethodError for MultipleInstallBroadcastReceiver.java line 43

I am getting a Crash which is reported in Crashlytics for com.appsflyer.MultipleInstallBroadcastReceiver.onReceive in MultipleInstallBroadcastReceiver.java class
This Crash is been reported for few users in all the android verisons
Fatal Exception: java.lang.NoSuchMethodError: No virtual method 藡(Landroid/content/Context;Landroid/content/Intent;)V in class Lcom/appsflyer/AppsFlyerLib; or its super classes (declaration of 'com.appsflyer.AppsFlyerLib' appears in /data/app/com.rapido.passenger-1/base.apk)
at com.appsflyer.MultipleInstallBroadcastReceiver.onReceive(MultipleInstallBroadcastReceiver.java:43)
at android.app.ActivityThread.handleReceiver(ActivityThread.java:3112)
at android.app.ActivityThread.-wrap18(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1627)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:165)
at android.app.ActivityThread.main(ActivityThread.java:6375)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:912)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:802)
From the stack trace it seems to be an obfuscation issue (looking at the method name 藡)
What is the SDK version being used? Are there any proGuard (or other tool) rules configured for AppsFlyer?
If not I would suggest adding a -keep class com.appsflyer.** { *; } rule.
If you do not wish to share any additional information publicly, you can open a ticket with support#appsflyer.com, with the SDK version, any obfuscation related information and a link to this thread.

Categories

Resources