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'
Related
I'm trying to use azure chat and calling in the same application. Right now I'm getting an error
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/microsoft/trouterclient/registration/ISkypetokenProvider;
at com.azure.android.communication.chat.ChatAsyncClient.<init>(ChatAsyncClient.java:50)
at com.azure.android.communication.chat.ChatClientBuilder.buildAsyncClient(ChatClientBuilder.java:233)
https://learn.microsoft.com/en-us/azure/communication-services/quickstarts/chat/get-started the QuickStart library suggested I exclude files from dependency like below and this is causing the issue I'm seeing.
implementation 'com.azure.android:azure-communication-calling:2.0.0'
implementation 'com.azure.android:azure-communication-common:1.0.1'
implementation 'org.slf4j:slf4j-log4j12:1.7.29'
implementation ("com.azure.android:azure-communication-chat:1.1.0-beta.4") {
exclude group: 'com.microsoft', module: 'trouter-client-android'
}
If I try to remove this though I will receive this error
Duplicate class com.skype.rt.WiFiNetworkState found in modules jetified-azure-communication-calling-2.0.0-runtime (com.azure.android:azure-communication-calling:2.0.0) and jetified-trouter-client-android-0.1.1-runtime (com.microsoft:trouter-client-android:0.1.1)
Am I using the wrong versions or is there a different solution to this?
Chat for azure can't work with the real time notification functionality in android as of that version.
https://learn.microsoft.com/en-us/azure/communication-services/quickstarts/chat/get-started?tabs=windows&pivots=programming-language-android#receive-chat-messages-from-a-chat-thread
Updating AndroidStudio this week I was forced to add AnnotationProcessor:
(Don't even understand what for.)
Annotation processors must be explicitly declared now. The following dependencies on the compile classpath are found to contain annotation processor. Please add them to the annotationProcessor configuration. kotlin-compiler-embeddable-1.3.11.jar (org.jetbrains.kotlin:kotlin-compiler-embeddable:1.3.11)
So I added to my app.build.gradle:
dependencies {
...
annotationProcessor "org.jetbrains.kotlin:kotlin-compiler-embeddable:$kotlin_version"
...
}
But now I can't get rid of the following errors:
Run tasks :app:checkDebugDuplicateClasses
> Duplicate class found in modules annotations-13.0.jar (org.jetbrains:annotations:13.0) and kotlin-compiler-embeddable-1.3.11.jar (org.jetbrains.kotlin:kotlin-compiler-embeddable:1.3.11)
I don't know where org.jetbrains:annotations:13.0 is declared/imported in my gradles or settings.
How can I solve this error?
I was getting a similar Gradle error stating duplicate class found in annotations when I tried to use kotlin in some Old project. In my case, I have to remove the following dependency which was causing conflict with kotlin's annotation module.
implementation 'org.jetbrains:annotations-java5:17.0.0'
I got similar error due to some libraries using different versions of the same intellij annotation library.
I run app:dependencies and found that library com.xx.yy is using intellij.annotations.12 dependency. So I exclude that for that library only with
implemenation ("com.xx.yy:1.2.3") {
exclude group: 'com.intellij', module: 'annotations'
}
./gradlew app:dependencies
check all dependencies
Facing this issue while I am upgrading my Android project. Upgraded following config till now:
Kotlin v.1.1.60 to v.1.2.41
along with above change I added plugin apply plugin: 'kotlin-kapt' and replaced annotationProcessor to kapt
Upgraded dependency compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version" to compile "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" as I got the warning that "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version" was deprecated for new Kotlin version
Uptill now, my project isworking i.e. getting compiled and APK is getting generated. Now I made following changes:
Upgraded Realm from v.2.2.2 to v.5.1.0
At this stage, my project was not getting compiled. For classes such as Realm, RealmResults I was getting 'unresolved reference'. Then I added below code in application's build.gradle
realm {
syncEnabled = true
}
Now 'unresolved reference' is resolved but I am getting above error mentioned in the question.
Caused by: com.android.build.api.transform.TransformException: java.lang.RuntimeException: java.lang.RuntimeException: Unable to pre-dex '/Users/macusername/.android/build-cache/1356d0bbf59bd3c075dd3c13537428b6de3f0678/output/jars/classes.jar' to '/Users/macusername/AndroidProjects/project-name/app/build/intermediates/transforms/dex/flavour-name/debugSIT/folders/1000/10/classes_3ca2264d84fdd4905c647b112b0d3c683ba517e0'
What can cause this error for class DrawableWrapper from the support lib?
Caused by: java.lang.ClassNotFoundException: Didn't find class
"android.support.v4.graphics.drawable.DrawableWrapper" on path:
DexPathList[[zip file "/data/app/com.example.banyan.tasty-
1/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
Try updating your support library to 27.1.0.
Make sure all of your "com.android.support:*" dependencies are at the same version.
Looks like one of the support libraries uses something that is missing in the other one.
i fixed same error updating version
implementation 'com.android.support:design:27.0.2'
implementation 'com.android.support:support-v4:27.0.2'
To
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support:support-v4:27.1.1'
I started getting this exception in Android 5 and Android 4 users after removing com.android.support-v13 from my build.gradle file:
configurations.all {
exclude group: 'com.android.support', module: 'support-v13'
}
I removed the above exclude configuration and no longer saw this crash.
In my case, I used support library version '27.0.2' for my project. It was working perfectly. However, when I copy & paste the project to different location and I opened in Android studio. That time, android studio added below line in build.gradle (path: MyProject/app/build.gradle)
compile 'com.android.support:support-v4:27.1.1'
Then I got the below exception.
Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.v4.graphics.drawable.DrawableWrapper" on path: DexPathList
I removed the line from build.gradle (MyProject/app/build.gradle). Now it is working fine.
Try this:
import android.support.v7.graphics.drawable.DrawableWrapper;
import android.support.v7.graphics.drawable.DrawableWrapper;
or
import android.support.v4.graphics.drawable.WrappedDrawable; will help.
Also, when you use Drawable inner = ((WrappedDrawable) drawable).getWrappedDrawable();, you can add #SuppressLint("RestrictedApi") above your method.
Try:
enable D8
if you using
AS 3.1
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.