I upgraded Android studio and gradle to the latest version and also updated all project dependencies to the latest verison. Today, I discovered an error that 2 dupclicate classes exist in gradle dependencies.
I got this error:
Duplicate class androidx.lifecycle.ViewModelLazy found in modules jetified-lifecycle-viewmodel-ktx-2.3.1-runtime (androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1) and lifecycle-viewmodel-2.5.1-runtime (androidx.lifecycle:lifecycle-viewmodel:2.5.1)
Duplicate class androidx.lifecycle.ViewTreeViewModelKt found in modules jetified-lifecycle-viewmodel-ktx-2.3.1-runtime (androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1) and lifecycle-viewmodel-2.5.1-runtime (androidx.lifecycle:lifecycle-viewmodel:2.5.1)
I tried to fix the error as suggested on the Android developer's official webiste, but can't seem to fix the error. The fix at here didn't work
I also tried some stackoverflow answers but it didn't fix it for me, some didn't suite my case.
This is my grade file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 33
buildToolsVersion "31.0.0"
defaultConfig {
applicationId "com.astrro.timely"
minSdkVersion 16
targetSdkVersion 33
multiDexEnabled true
versionCode 5
versionName "1.3.0"
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
vectorDrawables.useSupportLibrary = true
}
buildTypes {
release {
minifyEnabled false
shrinkResources false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
}
}
// changing the default apk build name from app-debug to proper name
applicationVariants.all {
variant ->
variant.outputs.each {
output ->
output.outputFileName = "TimeLY_v${variant.versionName}.apk"
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'org.jetbrains:annotations:15.0'
implementation 'androidx.appcompat:appcompat:1.5.1'
implementation 'androidx.appcompat:appcompat-resources:1.5.1'
implementation 'com.google.android.material:material:1.7.0'
implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'androidx.fragment:fragment:1.5.5'
implementation 'androidx.recyclerview:recyclerview:1.2.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'androidx.preference:preference:1.2.0'
implementation "androidx.multidex:multidex:2.0.1"
implementation 'androidx.viewpager2:viewpager2:1.0.0'
implementation 'com.google.code.gson:gson:2.8.8'
implementation 'com.kevalpatel2106:ringtonepicker:1.2'
implementation 'net.cachapa.expandablelayout:expandablelayout:2.9.2'
implementation 'org.greenrobot:eventbus:3.2.0'
implementation 'com.github.chrisbanes:PhotoView:2.0.0'
implementation 'com.airbnb.android:lottie:3.7.0'
implementation 'com.github.javiersantos:AppUpdater:2.7'
implementation 'me.zhanghai.android.materialprogressbar:library:1.1.6'
implementation ('com.wdullaer:materialdatetimepicker:4.2.3') {
exclude group: 'androidx.appcompat'
exclude group: 'androidx.recyclerview'
}
// debugImplementation because all these dependencies should only run in debug builds.
debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.7'
}
}
Related
How can I solve this issue? I tried searching in YouTube and Chrome couldn't find the relevant solution for this. There are three issues faced. I tried changing various things in settings and tried different solution but none of those helped
THIS IS BUILD.GRADLE (app):
apply plugin: 'com.android.application'
apply plugin: 'com.jakewharton.butterknife'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 29
buildToolsVersion '29.0.1'
defaultConfig {
applicationId "com.pdf.scanner.queenscanner"
minSdkVersion 16
targetSdkVersion 31
versionCode 1
versionName '1.1'
multiDexEnabled true
//Photo editor
renderscriptTargetApi 23
renderscriptSupportModeEnabled true
android.defaultConfig.javaCompileOptions.annotationProcessorOptions.includeCompileClasspath = true
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dexOptions {
javaMaxHeapSize "4g"
}
//Photo editor
dataBinding {
enabled = true
}
lintOptions {
checkReleaseBuilds false
// Or, if you prefer, you can continue to check for errors in release builds,
// but continue the build even when errors are found:
abortOnError false
}
}
repositories {
maven { url "http://jitpack.io" }
//tedpicker
maven { url "http://repo.commonsware.com.s3.amazonaws.com" }
maven { url "http://s3.amazonaws.com/repo.commonsware.com" }
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'androidx.appcompat:appcompat:1.5.1'
implementation 'com.google.android.material:material:1.7.0'
//Add library
implementation 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'
//hungdh
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation project(':openCVLibrary310')
//Photo editor
// annotationProcessor 'ly.img.android:photo-editor-sdk:2.0.27'
// compile 'ly.img.android:photo-editor-sdk:2.0.27'
//OCR
implementation 'com.rmtheis:tess-two:6.1.1'
implementation 'com.github.mthli:Knife:v1.1'
//Opennote
implementation 'com.google.zxing:core:3.3.3'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
//compile 'com.github.ctodobom:OpenCV-3.1.0-Android:9e00ee4218ca0c9e60a905c9f09bf499f9dc5115'
implementation 'us.feras.mdv:markdownview:1.1.0'
implementation 'com.github.ctodobom:drag-select-recyclerview:0.3.4.ctodobom.sections'
implementation 'com.github.nostra13:Android-Universal-Image-Loader:v1.9.5'
implementation 'com.github.ctodobom:FabToolbar:3c5f0e0ff1b6d5089e20b7da7157a604075ae943'
//Simple document scanner
implementation 'com.afollestad.material-dialogs:core:0.8.5.9'
implementation 'com.jakewharton.timber:timber:4.1.2'
//ImagetoPDF
implementation project(':tedpicker')
implementation project(':photo-editor-sdk-2.0.27')
implementation 'com.itextpdf:itextg:5.5.9'
implementation 'com.balysv:material-ripple:1.0.2'
implementation 'com.jakewharton:butterknife:10.2.1'
implementation 'com.google.firebase:firebase-analytics:21.2.0'
annotationProcessor 'com.jakewharton:butterknife-compiler:10.2.1'
implementation 'androidx.multidex:multidex:2.0.1'
//Auto mail
implementation 'com.github.yesidlazaro:GmailBackground:1.2.0'
implementation 'com.github.nextcloud:android-library:-SNAPSHOT'
//filter_image
implementation 'it.chengdazhi.styleimageview:styleimageview:1.0.4'
//photoview
implementation 'com.github.chrisbanes:PhotoView:2.1.3'
implementation 'com.google.android.gms:play-services-ads:21.3.0'
//sửa là lỗi (lúc có firebase-core)
//implementation files('/libs/photo-editor-sdk-2.0.14.aar')
implementation 'com.github.clans:fab:1.6.4'
implementation 'com.facebook.android:facebook-android-sdk:5.13.0'
implementation 'com.facebook.android:audience-network-sdk:5.8.0'
implementation project(path: ':dynamicgrid')
}
You could download the corresponding JAR file directly from the package's Maven repository site and put it into the libs directory of your project. This earlier Stackoverflow thread might be helpful in the details.
Here is my build.gradle(:app) file:
plugins {
id 'com.android.application'
}
[enter image description here][1]
android {
compileSdk 32
defaultConfig {
applicationId "com.example.peon"
minSdk 21
targetSdk 32
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildFeatures{
viewBinding true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'com.google.android.material:material:1.5.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
implementation 'androidx.mediarouter:mediarouter:1.3.0'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
implementation 'io.github.chaosleung:pinview:1.4.4'
implementation platform('com.google.firebase:firebase-bom:29.3.1')
implementation 'com.google.firebase:firebase-analytics'
implementation 'com.google.firebase:firebase-auth'
implementation 'com.google.firebase:firebase-database'
implementation 'com.google.firebase:firebase-storage'
implementation 'de.hdodenhof:circleimageview:3.1.0'
implementation 'com.github.bumptech.glide:glide:4.13.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.13.0'
implementation "com.github.pgreze:android-reactions:1.6"
implementation("app.futured.donut:donut:2.2.2")
implementation 'com.github.OMARIHAMZA:StoryView:1.0.6-alpha'
}
enter code here
apply plugin: 'com.google.gms.google-services'
**It shows: Failed to resolve: **
[1]: https://i.stack.imgur.com/zbOc1.png
I've tried to use double quotes, clean and rebuild the project, as well as restarting my android studio. Yet I can't solve this problem. Am I missing something? Thanks in advance.
enter image description here
Hi I'm learning Android studio new and I bought the source from CodeCanyon and solved some errors, but I got stuck in this error:
No variants found for ':app'. Check build files to ensure at least one variant exists.
I checked cdk tools and everything seems fine and I also searched for answers and tried them but I couldn't solve this error.
here is my code :
apply plugin: 'com.android.application'
android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
defaultConfig {
applicationId 'com.quraan.farroukh'
minSdkVersion 17
targetSdkVersion 29
versionCode 1
versionName "1.0"
ndk {
ndk.abiFilters 'armeabi-v7a','arm64-v8a','x86','x86_64'
}
}
lintOptions {
checkReleaseBuilds false
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
productFlavors {
}
}
dependencies{
task wrapper(type: Wrapper){
gradleVersion = '2.14.1'
}
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'com.google.android.material:material:1.3.0'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.browser:browser:1.3.0'
implementation 'androidx.recyclerview:recyclerview:1.2.1'
implementation 'com.google.android.gms:play-services-ads:20.2.0'
implementation 'com.google.android.gms:play-services-analytics:17.0.0'
implementation 'com.google.android.gms:play-services-analytics-impl:17.0.0'
implementation 'com.github.varunest:sparkbutton:1.0.6'
implementation 'com.airbnb.android:lottie:3.6.1'
implementation 'com.github.glomadrian:Grav:1.1'
implementation 'hanks.xyz:htextview-library:0.1.5'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation 'com.intuit.sdp:sdp-android:1.0.6'
implementation 'io.saeid:fab-loading:1.0.0'
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.balysv:material-ripple:1.0.2'
implementation 'de.hdodenhof:circleimageview:3.1.0'
}
I guess, you probably didn't install SDK 29.
Go to File->Settings->Appearance and Behaviour->System Settings->Android SDK
Check the specific version of API Level and install it if it's missing
It's my first time building AAR
The official site says that All I hate to do is build APK and AAR will be assembled
Here's the quote:
But when I choose "Build Apk(s)" nothing happens.
Another tutorial says I have to choose Gradle-> library name -> tasks-> build-> :assembleRelease.
But there is no such thing :
How can I assemble library as AAR?
here's my gradle :
plugins {
id 'com.android.library'
id 'kotlin-android'
id 'kotlin-kapt'
}
android {
compileSdkVersion 29
buildToolsVersion "29.0.3"
defaultConfig {
minSdkVersion 17
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.3.2'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.2.1'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
def room_version = "2.2.3"
implementation "androidx.room:room-runtime:$room_version"
kapt "androidx.room:room-compiler:$room_version"
implementation "androidx.room:room-ktx:$room_version"
implementation "androidx.room:room-rxjava2:$room_version"
implementation 'com.google.code.gson:gson:2.8.2'
}
Just click assemble or add buildTypes.debug. While you don't have buildTypes.debug defined, it won't generate the tasks you are looking for (as there only is one configuration present there and so there is nothing to tell apart).
Duplicate class
android.support.v4.accessibilityservice.AccessibilityServiceInfoCompat
found in modules classes.jar
(com.android.support:support-compat:28.0.0) and classes.jar
(com.android.support:support-v4:24.0.0)
and so on so many errors like this
android {
compileSdkVersion 28
buildToolsVersion "28.0.3"
defaultConfig {
applicationId "com.example.sakhi.live_scoure"
minSdkVersion 21
targetSdkVersion 28
versionCode 1
versionName "1.0"
multiDexEnabled = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dexOptions {
preDexLibraries = false
javaMaxHeapSize "4g"
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
testImplementation 'junit:junit:4.12'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support:recyclerview-v7:28.0.0'
implementation 'com.android.volley:volley:1.1.0'
implementation 'com.google.android.gms:play-services:10.0.1'
implementation 'com.jakewharton:butterknife:8.8.1'
implementation 'com.squareup.picasso:picasso:2.71828'
implementation files('libs/awais.jar')
implementation 'com.android.support:support-vector-drawable:28.0.0'
implementation 'com.android.support:multidex:1.0.3'
implementation project(':dBPullToRefresh')
}
apply plugin: 'com.getkeepsafe.dexcount'
you are using older GCM Service, you can resolve by replace this line 'com.google.android.gms:play-services:10.0.1' To 'com.google.android.gms:play-services-gcm:16.1.0'
by replacing this line you can resolve but i will suggest you to upgrade GCM to FCM (firebase messaging) because GCM is now shutdown his services.