Gradle Project Sync Failed - Unresolved dependencies - android

I've taken an Android project that was created in IntelliJ and imported it into AndroidStudio. After looking at Googles hopeless instructions for how to migrate a project to Gradle I pressed buttons at random and prayed to the gods of droid whilst sacrificing a small innocent child and somehow eventually ended up with a Gradle controlled project that synced, built and ran on my Android devices.
I then added some additional dependencies to my build.gradle file:
compile 'com.octo.android.robospice:robospice:1.4.12'
compile 'com.octo.android.robospice:robospice-spring-android:1.4.12'
compile 'com.google.code.gson:gson:2.2.4'
compile 'com.google.http-client:google-http-client-jackson:1.18.0-rc'
compile 'com.octo.android.robospice:robospice-google-http-client:1.4.12'
compile 'org.codehaus.jackson:jackson-mapper-asl:1.9.13'
Now when I try to sync Gradle I get the following message:
Gradle Project sync Failed. Basic functionality (e.g. editing, debugging) will not work properly.
In the Gradle Sync window I get the following messages:
Unresolved Dependencies:
Error:com.google.http-client:google-http-client-gson:1.18.0-rc
Error:com.octo.android.robospice:robospice-spring-android:1.4.12
...
and so on for each of the dependencies that I have listed.
How might I resolve this?

OK I've figured it out.
I added
allprojects {
repositories {
mavenCentral()
}
}
to the bottom of my build.gradle file.
It was obviously struggling to find a repository to load from.
The script already had
buildscript {
repositories {
mavenCentral()
}
This it would seem was insufficient.

Related

failed to resolve android support library v7-appcompat

I create empty project in android studio 2.3.3 and it by default has compile 'com.android.support:appcompat-v7:26.+' in it's module level build.gradle file and it compiles ok, but when I specify any concrete version from https://developer.android.com/topic/libraries/support-library/revisions.html#26-0-2
gradle sync fails with message
I also tried the following notation compile group: 'com.android.support', name:'v7-appcompat', version: '26.0.0', still no success.
I have
jcenter()
maven {
url "https://maven.google.com"
}
in repositories secion. Install repository and sync project button is not clickable. Support repository is updated:
You misswrote the artefact name. Change it as below:
compile 'com.android.support:v7-appcompat:26.0.0'
to
compile 'com.android.support:appcompat-v7:26.0.0'
Be sure to use:
compileSdkVersion 26
buildToolsVersion "26.0.0"
or later.
Invalidate Cache, go to File > Invalidates Caches
Just click in the Install Repository and sync Project link to install the missing dependencies.
Then sync your project with the gradle files again.
Second solution, try uninstalling an reinstalling Android Support Repository again (I think its similar to clean cache):
Check the error message:
Failed to resolve com.android.support:v7-appcompat:26.0.0'
The right library is appcompat-v7 and not v7-appcompat
Use:
compile 'com.android.support:appcompat-v7:26.x.x'

Failed to resolve: com.onesignal:OneSignal:3.4.3

I'm trying to setup OneSignal push notifocation in my Android app. I have changed my build.gradle to include the required dependencies (or so I think).
No matter what I do I keep getting
Failed to resolve: com.onesignal:OneSignal:3.4.3
or
Could not find com.onesignal:OneSignal:3.4.3
Can anyone give me a slight push please? Thanks in advance :-)
I should mention that I have checked the trouble shooting section on OneSignals home page. All is in order.
Here's the dependencies section of my gradle file:
dependencies {
compile 'com.android.support:appcompat-v7:25.1.1'
compile 'com.android.support:design:25.1.1'
compile 'com.google.firebase:firebase-analytics:9.6.0'
compile 'com.google.firebase:firebase-crash:9.6.0'
compile files('src/main/libs/simple-xml-2.7.jar')
compile files('src/main/libs/date4j.jar')
compile files('src/main/libs/picasso-2.5.2.jar')
compile 'com.onesignal:OneSignal:3.4.3#aar'
compile 'com.google.android.gms:play-services-gcm:10.0.1'
compile 'com.google.android.gms:play-services-location:10.0.1'
}
The OneSignal SDK is hosted on Maven Central so I would first make sure you can access this from your system. Next double check the following as well.
Make sure you're using Android Studio version 1.4.0 or newer.
Go to File>Settings. Search for Offline work and uncheck that option.
Add the following to your .gradle file.
Root build.gradle
repositories {
mavenCentral()
}
4. Try restarting Android Studio and then going to Tool>Android>Sync Project again.
5.Try building OneSignal's example Android Studio project. If this works then the problems is related to your project.
Screenshots for some of these steps below.
https://documentation.onesignal.com/docs/troubleshooting-android
Well... what finally fixed this issue for me was to replace
mavenCentral()
with
jcenter()
go figure... :-)

