My Android Studio Gradle is not getting the plugin from maven central - android

I tried to add smoothprogressbar library to my android project
I added these lines to my build.gradle
dependencies {
// of course, do not write x.x.x but the version number
compile 'com.github.castorflex.smoothprogressbar:library:0.5.2'
}
And when i sync the gradle its saying that
Failed to find : com.github.castorflex.smoothprogressbar:library:0.5.1
I tried putting mavenCentral() and maven url in build.gradle and other solutions which i found in stackoverflow but nothing seems to work.
Edited :
This is my full gradle file
apply plugin: 'com.android.application'
repositories {
mavenCentral()
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
//compile 'com.android.support:cardview-v7:21.+'
compile('com.google.http-client:google-http-client-android:1.18.0-rc') {
exclude(group: 'com.google.android', module: 'android')
exclude(group: 'org.apache.httpcomponents', module: 'httpclient')
}
// You must install or update the Support Repository through the SDK manager to use this dependency.
// You must install or update the Support Repository through the SDK manager to use this dependency.
compile project(path: ':backend', configuration: 'android-endpoints')
// You must install or update the Support Repository through the SDK manager to use this dependency.
// You must install or update the Support Repository through the SDK manager to use this dependency.
compile project(':library')
// You must install or update the Support Repository through the SDK manager to use this dependency.
compile 'com.android.support:support-v4:19.+'
compile 'com.google.android.gms:play-services:4.4.52'
// You must install or update the Support Repository through the SDK manager to use this dependency.
compile 'com.android.support:support-v13:19.+'
compile 'com.google.code.gson:gson:2.+'
compile 'com.github.castorflex.smoothprogressbar:library:0.5.2'
}
android {
signingConfigs {
...
}
compileSdkVersion 19
buildToolsVersion '20.0.0'
defaultConfig {
applicationId ...
minSdkVersion 15
targetSdkVersion 19
versionCode 1
versionName '1.0'
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.config
}
}
dexOptions {
preDexLibraries = false
}
productFlavors {
}
}

Works for me. You should post more of your build.gradle script (in particular, how exactly you tried to put mavenCentral() in the script), but the gist is that you need the following outside of the android {} block in the script (and this is in addition to the similar code in the buildscript {} block):
buildscript {
// ...
}
repositories {
mavenCentral()
}
dependencies {
compile 'com.github.castorflex.smoothprogressbar:library:0.5.2'
}
android {
// ...
}
Then re-sync your project with Gradle.

Use this approach:
compile 'com.github.castorflex.smoothprogressbar:library:0.5.2#aar'

Related

Gradle dependecies are failed to resolve

I'm using Android Studio version 2.3.3. It has been updated recently. Whenever I try to add a new dependency for any use e.g. recyclerview, cardview, retrofit, etc, the gradle fails to resolve them.
I have mentioned the repositories in gradle file. But there is no solution.
this is my gradle file
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.3"
defaultConfig {
applicationId "com.example.apurva.bargraph"
minSdkVersion 15
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'
}
}
}
allprojects {
repositories {
jcenter()
maven { url "https://jitpack.io" }
maven {url "https://maven.google.com"}
}
}
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'
compile 'com.android.support:design:25.3.1'
compile 'com.android.support:cardview-v7:25.3.1'
compile 'com.android.support:recyclerview-v7:25.3.1'
compile 'com.github.philjay:mpandroidchart:v3.0.2'
testCompile 'junit:junit:4.12'
}
for each of the dependency, gradle sync fails and I don't know what else to do.
Any kind of help would be great.
There may be number of problems for this
1. First check your buildToolVersion which you are using is installed in your sdk.
2. You have to add below code in project gradle file not in app gradle.
maven { url "https://jitpack.io" }
maven {url "https://maven.google.com"}
Just change the buildToolVersion to higher version which is installed in you studio.
It's May be help you out.
This is because you didn't have support library 25.3.1 installed in your system. So, you need to install the sdk from Android Studio via Tools->Android->SDK Manager for support library below 25.4.0. You only need to use google maven to use support library starting from revision 25.4.0.

Android NoClassDefFoundError for library's class inside a dependency

