Failed to resolve com.androidAffected Modules and com.loopjAffected Modules in android - android

Failed to resolve com.androidAffected Modules and com.loopjAffected Modules in android.
I have checked with different links but I am confused.
Below is my App build file
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.XXX.XXXX"
minSdkVersion 21
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:25.3.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:cardview v7:25.3.1'
implementation 'com.github.bumptech.glide:glide:3.6.1'
implementation 'me.dm7.barcodescanner:zxing:1.8.4'
implementation 'com.loopj.android:androidasync http:1.4.9'
implementation 'com.google.code.gson:gson:2.6.2'
implementation project(':merchantsdk')
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'
}
MerchantSDK is the aar file which is imported into this project and then I build giving below exceptions
Failed to resolve com.androidAffected Modules and
Failed to resolve com.loopjAffected Modules
Please help me on this.Thanks in advance.

If it is an AAR file you can keep it "lib" folder. You can add dependancy for this AAR in build.gradle as follows: -
implementation "packagename of aar:aar filename:#aar"
Replace package name and filename of AAR.
In build.gradle file of main project add this: -
allprojects {
repositories {
flatDir { dirs 'libs' }
}
}

Related

Android Gradle project sync failed due to unresolved dependency

I recently added a card-stack-view dependency (implementation 'com.yuyakaido.android:card-stack-view:2.3.4') to my app level build.gradle and after that my project is giving syncing failure like:-
ERROR: Failed to resolve: androidx
Affected Modules: app
This is my build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.animeapp.brijender.myapp"
minSdkVersion 19
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:run ner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'com.miguelcatalan:materialsearchview:1.4.0'
implementation 'androidx.recyclerview:recyclerview:1.0.0'
implementation 'com.squareup.retrofit2:retrofit:2.5.0'
implementation 'com.squareup.retrofit2:converter-gson:2.1.0'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'com.google.android.material:material:1.0.0'
implementation 'com.yuyakaido.android:card-stack-view:2.3.4'
}
Can anyone help what i might be doing wrong?
Just add jCenter repository in project’s build.gradle (or if you are using the new way just add it in your settings.gradle)
pluginManagement {
repositories {
gradlePluginPortal()
google()
mavenCentral()
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
jcenter()
}
}
include ':app'
Just Needed to remove these dependencies androidTestImplementation 'androidx.test:run ner:1.2.0' androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'

Shows Please make sure you have the required dependencies in the classpath: class com.google.android.gms.vision.barcode.Barcode

Everything was working fine until I added implementation 'com.google.android.gms:play-services-ads:18.2.0' this dependency for showing ads in-app.
I am getting below error message while building the application. error gets removed if I remove ad library.
Supertypes of the following classes cannot be resolved. Please make sure you have the required dependencies in the classpath:
class com.google.android.gms.vision.barcode.Barcode, unresolved supertypes: com.google.android.gms.internal.zzbck
App level build.gradle
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 29
defaultConfig {
applicationId "com.creatorisone.chargingtheftsecurityalarm"
minSdkVersion 16
targetSdkVersion 29
versionCode 1
versionName "1.04"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
buildTypes {
release {
shrinkResources true
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), "proguard-rules.pro"
}
}
configurations {
cleanedAnnotations
compile.exclude group: 'org.jetbrains', module: 'annotations'
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.google.android.material:material:1.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'org.jetbrains:annotations-java5:17.0.0'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.50"
implementation 'xyz.belvi.mobilevision:barcodescanner:2.0.3'
implementation 'androidx.fragment:fragment:1.2.0-alpha02'
implementation 'com.google.zxing:core:3.3.3'
implementation 'com.journeyapps:zxing-android-embedded:3.2.0#aar'
implementation 'com.google.android.gms:play-services-ads:18.2.0'
}
repositories {
mavenCentral()
}
I have tried multiple solutions provided on StackOverflow but nothing is working in my case
"Error: Supertypes of the following classes cannot be resolved. Please make sure you have the required dependencies in the classpath"
error in Location Request class in android with kotlin
error: supertypes of the following classes cannot be resolved. Please make sure you have the required dependencies in the classpath
"Supertypes of the following classes cannot be resolved.” in Task:app:buildInfoGeneratorDebug
I have faced same problem and its resolve by adding
implementation 'com.google.android.gms:play-services-vision:15.0.2'

