java.lang.NoClassDefFoundError exception when using CircularFifoQueue - android

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'

Related

Hilt with multi module not working with aar file

I've created a project with one module. e.g
app
module
When I'm using the following code in the app's build.gradle, It's working fine
implementation project(':module')
When I'm creating .aar for module with minifyEnabled true and using it in build.gradle using bellow code
implementation files('module-release.aar')
It gives the following error
Caused by: java.lang.ClassCastException: com.mypackage.DaggerMainApplication_HiltComponents_ApplicationC$ActivityRetainedCImpl$ActivityCImpl cannot be cast to com.com.mypackage.MyActivity_GeneratedInjector

com.android.build.api.transform.TransformException: java.lang.RuntimeException: Unable to pre-dex

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'

Not able to build Android gradle project from command line with dagger 2 dependency

I've bee using dagger for a while and now I'm facing a problem related to the generation of DaggerAppComponent class.
It is working as expected while running the project from Android Studio, but whenever I run the task assembleDebug on command line on the root dir, gradle cannot build the entire project since dagger classes are not being generated.
I am missing some task in order to completly execute the dagger annontation processor?
Dependencies:
final DAGGER_VERSION = '2.0.1'
compile "com.google.dagger:dagger:$DAGGER_VERSION"
annotationProcessor "com.google.dagger:dagger-compiler:$DAGGER_VERSION"
provided 'org.glassfish:javax.annotation:10.0-b28'
This is the final error:
import com.company.injection.DaggerAppComponent;
^
symbol: class DaggerAppComponent
location: package com.company.injection
:mobile:compileDebugJavaWithJavac FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':mobile:compileDebugJavaWithJavac'.
> java.lang.NoSuchMethodError: com.google.common.collect.Multimaps.filterKeys(Lcom/google/common/collect/SetMultimap;Lcom/google/common/base/Predicate;)Lcom/google/co
mmon/collect/SetMultimap;
Just to make sure, the graph is ok and it is working correctly, the problem just happen if I try to build the project by command line with assembleDebug.
After spending some time on this, I fixed the problem adding the guava dependency as the annotationProcessor just above the dagger-compiler.
final DAGGER_VERSION = '2.0.1'
compile "com.google.dagger:dagger:$DAGGER_VERSION"
annotationProcessor 'com.google.guava:guava:19.0'
annotationProcessor "com.google.dagger:dagger-compiler:$DAGGER_VERSION"
provided 'org.glassfish:javax.annotation:10.0-b28'
I had the same config with 'com.google.guava:guava:19.0' but I was having the following error:
Error:Execution failed for task ':mobile:compileDebugJavaWithJavac'.
> java.lang.NoSuchMethodError: com.google.common.collect.Multimaps.filterKeys(Lcom/google/common/collect/SetMultimap;Lcom/google/common/base/Predicate;)Lcom/google/common/collect/SetMultimap;
I tried to update the guava version to the current at the time 'com.google.guava:guava:22.0' but the error continued.
I changed to 'com.google.guava:guava:21.0' and it worked nicely. May be an incompatibility with others versions.

Error when generating code coverage report for androidTest instrumented testcases with dagger

I want to run createDebugCoverageReport gradle task.But after run task is failing and giving below error.
java.lang.NoClassDefFoundError: dagger.shaded.auto.common.BasicAnnotationProcessor
at java.lang.Class.classForName(Native Method)
at java.lang.Class.forName(Class.java:324)
at android.support.test.internal.runner.TestLoader.doLoadClass(TestLoader.java:92)
at android.support.test.internal.runner.TestLoader.loadIfTest(TestLoader.java:113)
at android.support.test.internal.runner.TestRequestBuilder.loadClassesFromClassPath(TestRequestBuilder.java:801)
at android.support.test.internal.runner.TestRequestBuilder.build(TestRequestBuilder.java:747)
at android.support.test.runner.AndroidJUnitRunner.buildRequest(AndroidJUnitRunner.java:354)
at android.support.test.runner.AndroidJUnitRunner.onStart(AndroidJUnitRunner.java:260)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1970)
Below are the dagger dependencies used
compile 'com.google.dagger:dagger:2.4'
annotationProcessor 'com.google.dagger:dagger-compiler:2.4'
androidTestCompile 'com.google.dagger:dagger-compiler:2.4'
Please suggest, How I can remove this error.
due what I found, it's a conflict with dagger-producers extensions - auto-value-gson works fine with dagger 2.0.2 - 2.4, but when dagger-producers (any version) is added as extra dependency to project following exception is thrown.
our problem is you are hitting the dex limit, which is different than this ticket. Make sure you're adding those dependencies to the apt config, not compile.

Android studio : android.support.v4.widget.DrawerLayout could not be found

After importing the demo from http://developer.android.com/training/implementing-navigation/nav-drawer.html, the android studio automatically makes it Gradle-configured .
At first, it's dependency part in build.gradle:
dependencies {
compile 'com.android.support:+'
}
And the above causes error.
Followed the solution (Manifest merger failed : uses-sdk:minSdkVersion 14), I change it to
dependencies {
compile 'com.android.support:support-v4:20.0.0'
}
and it works. Then I can build and run the app.
However, the code shows 'cannot resolve symbol R ‘, 'cannot resolve symbol DrawerLayout' and so on. And I then found errors in activity_main.xml:
android.support.v4.widget.DrawerLayout could not be found
I have specify the dependency of android.support.v4 , and why the drawerlayout cannot be found?
Try this.
compile 'com.android.support:support-v4:21.0.3'

Categories

Resources