I created an Android library named "core" that use the Logger library (https://github.com/orhanobut/logger).
Here its build.gradle:
apply plugin: 'com.android.library'
android {
compileSdkVersion 25
buildToolsVersion "25.0.1"
defaultConfig {
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'])
compile 'com.orhanobut:logger:1.15'
compile 'com.android.support:appcompat-v7:25.0.1'
testCompile 'junit:junit:4.12'
}
Then I build a .aar of core library.
I add this library as a dependency into my application, by putting the .aarcore files in the libs folder.
That's the build.gradle of my application :
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.1"
defaultConfig {
applicationId "com.package.test"
minSdkVersion 16
targetSdkVersion 25
multiDexEnabled true
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
repositories {
mavenCentral()
jcenter()
flatDir {
dirs 'libs'
}
}
dependencies {
compile 'com.mypackage:core:1.0#aar'
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'
})
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:25.0.1'
compile 'com.android.support:multidex:1.0.1'
}
As you can see I have multidex activated.
It compile just fine but at runtime, at the first call to Logger I get an exception:
stack=java.lang.NoClassDefFoundError: Failed resolution of: Lcom/orhanobut/logger/Logger;
Even if I set transitive = true
compile (com.mypackage:core:1.0#aar) {
transitive=true
}
it doesn't work.
Thank you !
I had to do a couple of things in concert to get it to work.
1) In your library project
Add the following to your project-level gradle file:
buildscript {
dependencies {
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
}
}
Be sure to use the right version of the plugin for your gradle version, check here.
Add the following to your module-level gradle file:
apply plugin: 'com.github.dcendents.android-maven'
group='com.github.YourPackage'// Doesn't have to be github, just an example
Also in this file, make sure your dependencies (the ones you want to be transitive) use api instead of implementation if you are using Gradle 3.4+. If you are using a version of Gradle <3.4, compile is the way to go. Example:
dependencies {
api 'com.google.android.gms:play-services-location:15.0.1'
}
2) In your app project (which uses the library)
Add the following to your module-level gradle file:
dependencies {
implementation('com.github.YourPackage:yourRepo:version#aar') {
transitive=true
}
}
Add the following to you project-level gradle file (but this will depend on where your library is served from, for me it's jitpack):
allprojects {
repositories {
...
maven {
url 'https://jitpack.io'
credentials { username 'yourAuthKey' }// Only for private repositories
}
}
}
Note: You shouldn't add the auth key as a string in build.gradle, put it in a property in your gradle.properties file.
Note 2: JitPack allows you to use for example development-SNAPSHOT as a version number for a gradle dependency. Android Studio caches these dependencies and will not re-download it when you push to your development branch. To overcome this, use commit hashes as version numbers during development or clear (delete) the cache files, located on Windows at ~/.gradle/caches/modules-2/metadata-x.xx/descriptors/com.github.YourPackage/yourRepo. (Needles to say, I learned this the hard way).

Android studio - Failed to resolve (gradle) Uber library

In my Android application, I want to add Uber facility to users so that I looked the following library. So that I added the compile 'com.uber.sdk:rides-android:0.1.0' in my main module's (Main application) build.gradle file. It gives me following error when sync the gradele
Failed to resolve: com.uber.sdk:rides-android:0.1.0
I have some other libraries referenced to the application.
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.+'
}
}
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.qapp"
minSdkVersion 14
targetSdkVersion 21
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile project(':facebookSDK')
compile project(':payPalDemo1')
compile project(':uberLibrary')
compile project(':bSLibrary')
compile project(':pullToRefresh')
compile project(':androidmapsutils')
compile 'com.android.support:support-v4:21.0.3'
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.google.android.gms:play-services:+'
compile 'com.android.support:multidex:1.0.0'
compile files('libs/android-async-http-1.4.6.jar')
compile files('libs/cardio.jar')
compile files('libs/universal-image-loader-1.9.3.jar')
compile files('libs/UserFormValidation.jar')
}
Please help me to resolve this exception.
Try to add this in your gradle file
repositories{
maven { url "https://jitpack.io" }
}
In the portion of your build.gradle file that you have included you only have the mavenCentral() repository specified within the buildScript block. In order to make that repository accessible outside of that context you should include a block such as the following to the root level of your build.gradle:
repositories {
mavenCentral()
}
In addition, you have not actually included the line compile 'com.uber.sdk:rides-android:0.1.0' in the file copied in your question.
Ultimately, your build.gradle should include the following:
repositories {
mavenCentral()
}
dependencies {
compile 'com.uber.sdk:rides-android:0.1.0'
}
this SDK is designed to work with Android SDK 16. so minSdkVersion should be 16 or greater

