Android Studio : Failed to resolve <github dependency> - android

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'
}

Related

Why getting this error transformClassesWithDexForDebug while building apk?

While building apk I am getting this error:
Error Image
This is my gradle Image: gradle image
Note:- I started getting this error after including android-support-v4.jar to project
If anyone know this so please tell me why I am getting this error and how to solve It.
Your last line has a dependency of support-v4 using a jar file in your lib folder that you might have placed.
Either remove the file and the last line or remove the support-v4 dependency that you have highlighted.
Add the following to your project level build.gradle file if not already present
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
}
Add the support-v4 dependency as follows to your app level build.gradle:
compile 'com.android.support:support-v4:24.2.1'
Remove the following along with the jar file:
compile files('libs/support-v4.jar')
Now your gradle will use the dependency and download the aar on it's own from the maven repository and not use the jar file that you have added.

failed to resolve com.android.support.constraint:constraint-layout:2.0.0-alpha4

I imported a project from my work-space. After this some errors were shown which I can't solve.
The message
Install Repository and sync project
was shown as a link, but clicking on it didn't solve my problem.
Add ConstraintLayout to your project.
To use ConstraintLayout in your project, proceed as follows:
Ensure you have the "maven.google.com" repository declared in your
module-level build.gradle file:
repositories {
maven {
url 'https://maven.google.com'
}
}
Add the library as a dependency in the same build.gradle file:
dependencies {
compile 'com.android.support.constraint:constraint-layout:1.0.2'
}
In the toolbar or sync notification, click Sync Project with Gradle Files.
The constraintLayout is not available yet on any stable relase of Android Studio. You have to download the latest Android Studio Preview to use it.

Github Project not available on android studio

I forked a project and I made a little modification on https://github.com/oursgris/datetimepicker
How can I make it available in android studio ?
I tryied to add in build.gradle :
dependencies {
compile 'com.github.oursgris.datetimepicker:library:0.0.3'
}
I had an error : Failed to resolve: com.github.oursgris.datetimepicker:library:0.0.3
What did I missed ?
I manage to output aar file but I don't know how to make it available in android studio with a simple dependancy (like other projects)
Regards
You almost got it right. What was missing is that you need to add a repository that stores your 'aar' file. You can do this with JitPack:
repositories {
maven {
url "https://jitpack.io"
}
}
And then add your library as:
dependencies {
compile 'com.github.oursgris:datetimepicker:0.0.3'
}

Gradle Project Sync Failed - Unresolved dependencies

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.

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