Android Studio : Failed to resolve <github dependency>

Let me first start of by saying that I just recently migrated to Android Studio and being totally honest I didn't like it. Now there is this git I am trying to import into my project - https://github.com/ongakuer/CircleIndicator
Although the compile statement which the owner has asked to put creates the error.
I added it into the dependency{} in my build.gradle file.
compile 'me.relex:circleindicator:1.1.5#aar'
Failed to resolve: me.relex:circleindicator:1.1.5#aar
You probably had forgotten this line under your gradle :
allprojects {
repositories {
jcenter()
}
}
Edit the root gradle located in root/build.gradle
I'll just explain a little :
When you add this line : compile 'repository or jar url', it prompts your gradle that it should find the repository (or the jar) and add it to your source.
But where should it search for this particular repository ? That is the purpose of this line, to declare a location from where the gradle should search from. In most of the cases it is - jcenter
(see this link)
Just open build.gradle(Module:app) and copy pase on your dependencies
dependencies {
compile 'me.relex:circleindicator:1.1.5#aar'
}

Android studio 1.2.2 gradle library

Adding a gradle project with compile has been working for me very well, but I noticed after updating the Android studio to 1.2.2, or maybe the version just before it, that adding a library is not working anymore.
So for example I tried to add this and I did the "Sync Now" and it was successful but the library doesn't seem to be recognized. When I try to use ProgressWheel in Java and I hit ctrl+Enter it doesn't find the library, anyone have an idea of what should I do?
dependencies {
compile 'com.android.support:support-v4:21.0.0'
compile 'com.google.android.gms:play-services:+'
compile files('libs/universal-image-loader-1.9.3.jar')
compile 'com.romainpiel.shimmer:library:1.4.0#aar'
//the above libraries were added before the update, everything was
//working fine, the below isn't
compile 'com.pnikosis:materialish-progress:1.5'
}
Please note that I tried many other libraries and all had the same result.
The project README (front page of https://github.com/pnikosis/materialish-progress) says it's on Maven Central. Android Studio uses jCenter (by Bintray) by default. Add this in your module's build.gradle file:
repositories {
mavenCentral()
}

Use android-maps-utils in Android Studio

I am trying to use this library [1] in an Android project either with Android Studio or with ADT. But it doesn't work at all. In ADT I don't know how to handle gradle stuff and in Android Studio, when I try to "Import Project", I get the error "Could not find com.google.android.gms:play-services:3.1.36.
(don't have enough reputation to post picture, it's on imgur with xswZ3.jpg)
I am not familiar with gradle and I only have a vague idea of what it does but all I want is to use something like BubbleIconFactory f = new BubbleIconFactory(this) in my own project.
Any help is appreciated!
[1] https://github.com/googlemaps/android-maps-utils
Perhaps your problem is needing the repositories outside of the buildscript block.
The repositories internal to the buildscript is for managing the gradle dependency itself, I believe. Here's how I resolved my problem with google-maps-utils as a library dependency. Hopefully this helps. I included my maps and support-v4 libs too.
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.10+'
}
}
apply plugin: 'android'
repositories {
mavenCentral()
}
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
// Support Libraries
compile 'com.google.android.gms:play-services:4.1.32'
compile 'com.android.support:support-v4:19.0.1'
compile 'com.google.maps.android:android-maps-utils:0.3+'
}
com.google.android.gms:play-services:3.1.36 can be downloaded by going to your SDK Manager and installing the Extras->Google Repository package (you may want to install the Extras->Android Support Repository as well while you are there). These allow Gradle to automatically use these resources without the need for library projects or jars manually added to your project.
Add the following dependency to your Gradle build file:
dependencies {
compile 'com.google.maps.android:android-maps-utils:0.2+'
}
You'll need to install the "Google Repository" from the Android SDK manager.
See demo/build.gradle for an example.
You can, of course, copy the library directory and use it like any other Android library project.
Let me know if this helps!
Chris
Steps:
First File>Project Structure>Click Plus Button >Import Graddle Project>Select the file(library folder) from the location where downloaded>CLick Ok.
Add this code to dependencies to that app module build.gradle file(remember there are two build.gradle files) :
dependencies {
compile 'com.google.maps.android:android-maps-utils:0.4+'
}
Copy gradle.properties file contents of that Android-maps-util Library project app(found inside that project library folder) TO
gradle.properties file of your project(Simple copy and paste of content to the editor).
Click Sync Project with gradle files button. And you must be fine!

Categories

Resources