Gradle Fails to resolve material-dialogs dependency in Android Studio

I am trying to build my Android App I imported from a Git repository. This same app builds correctly in another environment, but in my environment I get the following error:
Error:(41, 13) Failed to resolve: com.afollestad:material-dialogs:0.7.7.0
My build.gradle:
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
repositories {
maven { url 'https://maven.fabric.io/public' }
}
android {
compileSdkVersion 22
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "my.app.id"
minSdkVersion 16
targetSdkVersion 22
multiDexEnabled true
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:22.2.0'
compile 'com.android.support:support-v4:22.2.0'
compile 'com.afollestad:material-dialogs:0.7.7.0'
compile 'com.michaelpardo:activeandroid:3.1.0-SNAPSHOT'
compile 'com.github.navasmdc:MaterialDesign:1.2'
compile 'com.android.support:multidex:1.0.1'
compile 'com.squareup.retrofit:retrofit:1.9.0'
compile 'com.squareup.okhttp:okhttp-urlconnection:2.1.0'
compile 'com.squareup.okhttp:okhttp:2.1.0'
compile 'com.google.code.gson:gson:2.3.1'
compile 'joda-time:joda-time:2.3'
compile 'com.joanzapata.pdfview:android-pdfview:1.0.4#aar'
compile 'com.andreabaccega:android-form-edittext:1.2.1#aar'
compile('com.crashlytics.sdk.android:crashlytics:2.5.2#aar') {
transitive = true;
}
}
I also tried different versions (0.7.7.0, 0.7.6.0, 0.7.5.5), but nothing changes. How can I address my issue?
On jCenter there are only two version available 0.7.9.0 and 0.7.9.1. These versions are not available in Maven Central, so check in your project build.gradle that you are using jcenter().
BTW these versions are not updated, the last version released in GitHub is 0.8.5.1.
To use the last version in your project use the following instructions:
Repository
First, add the following to your app's build.gradle file:
repositories {
maven { url "https://jitpack.io" }
}
Core
The core module contains all the major classes of this library,
including MaterialDialog and AlertDialogWrapper. You can create basic,
list, single/multi choice, progress, input, etc. dialogs with core.
dependencies {
// ... other dependencies here
compile('com.github.afollestad.material-dialogs:core:0.8.5.1#aar') {
transitive = true
}
}
The problem is that you use targetSdkVersion 22. If you update targetSdkVersion to 23 and use this latest library version in denendency the problem'll go away:
repositories {
jcenter()
}
dependencies {
compile('com.github.afollestad.material-dialogs:core:0.8.5.1#aar') {
transitive = true
}
}
But if you want to use 22 SDK you should use such dependencies:
repositories {
maven { url "https://jitpack.io" }
}
compile ('com.github.afollestad:material-dialogs:53103863a6') {
transitive = true
}
This is the last version which supports 22 SDK - v. 0.6.4.4. But there is some problem with using old version number in dependency name (maybe because library author migrated to jCenter) and you can use first 10 digits of commit's hash related to this version instead.
or you can use this:
compile 'com.afollestad.material-dialogs:core:0.9.1.0'
instead of
compile 'com.afollestad:material-dialogs:0.7.7.0'

Failed to resolve: com.firebase:firebase-client-android:2.3.1

