Unresolved dependencies in Android Studio project - android

Issue: I've recently updated/installed the latest version of Android Studio and I imported a little old project. When I sync the project I get these errors:
The errors are as follows:
Failed to resolve: com.google.android.gms:play-services-ads-identifier:12.0.1
Show in Project Structure dialog
Affected Modules: app
Failed to resolve: com.google.firebase:firebase-measurement-connector:12.0.1
Show in Project Structure dialog
Affected Modules: app
I tried to add all the necessary elements to the gradle and I tried installing Google Play Services in SDK. My project is imported from the Desktop.
This is my app/build.gradle:
buildscript {
repositories {
maven { url 'https://plugins.gradle.org/m2/' }
}
dependencies {
classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:0.12.0'
}
}
apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'
repositories {
maven { url 'https://maven.google.com' }
}
apply plugin: 'com.android.application'
android {
compileSdkVersion 29
defaultConfig {
applicationId "com.albetaqasite"
manifestPlaceholders = [
onesignal_app_id : 'cc95bb51-0699-4309-9322-be8793d5e564',
// Project number pulled from dashboard, local value is ignored.
onesignal_google_project_number: 'REMOTE']
minSdkVersion 15
targetSdkVersion 29
versionCode 55
versionName "3.4.1"
multiDexEnabled true
dexOptions {
javaMaxHeapSize "4g"
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
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
}
useLibrary 'org.apache.http.legacy'
}
repositories {
maven {
url "https://jitpack.io"
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation files('libs/android-async-http-1.4.4.jar')
implementation project(':ColorDialog')
implementation files('libs/universal-image-loader-1.9.4.jar')
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:support-v4:27.1.1'
implementation 'com.android.support:cardview-v7:27.1.1'
//implementation 'cn.pedant.sweetalert:library:1.3'
implementation 'com.github.f0ris.sweetalert:library:1.5.1'
implementation 'com.google.code.gson:gson:2.3.1'
implementation 'com.google.android.gms:play-services:8.4.0'
implementation 'com.squareup.picasso:picasso:2.5.2'
implementation 'com.squareup.okhttp:okhttp:2.+'
implementation 'com.squareup.okhttp:okhttp-urlconnection:2.+'
implementation 'com.google.android.gms:play-services-ads:8.4.0'
implementation 'com.google.android.gms:play-services-identity:8.4.0'
//compile 'com.google.android.gms:play-services-gcm:8.4.0'
implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.7'
implementation 'com.onesignal:OneSignal:[3.8.3, 3.99.99]'
// compile 'com.google.firebase:firebase-core:8.4.0'
}
apply plugin: 'com.google.gms.google-services'
This is my Project/build.gradle:
buildscript {
repositories {
google()
mavenCentral()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.1'
classpath 'com.google.gms:google-services:4.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
mavenCentral()
maven {
url "https://maven.google.com" // Google's Maven repository
} }
}
dependencies {
}
P.S: I'm aware of the problem in android.com.support dependencies, when I change the compileSdkVersion and targetSdkVersion to 27 it works, but the gradle ones I couldn't fix, kindly share your knowledge and experience if you've ever encountered this or have any idea how to solve it.

I think you need to add entries for those dependencies down in the section near these entries:
implementation 'com.google.android.gms:play-services:8.4.0'
implementation 'com.google.android.gms:play-services-ads:8.4.0'
implementation 'com.google.android.gms:play-services-identity:8.4.0'
However, if you try to bring in version 12.0.1 of one library, and version 8.4.0 of another related library, you are probably going to have issues. See if you can bump up the version number of these three to 12.0.1

Related

Can't make or build project: Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'

Everything was working fine. In my application, I was using Picasso to show images and by default Picasso rotate images by 90 degrees. I wanted to replace with Glide, I tried including Glide in the project. Since then I'm getting this error even though I removed Glide from my project I can't build my project anymore. Here are my Gradles.
Project.gradle
buildscript {
repositories {
google()
maven {
url "https://maven.google.com"
}
maven {
url 'https://maven.fabric.io/public'
}
jcenter()
}
dependencies {
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.android.tools.build:gradle:3.4.2'
classpath 'com.google.gms:google-services:4.2.0'
classpath 'io.fabric.tools:gradle:1.31.0'
}
}
allprojects {
repositories {
google()
maven { url "https://maven.google.com" }
maven { url "https://jitpack.io" }
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
App.gradle
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'io.fabric'
android {
compileSdkVersion 28
defaultConfig {
applicationId "xxx"
minSdkVersion 21
targetSdkVersion 28
versionCode 40
versionName "0.0.97"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions
{
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
dexOptions {
javaMaxHeapSize "8g"
}
useLibrary 'org.apache.http.legacy'
}
repositories {
maven { url "https://jitpack.io" }
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'com.google.firebase:firebase-messaging:19.0.1'
implementation 'com.google.firebase:firebase-inappmessaging-display:18.0.1'
implementation 'com.google.firebase:firebase-dynamic-links:18.0.0'
implementation 'com.mcxiaoke.volley:library:1.0.19'
implementation 'gun0912.ted:tedpermission:2.2.2'
implementation 'com.google.android.material:material:1.0.0'
implementation 'com.github.BlacKCaT27:CurrencyEditText:2.0.2'
implementation 'com.github.CardinalNow:Android-CircleProgressIndicator:v0.2'
implementation 'com.txusballesteros:FitChart:1.0'
implementation 'androidx.multidex:multidex:2.0.1'
implementation 'com.google.code.gson:gson:2.8.5'
implementation 'com.google.firebase:firebase-core:17.0.1'
implementation 'com.crashlytics.sdk.android:crashlytics:2.10.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}
Please help.
Try this:
Go To File >> Invalidate caches and restart.
If it doesn't help, then try that manually like this:
Close Android Studio
Go to C:\Users\UserName\.android and rename:
build-cache folder to build-cache.bak
Go to C:\Users\UserName\.AndroidStudio3.4.2\system and rename these folders:
caches to caches.bak
compiler to compiler.bak
compile-server to compile-server.bak
conversion to conversion.bak
external_build_system to external_build_system.bak
frameworks to frameworks.bak
gradle to gradle.bak
resource_folder_cache to resource_folder_cache.bak
Open the Android Studio and open your project again. Hope it helps.
1- Add this
android {
defaultConfig {
multiDexEnabled true
}
}
sync project
Clean
build
Try adding these two dependencies and let me know,
implementation "android.arch.core:runtime:1.1.0"
implementation "android.arch.core:common:1.1.0"

Android - Getting multiple errors while building the project

I am getting these errors while building the project
Failed to resolve: firebase-core
Failed to resolve: multidex
Failed to resolve: play-services-ads
Failed to resolve: play-services-auth
Failed to resolve: firebase-auth-license
Failed to resolve: common
Please check and let me know how this issue can be resolved?
plugins {
id 'com.onesignal.androidsdk.onesignal-gradle-plugin' version '0.8.1'
}
apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion '27.0.3'
defaultConfig {
applicationId "com.test.android"
minSdkVersion 15
targetSdkVersion 26
versionCode 3
versionName "1.0.2"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
multiDexEnabled true
manifestPlaceholders = [onesignal_app_id : "65f11821-8462-4ec4-9e41-XXXXXXXX",
// Project number pulled from dashboard, local value is ignored.
onesignal_google_project_number: "91629XXXXX00"]
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
targetCompatibility 1.8
sourceCompatibility 1.8
}
}
dependencies {
implementation 'com.google.firebase:firebase-auth:11.6.0'
implementation fileTree(include: ['*.jar'], dir: 'libs')
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
// applovin
implementation project(':unity-ads')
//unity ads
//compile 'com.google.android.gms:play-services-ads:11.0.4'
implementation 'com.android.support:appcompat-v7:26.+'
implementation 'com.android.support:design:26.+'
implementation 'com.android.support:support-vector-drawable:26.+'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.android.support:support-v4:26.+'
implementation 'com.google.android.gms:play-services:11.6.0'
implementation 'com.android.support:multidex:1.0.1'
//compile 'com.github.cooltechworks:ScratchView:v1.1'//not used
implementation 'com.jackpocket:scratchoff:1.1.0'
implementation 'com.adcolony:sdk:3.2.1'
implementation 'com.android.support:support-annotations:26.0.1'
implementation 'com.google.android.gms:play-services-ads:11.6.0'
implementation 'com.android.support:cardview-v7:26.1.0'
implementation 'com.facebook.android:facebook-share:[4,5)'
testImplementation 'junit:junit:4.12'
implementation 'com.ironsource.sdk:mediationsdk:6.7.0.1#jar'
//compile 'com.google.ads.mediation:unity:2.1.1.0' //not used
implementation 'com.google.firebase:firebase-database:11.6.0'
implementation 'com.github.bumptech.glide:glide:4.1.1'
implementation 'commons-net:commons-net:3.3'
//get server time
//compile 'com.github.instacart.truetime-android:library-extension-rx:2.0'
//compile 'com.github.instacart.truetime-android:library:2.0' // not used
implementation 'com.google.firebase:firebase-auth:11.6.0'
implementation 'com.google.firebase:firebase-core:11.6.0'
implementation 'com.google.android.gms:play-services-auth:11.6.0'
implementation 'com.squareup.retrofit2:retrofit:2.3.0'
implementation 'com.onesignal:OneSignal:[3.7.1, 3.99.99]'
implementation files('libs/applovin-sdk-7.7.0-javadoc.jar')
implementation files('libs/applovin-sdk-7.7.0.jar')
}
apply plugin: 'com.google.gms.google-services'
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.0-alpha09'
classpath 'com.google.gms:google-services:3.1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
maven { url "https://maven.google.com" }
maven { url "https://jitpack.io" }
maven { url "https://adcolony.bintray.com/AdColony" }
maven { url "https://dl.bintray.com/ironsource-mobile/android-sdk" }
google()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Apparently, jcenter has started mirroring Google's repo. Try moving google() before jcenter() in the allprojects section of your project's build.gradle (like this):
repositories {
google()
jcenter()
maven { url "https://maven.google.com" }
maven { url "https://jitpack.io" }
maven { url "https://adcolony.bintray.com/AdColony" }
maven { url "https://dl.bintray.com/ironsource-mobile/android-sdk" }
}
Have you tried rebuilding the app? Also make sure you are using the latest version of GMS. As a sidenote you dont need to add the entire gms library, you can add selective services. I see you have added gms- and gms-ads, which would already be included in the main gms.

Facing several errors while building the project in Android [duplicate]

This question already has answers here:
Android - Getting multiple errors while building the project
(2 answers)
Closed 4 years ago.
I am getting these errors after importing the android project
Failed to resolve: firebase-core
Open File
Failed to resolve: multidex
Open File
Failed to resolve: play-services-ads
Open File
Failed to resolve: play-services-auth
Open File
Failed to resolve: firebase-auth-license
Open File
Failed to resolve: common
Show in File
I am unable to know the exact reason of this issue. Please check.
build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.0-alpha09'
classpath 'com.google.gms:google-services:3.1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
maven { url "https://maven.google.com" }
maven { url "https://jitpack.io" }
maven { url "https://adcolony.bintray.com/AdColony" }
maven { url "https://dl.bintray.com/ironsource-mobile/android-sdk" }
google()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
app level build.gradle
plugins {
id 'com.onesignal.androidsdk.onesignal-gradle-plugin' version '0.8.1'
}
apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion '27.0.3'
defaultConfig {
applicationId "com.test.android"
minSdkVersion 15
targetSdkVersion 26
versionCode 3
versionName "1.0.2"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
multiDexEnabled true
manifestPlaceholders = [onesignal_app_id : "65f11821-8462-4ec4-9e41-XXXXX",
// Project number pulled from dashboard, local value is ignored.
onesignal_google_project_number: "916XXXXXXX00"]
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
targetCompatibility 1.8
sourceCompatibility 1.8
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
// applovin
implementation project(':unity-ads')
//unity ads
//compile 'com.google.android.gms:play-services-ads:11.0.4'
implementation 'com.android.support:appcompat-v7:26.+'
implementation 'com.android.support:design:26.+'
implementation 'com.android.support:support-vector-drawable:26.+'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.android.support:support-v4:26.+'
//implementation 'com.google.android.gms:play-services:11.6.0'
implementation 'com.android.support:multidex:1.0.1'
//compile 'com.github.cooltechworks:ScratchView:v1.1'//not used
implementation 'com.jackpocket:scratchoff:1.1.0'
implementation 'com.adcolony:sdk:3.2.1'
implementation 'com.android.support:support-annotations:26.0.1'
implementation 'com.google.android.gms:play-services-ads:11.6.0'
implementation 'com.android.support:cardview-v7:26.1.0'
implementation 'com.facebook.android:facebook-share:[4,5)'
testImplementation 'junit:junit:4.12'
implementation 'com.ironsource.sdk:mediationsdk:6.7.0.1#jar'
//compile 'com.google.ads.mediation:unity:2.1.1.0' //not used
implementation 'com.google.firebase:firebase-database:11.6.0'
implementation 'com.github.bumptech.glide:glide:4.1.1'
implementation 'commons-net:commons-net:3.3'
//get server time
//compile 'com.github.instacart.truetime-android:library-extension-rx:2.0'
//compile 'com.github.instacart.truetime-android:library:2.0' // not used
implementation 'com.google.firebase:firebase-auth:11.6.0'
implementation 'com.google.firebase:firebase-core:11.6.0'
implementation 'com.google.android.gms:play-services-auth:11.6.0'
implementation 'com.squareup.retrofit2:retrofit:2.3.0'
implementation 'com.onesignal:OneSignal:[3.7.1, 3.99.99]'
implementation files('libs/applovin-sdk-7.7.0-javadoc.jar')
implementation files('libs/applovin-sdk-7.7.0.jar')
}
apply plugin: 'com.google.gms.google-services'
EDIT: Unfortunately, I've belatedly realized that this question was a duplicate. Please refer to the answer here instead. (I'm also leaving this duplicate answer text here for now - although it will probably eventually be deleted - to preserve the solution that the original poster marked as correct.)
Apparently, jcenter has started mirroring Google's repo. Try moving google() before jcenter() in the allprojects section of your project's build.gradle (like this):
repositories {
google()
jcenter()
maven { url "https://maven.google.com" }
maven { url "https://jitpack.io" }
maven { url "https://adcolony.bintray.com/AdColony" }
maven { url "https://dl.bintray.com/ironsource-mobile/android-sdk" }
}
Try another version of this APIs. And you should to declare constant version and use it like {$const} then your gradle will be less error prone about versions difference.

Failed to resolve: common Android Studio

I am recently getting this error message on gradle build/sync:
Image of the Error
When I click on "open file", it switches to the build.gradle (App) window.
I am not getting any solution for this on stackoverflow. Please check the code and let me know the issue.
I would really appreciate your help.
build.gradle (Project)
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
mavenCentral()
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.3'
classpath 'com.google.gms:google-services:3.3.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
maven {
url "https://jitpack.io"
}
maven {
url "https://maven.google.com" // Google's Maven repository
}
google()
}
dependencies {
/*compile('javax.inject:javax.inject:1',
'com.google.dagger:dagger:2.7',
'de.greenrobot:eventbus:2.2.1',
'io.reactivex:rxjava:1.2.0',
'io.reactivex:rxandroid:1.2.1')
compile files('libs/publisher-sdk-android-5.1.0.jar')*/
}
}
build.gradle (App)
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
buildToolsVersion '27.0.3'
defaultConfig {
applicationId "com.appname"
minSdkVersion 15
targetSdkVersion 27
versionCode 1
versionName "1.0"
//multiDexEnabled = false
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
/*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
}*/
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
//noinspection GradleCompatible
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.1'
implementation 'com.android.support:support-v4:27.1.1'
// Vungle SDK
//implementation 'com.github.vungle:vungle-android-sdk:6.2.5'
// Optional Google Play Services - Location and Basement
implementation 'com.google.android.gms:play-services-location:15.0.1'
implementation 'com.google.android.gms:play-services-ads:15.0.1'
//Replace it with Google Analytics?
implementation 'com.google.firebase:firebase-core:16.0.0'
implementation 'com.google.firebase:firebase-auth:16.0.1'
implementation 'com.google.firebase:firebase-database:16.0.1'
implementation 'com.google.firebase:firebase-database:16.0.1'
implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.10'
implementation 'org.jsoup:jsoup:1.8.3'
implementation 'com.github.simbiose:Encryption:2.0.1'
testImplementation 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
use these
Check first
Go to Settings/Preferences > Build, Execution, Deployment option > Instant Run and uncheck all the three boxes.
1. Upgrading Gradle services URL:
Project > Gradle > Wrapper > gradle-wrapper.properties
Change URL from
distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
to
distributionUrl=https\://services.gradle.org/distributions/gradle-4.7-all.zip
(Find latest distributionUrl gradle plugin version Here: http://services.gradle.org/distributions
**Make sure to use gradle-x.xx-all.zip )
2. Delete your build folder
When you run project, build folder will be created automatically
3. Go to BUILD option in menu > Clean the project, Build the project
It should work without instant run.

Android Studio: Gradle Build Error No repositories are defined

Andriod Studio 3.3.1
gradle 4.4
I added firebase storage through the Android > Tools > Firebase option. However when I sync the gradle the build fails. This is the error that I'm getting:
Cannot resolve external dependency com.google.gms:google-services:3.2.1
because no repositories are defined. Required by:project :app
Does anyone know how to correct this error?
build.gradle (Module: APP)
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.example.test"
minSdkVersion 16
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
targetCompatibility 1.8
sourceCompatibility 1.8
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
implementation 'com.android.support:support-v4:27.1.1'
implementation 'com.google.firebase:firebase-core:15.0.0'
implementation 'com.google.firebase:firebase-storage:15.0.0'
implementation 'com.google.firebase:firebase-auth:15.0.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:design:27.1.1'
//implementation 'com.google.android.gms:play-services:11.0.4'
}
buildscript {
dependencies {
classpath 'com.google.gms:google-services:3.2.1'
}
}
apply plugin: 'com.google.gms.google-services'
In my case, I have to add below code to project level gradle:
allprojects {
repositories {
google()
jcenter()
}
}
The error indicates that repositories is missing in order to determine from where google-services will be downloaded.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.google.gms:google-services:3.2.1'
}
}
jcenter is a reference to bintray jcenter. Gradle can find the google-services:3.2.1 there.
In my case I was able to get it working by adding another repository scope to the top level.
repositories {
mavenLocal()
mavenCentral()
}
I was inspired to do so by this example.

Categories

Resources