Failed to resolve: common Android Studio - android

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.

Related

Unresolved dependencies in Android Studio project

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

Gradle build fails because of firebase-auth dependency

I have updated the firebase-auth dependency version but gradle build always fails. It was working fine for 16.0.1
Error Unable to resolve dependency for ':app#debug/compileClasspath': Could not resolve com.google.firebase:firebase-auth:16.0.2.
app level gradle file
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.example.dell.pitchpls"
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'
}
}
buildToolsVersion '27.0.3'
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support:design:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
implementation 'com.android.support:support-v4:26.1.0'
implementation 'com.android.support:cardview-v7:26.1.0'
implementation 'com.google.firebase:firebase-auth:16.0.2'
//implementation 'com.google.firebase:firebase-core:16.0.0'
implementation 'com.google.firebase:firebase-database:16.0.1'
implementation 'com.google.firebase:firebase-storage:16.0.1'
implementation 'com.firebaseui:firebase-ui-database:3.0.0'
implementation 'com.squareup.picasso:picasso:2.5.2'
implementation 'com.squareup.okhttp:okhttp:2.5.0'
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'
}
apply plugin: 'com.google.gms.google-services'
Project level gradle file
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.0'
classpath 'com.google.gms:google-services:4.0.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
The problem is resolved following this question. Just had to uncheck the offline work in setting/gradle
Try These steps:
Open Module setting of the application
Under Dependencies tab click on '+' symbol and add dependency manually a
Click on apply.
Firebase Documentation
If you visit this link and scroll down to add dependency section, you will find out that gradle dependency version is 16.0.1 only
Also, to avoid such errors, let Android Studio do automatically for you.
For this, in Android Studio, go to:
Tools-->Firebase (This will open a Firebase Assistant)
Now choose your category like Authentication,Analytics,Cloud Messaging,etc --> Click on "Setup your category" and proceed with the steps mentioned there. It will automatically add all the gradle files and generated JSON file.

Android Studio 3.1 stuck at Configure Build over 30 Minutes

So I just updated my Android Studio to 3.1 from 3.0.1. As I am typing this, over 30 minutes have been passed and Android Studio is stuck at Configure build.
What have I done:
change gradle version in project gradle file
checked my internet (it is working fine)
Below is a snapshot of my screen with internet results
These dependencies in particular are taking all the time.
My project build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
mavenCentral()
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
And here is my application build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.smk.carsapp"
minSdkVersion 19
targetSdkVersion 27
versionCode 1
versionName "1.0"
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
configurations {
all*.exclude group: 'com.squareup.okhttp3', module: 'okhttp'
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:27.1.0'
implementation 'com.android.support:exifinterface:27.1.0'
implementation 'com.android.support:support-v13:27.1.0'
implementation 'com.android.support:cardview-v7:27.1.0'
implementation 'com.android.support:design:27.1.0'
implementation 'com.google.code.gson:gson:2.8.2'
implementation 'com.wdullaer:materialdatetimepicker:3.5.1'
implementation 'com.squareup.okhttp3:okhttp:3.10.0'
implementation 'com.github.bumptech.glide:glide:4.6.1'
implementation 'com.jsibbold:zoomage:1.1.0'
implementation 'com.siclo.ezphotopick:library:1.0.8'
// TEST
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'
implementation files('libs/ksoap2-android-assembly-3.6.2-jar-with-dependencies.jar')
}
repositories {
mavenCentral()
maven {
url 'https://dl.bintray.com/siclo/SicloAndroidOSS'
}
}
try this :
Android Studio go to File -> Settings -> Build, Execution, Deployment -> Build Tools -> Gradle
Check the 'Offline work' under 'Global Gradle settings'
It will reduce 80% gradle build time.
and check gradle dependencies
buildscript {
dependencies {
classpath 'com.android.tools.build:gradle:2.0.0-alpha9'
}
}
Add dexOption and give the following heapSize
dexOptions {
incremental = true;
preDexLibraries = false
javaMaxHeapSize "4g"
}
Fixed:
I changed the distributionUrl in gradle-wrapper.properties as pointed by Santanu here.
In gradle-wrapper.properties use this :-
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
Instead of 4.1-all.zip .
Click to open ScreenShot
Enable Toggle Offline Mode Solved my issue. Check screenshot for more details.
Just select this one if it's not selected. its worked for me previously its take 25 30 minutes now it only takes a few seconds

Firebase not working Android Studio 3.0.1 [com.android.support:support-core-utils:27.1.0]