I am working on the Sample in the below blog
https://www.firebase.com/blog/2015-10-01-firebase-android-app-engine-tutorial.html
The projects fails to compile after adding the dependency
compile 'com.firebase:firebase-client-android:2.3.1'
Other dependencies compile without any issue.
'com.android.support:appcompat-v7:23.0.1'
'compile 'com.android.support:design:23.0.1'
Where am I going wrong ?
here is my module build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.tri.todoapp"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE-FIREBASE.txt'
exclude 'META-INF/NOTICE'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
// testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.android.support:design:23.0.1'
compile 'com.firebase:firebase-client-android:2.4.0'
}
Top-level gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.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
}
The project fails to compile because version 2.3 doesn't exists. You should use 2.3.1:
compile 'com.firebase:firebase-client-android:2.3.1'
or the newest 2.4.0:
compile 'com.firebase:firebase-client-android:2.4.0'
You can find more information here:
https://www.firebase.com/docs/android/quickstart.html
We are talking about Google api versions without mentioning Google Repository version.
The actual problem here is that your Google Repository doesn't "know" about the firebase version you all were trying to use.
I got same error while following the official firebase documentation
My app-level build.gradle file looked like this:
apply plugin: 'com.android.application'
android {
// ...
}
dependencies {
// ...
compile 'com.google.firebase:firebase-core:10.2.1'
compile 'com.google.firebase:firebase-messaging:10.2.1'
}
apply plugin: 'com.google.gms.google-services'
My Google Repository version was 44
You can check yours in
SDK Manager>Android SDK> SDK Tools (tab)
Latest version is 46 (at the time of writing this)
I updated to latest Google Repository version and the problem was solved!
You can update by checking "Google Repository" under SDK Tools tab and click "Apply" to update Google Repository to latest version
If you do not wish to update your Google Repository version, you can still resolve the issue by lowering your firebase api version slighlty.
For my case, changing app-level build.gradle file to the following also fixes my problem:
apply plugin: 'com.android.application'
android {
// ...
}
dependencies {
// ...
compile 'com.google.firebase:firebase-core:10.2.0'
compile 'com.google.firebase:firebase-messaging:10.2.0'
}
apply plugin: 'com.google.gms.google-services'
firebase version has been lowered to version 10.2.0 from 10.2.1
This works because 10.2.0 is known to Google repository ver 44.
I hope this answer will help many in future.
There are two modules you need to add firebase to:
The android module: You should use the "Add Firebase" checkbox that appears in project structure that will add 2.3.1 to the android app.
The backend module requires 2.4 to run in app engine and those steps require you to add the dependency manually.
In that case, be sure you are adding the jvm client -- not the "android" client for app engine.
compile 'com.firebase:firebase-client-android:2.4.0'
It happens because this version
compile 'com.firebase:firebase-client-android:2.3'
doesn't exist.
You can use one of these:
compile 'com.firebase:firebase-client-android:2.4.0'
compile 'com.firebase:firebase-client-android:2.3.1'
compile 'com.firebase:firebase-client-android:2.3.0'
Pay attention.
compile 'com.firebase:firebase-client-android:2.3.0'
is different from
compile 'com.firebase:firebase-client-android:2.3'
You can find the full list in maven:
using
compile 'com.firebase:firebase-client-android:+'
worked for me.
I had the exact same problem today, but with version 2.4.1. I could however not open the link l jcenter.bintray.com/com/firebase/firebase-client-android/2.4.1/ as mentioned by Mattia Maestrini.
Solution for me: Deactivate my VPN, and then it worked.
it looks like it was a dex limit error. Adding the Firebase SDK must have put me over the limit, to fix this i had to add multiDexEnabled true in the defaultConfig section of my app:build.gradle file as well as compile 'com.android.support:multidex:1.0.0' in the dependencies
Here is my gradle
gradle for project
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.5.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
}
gradle module app
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.tranetech.openspace.firebasedemo"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE-FIREBASE.txt'
exclude 'META-INF/NOTICE'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.2.1'
compile 'com.firebase:firebase-client-android:2.5.2+'
compile 'com.firebaseui:firebase-ui:0.3.1'
compile 'com.android.support:multidex:1.0.0'
}
I not sure you still working with that project or not, but I also faced the same problem with you, my solution is
In your build.gradle (outside the app folder one), add
buildscript {
repositories {
jcenter()
}
dependencies {
////
classpath 'com.google.gms:google-services:3.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
and in your module build.gradle, add
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.+'
compile 'com.android.support:design:23.+'
compile 'com.google.firebase:firebase-core:9.2.1'
compile 'com.google.firebase:firebase-database:9.2.1'
compile 'com.firebase:firebase-client-android:2.4.0'
}
apply plugin:
'com.google.gms.google-services'// <- this code
And the last, don't forget to download google-services.json put in your app folder, the path should look like \yourapplication\app, you also can refer to this link for download google-services.json file. Download a configuration file
compile is deprecated. You should use:
implementation 'com.firebase:firebase-client-android:2.5.2'

Categories

Resources