How to get dependencies right for WorkManager and LocationServices?

I've been unable to get the dependencies right for an app that uses a worker for obtaining device locations. I suspect that I'm using the wrong location service with androidx, but I haven't found anything else. Here's my build.gradle:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-android'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.exelor.laytrax"
minSdkVersion 23
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.1.0-alpha05'
implementation 'androidx.core:core-ktx:1.0.2'
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-alpha1'
implementation 'androidx.work:work-runtime:2.1.0-alpha02'
implementation 'com.google.android.material:material:1.1.0-alpha06'
implementation ('com.google.android.gms:play-services-location:16.0.0') {
exclude group: 'com.android.support'
}
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
}
I'm excluding com.android.support to avoid build exceptions, such as
Duplicate class android.support.v4.os.ResultReceiver$MyRunnable found in modules classes.jar (androidx.core:core:1.1.0-beta01) and classes.jar (com.android.support:support-compat:26.1.0)
At runtime in worker doWork():
fusedLocationClient = LocationServices.getFusedLocationProviderClient(context.applicationContext)
throws this exception:
Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/v4/util/ArraySet;
at com.google.android.gms.common.api.internal.GoogleApiManager.<init>(Unknown Source:29)
My problem was not having a gradle.properties file containing
android.enableJetifier=true
android.useAndroidX=true

Error: Program type already present: org.hamcrest.CoreMatchers

When I build my app, I get the following error: Program type already present:org.hamcrest.CoreMatchers.
1:30 AM Gradle sync failed (6s 290ms)
This is my build.gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.ercess.ercess_app"
minSdkVersion 17
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0-rc01'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
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.squareup.picasso:picasso:2.71828'
implementation group: 'com.android.support', name: 'design', version: '28.0.0-rc01'
implementation 'com.basgeekball:awesome-validation:4.2'
implementation 'org.apache.httpcomponents:httpclient:4.4-alpha1'
implementation group: 'com.googlecode.json-simple', name: 'json-simple', version: '1.1.1'
}
You're getting this error from D8 because the runtime classpath contains multiple definitions for org.hamcrest.CoreMatchers.
On how to fix it check out the answer on issue tracker: https://issuetracker.google.com/issues/77499230
Sync your project in Android Studio, go Navigate -> Class, make sure "Include non-project classes" checkbox is selected, and type "org.intellij.lang.annotations.Identifier". Android Studio should show you jars that contain contain this type. If you are familiar with excluding transitive dependencies, excluding one of Maven dependencies that contain org.intellij.lang.annotations.Identifier should fix your issue.
Where in your case instead of org.intellij.lang.annotations.Identifier use org.hamcrest.CoreMatchers.

error after push and pull from git

i had a android studio project and it was wroks. I had push it to gitlab and after remove it , i had pull it again.
now i get this error when i want to build my gradle:
Error:The module 'app' is an Android project without build variants, and cannot be built.Please fix the module's configuration in the build.gradle file and sync the project again.
it's my build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion "26.0.0"
defaultConfig {
applicationId "sample.spart.com"
minSdkVersion 21
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
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'
implementation 'com.android.support:support-v4:26.1.0'
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'
implementation 'com.android.support:cardview-v7:27.0.2'
implementation 'com.android.support:design:27.0.2'
implementation 'com.nineoldandroids:library:2.4.0'
implementation 'com.android.support:recyclerview-v7:26.0.0-alpha1'
}
what is the problem and how i can fix it??
Maybe you can try invalidating your cash.
in Android Studio:
File -> Invalidate Caches / Restart
Sharing your project's build.gradle file may help.

Categories

Resources