I'm trying to sync with Firebase with my project I use the tool from Android Studio --> Firebase and then I do the steps (This is new Project) Image.
Android Studio version 3.0.1
The build.gradle in App folder is:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.example.eranp.fiberbase"
minSdkVersion 19
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.constraint:constraint-layout:1.0.2'
implementation 'com.google.firebase:firebase-database:11.0.4'
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'
}
apply plugin: 'com.google.gms.google-services'
The build.gradle in Project folder
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
compile "com.android.support:support-core-utils:27.1.0"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.google.gms:google-services:3.1.0'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
But when I sync the project I have this Error:
Error:(13, 0) Could not find method compile() for arguments
[com.android.support:support-core-utils:27.1.0] on object of type
org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
Please install the Android Support Repository from the Android SDK
Manager.
But this is installed: Image.
I tried for a week to work with Firebase but anything working to sync.
How can I fix this?
thank you for helping!
After you add this:
compile "com.android.support:support-core-utils:27.1.0"
under the dependencies in the app/build.gradle
then you need to change the:
compileSdkVersion 26
to this:
compileSdkVersion 27
also update the firebase version to this:
implementation 'com.google.firebase:firebase-database:11.8.0'
latest version
You're trying to add a compile dependency to your project buildscript, which is not valid. You are only supposed to add classpath dependencies to your buildscript, which effectively act as plugins for your Gradle build.
compile dependencies are to be using your app's build.gradle, which typically lives in the app folder. These are SDK components that you use to build your app.
If you want to use compile "com.android.support:support-core-utils:27.1.0" in your app, move it from the buildscript dependencies to the app dependencies.

Failed to resolve: com.google.firebase:firebase-auth:11.0.2

I just updated sdk, google play services and google repository, but still this error happened. Please help, I want to integrate authentication using phone number.
SDK Manager
Logcat
Build.gradle Module:Project
// Top-level build file where you can add configuration options common to all sub-projects/module
return
buildscript {
ext.kotlin_version = '1.1.3-2'
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
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()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Build.gradle Module:App
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
android {
compileSdkVersion 25
buildToolsVersion "25.0.3"
defaultConfig {
applicationId "com.*****"
minSdkVersion 16
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
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.google.firebase:firebase-auth:11.0.2'
compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
On Firebase documentation it says:
Getting a "Could not find" error? Make sure you have
the latest Google Repository in the Android SDK manager
Updating Google Repository should help with Failed to resolve issues as well (at the time of writing these lines, Google Repository version is 57).
So solving this should be rather simple. Here are the steps you should take:
Open SDK Manager.
Select SDK Tools on the top tabs.
Scroll down, under Support Repository select Google Repository.
Hit the OK button.
As soon as installation is completed, change the Firebase dependencies version to 11.0.2.
Click on the "Sync Now" button.
Enjoy Firebase =)
Seems like you forgot to include the google play services plugin add these lines of code
App level gradle
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
...
compile "com.google.firebase:firebase-core:11.0.2"
compile "com.google.firebase:firebase-auth:11.0.2"
...
}
apply plugin: 'com.google.gms.google-services' <-- this line ath the bottom of it
Project level gradle
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
classpath 'com.google.gms:google-services:3.1.0' <--- This Line
}
// Getting a "Could not find" error? Make sure you have
// the latest Google Repository in the Android SDK manager
Google have shifted their new repositories from jcenter to maven google.
Add
google()
inside repositories in project build.gradle
Add Googles own maven repository to your build-gradle file:
repositories {
maven {
url 'https://maven.google.com'
// Alternative URL is 'https://dl.google.com/dl/android/maven2/'
}
}
Source: https://developer.android.com/studio/build/dependencies.html#google-maven
Solved for me setting play-services and firebase equal versions, like this:
implementation "com.google.firebase:firebase-core:11.8.0"
implementation "com.google.firebase:firebase-messaging:11.8.0"
implementation "com.google.firebase:firebase-database:11.8.0"
implementation "com.google.firebase:firebase-storage:11.8.0"
implementation "com.google.firebase:firebase-auth:11.8.0"
implementation "com.google.firebase:firebase-config:11.8.0"
implementation "com.google.firebase:firebase-crash:11.8.0"
implementation "com.google.android.gms:play-services-maps:11.8.0"
implementation "com.google.android.gms:play-services-location:11.8.0"
implementation "com.google.android.gms:play-services-places:11.8.0"
implementation "com.google.android.gms:play-services-auth:11.8.0"
implementation "com.google.android.gms:play-services-base:11.8.0"
Try using older version of Auth.
compile 'com.google.firebase:firebase-auth:10.0.1'

Categories

Resources