I am trying to update my dependencies to use the new implementation/api spec instead of compile. This is for a general library I am writing which I then use in my app via jitpack.
When I make the simple switch from compile to implementation I get the following error (just the important bits) when using the library in my app:
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/bumptech/glide/request/RequestOptions;
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.bumptech.glide.request.RequestOptions" on path: DexPathList
I have tried cleaning and rebuilding and it does not help. The second I switch back to compile calls everything works just fine.
I'll note that the library will build just fine in all cases.
The following usage works (though warns me that compile will be deprecated):
compile fileTree(dir: 'libs', include: ['*.jar'])
testImplementation 'junit:junit:4.12'
compile 'com.github.ybq:Android-SpinKit:1.2.0'
compile 'io.reactivex.rxjava2:rxandroid:2.1.0'
compile 'androidx.appcompat:appcompat:1.0.2'
compile "com.github.bumptech.glide:glide:4.4.0"
compile 'androidx.recyclerview:recyclerview:1.0.0'
compile "com.github.chrisbanes:PhotoView:1.3.1"
compile 'com.google.android.material:material:1.0.0'
The following gives the above error (also gives the error if I use api instead of implementation):
implementation fileTree(dir: 'libs', include: ['*.jar'])
testImplementation 'junit:junit:4.12'
implementation 'com.github.ybq:Android-SpinKit:1.2.0'
implementation 'io.reactivex.rxjava2:rxandroid:2.1.0'
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation "com.github.bumptech.glide:glide:4.4.0"
implementation 'androidx.recyclerview:recyclerview:1.0.0'
implementation "com.github.chrisbanes:PhotoView:1.3.1"
implementation 'com.google.android.material:material:1.0.0'
I'll also add that if I just switch the glide to compile then it gives the same error but about a different dependency. Can anyone help me figure this out? I could just keep compile for now but I want to update this.
After hours of debugging I finally figured it out
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
Updating the maven gradle plugin in my library to 2.1 from 1.5 resolved the issue
Related
I am getting error in the whole class that extends BottomSheetDialogFragment
Cannot access 'androidx.lifecycle.HasDefaultViewModelProviderFactory' which is a supertype of 'FavoriteBottomDialogFragment'. Check your module classpath for missing or conflicting dependencies
The class is in app module and this module implements two other modules : core and presentation-core
build.gradle
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation project (':core')
implementation project (':presentation-core')
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.41"
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.core:core-ktx:1.2.0'
testImplementation 'junit:junit:4.12'
implementation "com.google.android.material:material:1.1.0"
//Rx
implementation "io.reactivex.rxjava2:rxandroid:2.1.1"
implementation "io.reactivex.rxjava2:rxjava:2.2.9"
//Architecture component
implementation 'androidx.lifecycle:lifecycle-extensions:2.0.0'
implementation 'androidx.room:room-runtime:2.0.0'
kapt 'androidx.room:room-compiler:2.0.0'
kapt 'androidx.lifecycle:lifecycle-common-java8:2.0.0'
implementation 'androidx.room:room-rxjava2:2.0.0'
implementation 'androidx.room:room-guava:2.0.0'
implementation 'androidx.recyclerview:recyclerview:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
}
core dependencies
dependencies {
api fileTree(dir: 'libs', include: ['*.jar'])
api "org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.61"
api "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.4"
api 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.3.2'
//library to serialize Java Objects between Contexts
implementation 'org.parceler:parceler-api:1.1.11'
kapt 'org.parceler:parceler:1.1.11'
//testing dependencies
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
testImplementation "org.mockito:mockito-core:2.24.5"
androidTestImplementation "org.mockito:mockito-android:2.24.5"
//architecture component
implementation "androidx.lifecycle:lifecycle-extensions:2.0.0"
implementation "androidx.lifecycle:lifecycle-livedata:2.0.0"
//RxJava2
implementation "io.reactivex.rxjava2:rxjava:2.2.9"
implementation "io.reactivex.rxjava2:rxandroid:2.1.1"
}
presentation-core
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.61"
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.core:core-ktx:1.0.2'
}
BottomSheetDialogFragment
Even with errors i got, I can run the project in a device
I experienced this exact same problem today, and was able to solve.
Turns out the issue was a version mismatch between the expected version of androidx.lifecycle:lifecycle-viewmodel used by the module where the "failing" class is and a later version in some other dependent code.
So in my case, my module was using version 2.1.0 of this module, but one of the dependencies was using version 2.2.0. The code will compile no problem, because gradle resolves the dependency to the latest version; however Android Studio is somehow confused by this situation (not always, because this doesn't happen all the time, but sometimes – this isn't the first time I've seen this.)
Therefore solution is: figure out what the latest version of this library is in your app and update your build.gradle for this module to point to the same version that gradle is resolving to. Or:
run gradlew app:dependencies
search the result for lifecycle-viewmodel
update build.gradle in your app to depend on lifecycle-viewmodel with the version that gradle says it is resolving to
Sync project with gradle files
in my case (an Android module), Android Studio 4.0.1, I get a number of warnings in the IDE related to androidx.lifecycle.HasDefaultViewModelProviderFactory,
I have solved the issue by adding this line to build.gradle:
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
thus the beginning of build.gradle becomes:
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
...
In my case, the problem was solved adding the lifecycle viewmodel dependency in the module of the troubled class.
Add dependency into you build gradle androidx.fragment:fragment-ktx:x.x.x with actual version. For activity you must add androidx.activity:activity-ktx:x.x.x. I hope this helps you, in my case it solved the problem.
I added the following lines to build.gradle to solve the same issue in a module:
def archLifecycleVersion = '2.2.0'
implementation "androidx.lifecycle:lifecycle-extensions:$archLifecycleVersion"
kapt "androidx.lifecycle:lifecycle-compiler:$archLifecycleVersion"
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$archLifecycleVersion"
Your androidx.lifecycle:lifecycle-XXX dependency versions must be the same.
in my case:
implementation "androidx.lifecycle:lifecycle-viewmodel-compose:2.4.1"
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.4.1"
implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.4.1"
I recently just started with android development using kotlin so a total noob at android studio too.
I am trying to build a super simple HelloWorld app but I got this error:
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.
- jetified-kotlin-compiler-embeddable-1.3.72.jar (kotlin-compiler-embeddable-1.3.72.jar)
Alternatively, set android.defaultConfig.javaCompileOptions.annotationProcessorOptions.includeCompileClasspath = true to continue with previous behavior. Note that this option is deprecated and will be removed in the future.
See https://developer.android.com/r/tools/annotation-processor-error-message.html for more details.
but when I added the annotationprocessor at the end of my dependencies like:
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.core:core-ktx:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
annotationProcessor "org.jetbrains.kotlin:kotlin-compiler-embeddable:$kotlin_version"
}
I encountered a new error instead when I tried to build:
https://del.dog/pyfunestin
Class duplicate error can be solved by cleaning the project. First clean the project and rebuild it.
I am really fed up of these stupid android studio errors, the thing is I have included the implementation com.google.firebase:firebase-core:16.1.0 dependency in my build.gradle file but still am getting the error that says :::
Could not find com.google.firebase:firebase-core:16.1.0.
Also if I try to change it from 16.1.0 to 16.0.1 still error continues. How to fix this issue I have built almost 80% of my app and now when I just created new activity it is showing this error, I also deleted the activity but still issue continues. What is the fix for this? Thanks in advance!!
classpath 'com.google.gms:google-services:4.0.1'
And here is my Gradle file:
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.github.ittianyu:BottomNavigationViewEx:2.0.2'
implementation 'me.anwarshahriar:calligrapher:1.0'
implementation 'com.firebaseui:firebase-ui-database:4.3.1'
implementation 'com.google.firebase:firebase-database:16.0.1'
implementation 'com.google.firebase:firebase-auth:16.1.0'
implementation 'com.google.firebase:firebase-core:16.1.0'
implementation 'com.squareup.picasso:picasso:2.5.2'
}
Could not find com.google.firebase:firebase-core:16.1.0"
It happens because firebase-core:16.1.0 doesn't exist (today).
You can check the latest version here. Currently it is 16.0.7
Firebase Core com.google.firebase:firebase-core:16.0.7
Change your dependency in:
implementation 'com.google.firebase:firebase-core:16.0.7'
My app level build.gradle has the following dependencies:
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
compile 'com.android.support:design:26.1.0'
compile 'com.squareup.retrofit2:retrofit:2.3.0'
compile 'com.squareup.retrofit2:converter-gson:2.3.0'
implementation 'com.facebook.android:facebook-login:4.30.0'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.theartofdev.edmodo:android-image-cropper:2.6.0'
compile 'com.google.android.gms:play-services-auth:11.8.0'
compile 'de.hdodenhof:circleimageview:2.2.0'
compile 'com.nexmo:verify:4.0.0'
}
The problem I am having is that the Application crashes once I run it. Now I understand why it's crashing, its because I have that red curly line in compile 'com.google.android.gms:play-services-auth:11.8.0'which says something like all gms/firebase must use the same exact version .
I ran ./gradlew app:dependencies. I think what caused the problem is nexmo is using google firebase messaging 9.8.0 and we have that sign in from google which is 11.8.0. So I commented the Nexmo dependency and sure enough the red curly line in google auth dependency is gone. But I need the nexmo verify.
I also tried changing the google auth dependency version to 9.8.0 to see if that works, but it seems that all the classes for Google Sign in are not available.
The nexmo library seems to use very old dependencies (last commit was 1 year ago)
Add in your build.gradle
compile 'com.google.firebase:firebase-messaging:11.8.0'
Cannot resolve symbol TabLayout ? How to clear this error? Please help me. I already imported import android.support.design.widget.TabLayout;
Had a similar problem, to fix this in Android Studio (AS) I went Build->Clean Project and AS sorted everything out. Make sure in your build.gradle file under dependencies that you have:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:your_api_version_number.0.0'
compile 'com.android.support:design:+'
}
I solved the issue Manually by adding the following two lines:
implementation 'com.android.support:support-v4:22.2.0'
implementation 'com.android.support:design:22.2.0'
under dependencies in \app\build.gradle worked for me.
Note: Your all the support libraries have to be the same version i.e. appcompat-v7 and support-v4 to same version e.g. 23.0.1; otherwise you can get this error
java.lang.NoClassDefFoundError: android.support.v7.internal.widget.TintManager`
after code build
Under Gradle Scripts,
Open build.gradle (Module: app)
Inside of dependencies add
compile 'com.android.support:design:25.3.1'
There may be a newer version of the library available, the android studio lint check may detect that.
The full dependencies area may look like this for reference. The above line is the only one I manually added.
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
compile 'com.android.support:design:25.3.1'
}
An above answer suggested adding
compile 'com.android.support:design:+'
Which is kind of dangerous because it always uses the latest library, you may have trouble isolating bugs with automatic library updates happening in the background.
Android Studio no longer uses "compile", they use "implementation".
Be sure to include the code below when you go to Build Gradle>dependencies{
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:support-v4:27.1.1'
implementation 'com.android.support:design:27.1.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}
For Android API Level 29+, add the following dependency in build.gradle (Module:app):
dependencies {
implementation 'com.google.android.material:material:1.0.0'
}
If there is a newer version available, Android Studio will prompt you to use the newest one.
I solve it by Open build.gradle (Module: app) and add
implementation 'com.android.support:design:+'