Runtime error in my android app - android

whenever I want to wrapp some data in a jackson object mapper, I got a runtime error with following message:
07-07 17:44:59.049 19642-20156/com.app.teamchannel E/AndroidRuntime: FATAL EXCEPTION: SyncAdapterThread-1
java.lang.VerifyError: org/codehaus/jackson/map/ObjectMapper
First time I encountered this error was after I included google analytics in gradle like:
compile 'com.google.android.gms:play-services-analytics:8.4.0'
Can anyone help please? I've already spent couple of hours with no solution until now.
Complete exception:
Could not find class 'org.codehaus.jackson.map.introspect.JacksonAnnotationIntrospector', referenced from method org.codehaus.jackson.map.ObjectMapper.
Could not find class 'org.codehaus.jackson.map.deser.StdDeserializerProvider', referenced from method org.codehaus.jackson.map.ObjectMapper.
Could not find class 'org.codehaus.jackson.util.TokenBuffer', referenced from method org.codehaus.jackson.map.ObjectMapper._convert
Could not find class 'org.codehaus.jackson.map.deser.StdDeserializationContext', referenced from method org.codehaus.jackson.map.ObjectMapper._createDeserializationContext
Could not find class 'org.codehaus.jackson.util.DefaultPrettyPrinter', referenced from method org.codehaus.jackson.map.ObjectMapper._defaultPrettyPrinter
FATAL EXCEPTION: SyncAdapterThread-1
java.lang.VerifyError: org/codehaus/jackson/map/ObjectMapper
at com.app.teamchannel.adapters.MySyncAdapter.onPerformSync(MySyncAdapter.java:2205)
at android.content.AbstractThreadedSyncAdapter$SyncThread.run(AbstractThreadedSyncAdapter.java:247)
FATAL EXCEPTION: SyncAdapterThread-1
java.lang.VerifyError: org/codehaus/jackson/map/ObjectMapper
at com.app.teamchannel.adapters.MySyncAdapter.onPerformSync(MySyncAdapter.java:2205)
at android.content.AbstractThreadedSyncAdapter$SyncThread.run(AbstractThreadedSyncAdapter.java:247)

Finally I found a solution. There was obviously a package name collision, what lead to take the wrong classes during runtime.
What I did:
I downloaded both jars manually
jackson-core-asl-1.9.3
jackson-mapper-asl-1.9.13
and changed the package name from org.codehaus.jackson.** to custom.org.codehaus.jackson.#1 for both libraries. To change the package name I used a tool called JarJar.
You can find instructions how to repackage here.
After that I put the repackaged jars into libs folder which you find in app folder (Android Studio: project view).
Following code must be included in the build.gradle on app-level in the dependencies:
compile fileTree(include: ['*.jar'], dir: 'libs')
So gradle also compiles jars in the lib folder.

Related

Caused by: java.lang.RuntimeException: Duplicate class com.google.common.base.FinalizablePhantomReference

I'm working on Android Studio Bumblebee | 2021.1.1
I'm having this error when I try to compile the project:
Caused by: java.lang.RuntimeException: Duplicate class com.google.common.base.FinalizablePhantomReference found in modules jetified-google-collect-snapshot-20080530 (com.google.code.google-collections:google-collect:snapshot-20080530) and jetified-guava-28.1-android (com.google.guava:guava:28.1-android)
Is simple annoying, I not able to recognize which exactly generate the error (The duplicate class).
Please let me know if you have any clue or if you have had the same problem before and know how to solve it, thanks!
Add the following implementation in the app level build.gradle
implementation 'com.google.firebase:firebase-inappmessaging-display:17.2.0'
implementation 'com.google.guava:guava:27.0.1-android'

java.lang.NoClassDefFoundError exception when using CircularFifoQueue

I'm trying to use the class CircularFifoQueue
It compiles successfully but I got the following exception on runtime
stack=java.lang.NoClassDefFoundError: Failed resolution of: Lorg/apache/commons/collections4/queue/CircularFifoQueue;
although I added the collections4 dependency to the build.gradle
compile 'org.apache.commons:commons-collections4:4.0'

NoClassDefFoundError: com.google.firebase.FirebaseOptions

I keep on getting the NoClassDefFoundError on other test device (4.4.2) that I'm using. But works fine on my test device (Android 5.1).
I tried the solutions that I've googled and nothing seems to work.
I'm using Firebase Realtime Database. Can somebody please help?
Here is the error log:
06-03 01:36:29.607 2655-2655/mobapps.mypersonal.biz.grouptracker E/dalvikvm: Could not find class 'com.google.firebase.FirebaseOptions', referenced from method com.google.firebase.FirebaseApp.<init> 06-03 01:36:29.617 2655-2655/mobapps.mypersonal.biz.grouptracker E/dalvikvm: Could not find class 'com.google.firebase.FirebaseApp$zzb', referenced from method com.google.firebase.FirebaseApp.zzaJ 06-03 01:36:29.621 2655-2655/mobapps.mypersonal.biz.grouptracker E/dalvikvm: Could not find class 'com.google.firebase.FirebaseApiNotAvailableException', referenced from method com.google.firebase.FirebaseApp.getToken 06-03 01:36:29.629 2655-2655/mobapps.mypersonal.biz.grouptracker E/dalvikvm: Could not find class 'com.google.firebase.FirebaseApp$zza', referenced from method com.google.firebase.FirebaseApp.zza 06-03 01:36:29.639 2655-2655/mobapps.mypersonal.biz.grouptracker E/AndroidRuntime: FATAL EXCEPTION: main
Process: mobapps.mypersonal.biz.grouptracker, PID: 2655
java.lang.NoClassDefFoundError: com.google.firebase.FirebaseOptions
at com.google.firebase.FirebaseApp.zzbu(Unknown Source)
at com.google.firebase.provider.FirebaseInitProvider.onCreate(Unknown Source)
at android.content.ContentProvider.attachInfo(ContentProvider.java:1656)
at android.content.ContentProvider.attachInfo(ContentProvider.java:1627)
at com.google.firebase.provider.FirebaseInitProvider.attachInfo(Unknown Source)
at android.app.ActivityThread.installProvider(ActivityThread.java:5079)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:4653)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4593)
at android.app.ActivityThread.access$1500(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1402)
at android.os.Handler.dispatchMessage(Handler.java:110)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:5363)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:828)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:644)
at dalvik.system.NativeStart.main(Native Method)
This is what solved the problem for me:
Add compile 'com.android.support:multidex:1.0.2' to
app/build.gradle.
Add android:name="android.support.multidex.MultiDexApplication" to the application tag in AndroidManifest.xml.
If you are using a custom Application class, skip the
AndroidManifest.xml and make your Application class extend MultiDexApplication instead of Application.
This bug is reported with newer versions mostly arround Revision 28,29 and its resolved in newer Play services versions so if you having this issue then make sure you have updated version of Google Play service in your Android studio. as older versions have it. To update Play services version..
Follow these steps:
Go to Android SDK Manager
Go to Extra here you will find as shown in image below, update it to latest version and try to run project.
Then if you are using MultiDex in your Application,then make sure you have correctly done it.
In you App level Build.Gradle file use this code multiDexEnabled true
defaultConfig {
applicationId "com.reversebits.tapanhp.saffer"
minSdkVersion 17
targetSdkVersion 23
versionCode 1
versionName "1.0"
multiDexEnabled true
}
Apply MultiDex dependency in dependencies inside Same file.
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.google.android.gms:play-services:9.4.0'
compile 'com.android.support:multidex:1.0.1'
}
Then inside your AndroidMenifest.xml file make sure that Application tag have name of MultiDexApplication.
<application
android:name="android.support.multidex.MultiDexApplication"
android:allowBackup="true">
Note
if you have your own Application class and you are using it in your menifest file then you can initialize multidex in your Application class as follows,
public class AppClass extends Application {
//this will initialize multidex in your own Application class
#Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
}
Thanks to TapanHP above I got this working quickly for me:
Short Answer:
I had multiDexEnabled= true set in my app/build.gradle file and this ran fine on Android 5.x.x above but any test device with 4.x.x (kit kat) would throw a critical error "Unfortunately, YourAppName has stopped."
Debugger showed:
Could not find class 'com.google.firebase.FirebaseOptions' ....
Note: I also have a custom class that extends Application.
My Solution:
Added the following code to my custom Application class
import android.support.multidex.MultiDex;
public class YourCustomApplication extends Application {
#Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
...
}
No more critical crash.
I have the same problem, with this I have solved:
https://stackoverflow.com/a/37364044
You must replace android:name=".app" with android:name="android.support.multidex.MultiDexApplication"

gradle dependencies .so file

I use gradle build android project, dependencies .so file.
compile 'com.epwk:liblocSDK4d:1.0:armeabi#so'
compile 'com.epwk:libjpush170:1.0:armeabi#so'
compile 'com.epwk:libMtaNativeCrash:1.0:armeabi#so'
compile 'com.epwk.mips:libMtaNativeCrash:1.0:mips#so'
compile 'com.epwk.x86:libMtaNativeCrash:1.0:x86#so'
compile 'com.epwk.armeabiv7a:libjpush170:1.0:v7a#so'
compile 'com.epwk.armeabiv7a:libMtaNativeCrash:1.0:v7a#so'
I could see them in the external libraries.
When I run this project it get the following error:
Caused by: java.lang.UnsatisfiedLinkError: Couldn't load jpush170: findLibrary returned null
What should I do?
Ignoring class path entry C:\Users\Administrator\.gradle\caches\modules-2\files-
2.1\com.epwk\liblocSDK4d\1.0\24c2f73ec32323d8f0eac88b58731ae3336e4c93\liblocSDK4
d-1.0-armeabi.so
Ignoring class path entry C:\Users\Administrator\.gradle\caches\modules-2\files-
2.1\com.epwk\libjpush170\1.0\4e0296ffc64d57753e974110682baedd4a127d17\libjpush17
0-1.0-armeabi.so
Ignoring class path entry C:\Users\Administrator\.gradle\caches\modules-2\files-
2.1\com.epwk\libMtaNativeCrash\1.0\beefa8d28bf7c2490443d74623c2c9595d329a86\libM
taNativeCrash-1.0-armeabi.so

Gradle: how to add a jar to build but not export it

I'm using the Open Mobile API (SEEK API) in my project by adding the jar file to my gradle build:
dependencies {compile files('libs/org.simalliance.openmobileapi.jar')}
it gives me this exception:
java.lang.IllegalAccessError: Class ref in pre-verified class resolved to unexpected implementation
at dalvik.system.DexFile.defineClassNative(Native Method)
at dalvik.system.DexFile.defineClass(DexFile.java:222)
at dalvik.system.DexFile.loadClassBinaryName(DexFile.java:215)
at dalvik.system.DexPathList.findClass(DexPathList.java:322)
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:65)
at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
My understanding is I need to include the jar in compile process but exclude it in the linking and don't export it to my APK. this is normally done with a simple checkbox in eclipse, but I can't find a way to do it with gradle.
any help is appreciated.
To not export your .jar THIS is maybe helpful. (reads well)
Additionally:
Try this to get rid of the error:
Go to modules -> dependencies, then set scope of the lib to 'Provided'.
here is my source

Categories

Resources