Android Studio cannot resolve 3rd party dependencies - android

With the newer versions of Android Studio it has been advertised that you can add compile statements to the build.gradle file for 3rd party libraries that are available on Maven Central and Android Studio should be able to automatically download the appropriate dependencies. However I haven't been able to get the Gradle Sync to successfully complete when I try to add one of these libraries. Here is the build.gradle file for the project
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.1"
defaultConfig {
applicationId "com.appsbysynapps.helloname"
minSdkVersion 14
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.larswerkman:HoloColorPicker:1.5'
}
Here is the build.gradle for the module
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
mavenCentral()
}
}
Here is the error given out by Gradle
Error:A problem occurred configuring project ':app'.
> Could not resolve all dependencies for configuration ':app:_debugCompile'.
> Could not resolve com.larswerkman:HoloColorPicker:1.5.
Required by:
HelloName:app:unspecified
> org.slf4j.spi.LocationAwareLogger.log(Lorg/slf4j/Marker;Ljava/lang/String;ILjava/lang/String;[Ljava/lang/Object;Ljava/lang/Throwable;)V
> org.slf4j.spi.LocationAwareLogger.log(Lorg/slf4j/Marker;Ljava/lang/String;ILjava/lang/String;[Ljava/lang/Object;Ljava/lang/Throwable;)V
I've been having the same issue for any 3rd party library I've tried to add. This is also a brand new project created in Android Studio 1.1.0 and offline mode is disabled. Any ideas for what is going on?

Related

Android Studio Gradle is not building third party libraries

I am using Android Studio 1.3.1 in Windows and same in Ubuntu.
In Ubuntu, everything is perfect.
But in Windows, when I compile third party libraries, the build fails and says:
Can not find resource
The build.gradle of my module is :
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "app.android.parking"
minSdkVersion 15
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.2.1'
compile 'com.android.support:design:22.2.0'
compile 'com.android.support:support-v4:22.2.0'
compile 'cn.pedant.sweetalert:library:1.3'
}
the error is coming in the last line. And it is coming for every third party library,not only for this one.
When I open same project in Ubuntu, the build is successful.
The build.gradle of my project is:
// 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()
}
}
The exact error is:
Error:A problem occurred configuring project ':parking'.
Could not resolve all dependencies for configuration ':parking:_debugCompile'.
Could not resolve cn.pedant.sweetalert:library:1.3.
Required by:
parking:parking:unspecified
Could not resolve cn.pedant.sweetalert:library:1.3.
Could not get resource 'https://jcenter.bintray.com/cn/pedant/sweetalert/library/1.3/library-1.3.pom'.
Could not GET 'https://jcenter.bintray.com/cn/pedant/sweetalert/library/1.3/library-1.3.pom'.
jcenter.bintray.com
I tried invalidating cache and restart, It did not work. It is compiling everything except those third party libraries.

Android Studio Gradle does not download maven depedencies

I am quite new to Android development and trying to write some test code. I have downloaded Android Studio 1.3 version and created testapp. I am trying to add com.facebook.android:facebook-android-sdk:4.1.0 depedency but somehow it's not getting downloaded.
Here is Project level build.gradle file.
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.2.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}}
Here is Module level build.gradle file.
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.testapp"
minSdkVersion 19
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.facebook.android:facebook-android-sdk:4.1.0'
compile 'com.android.support:appcompat-v7:22.2.1'
}
After reading other posts on similar topics I also confirmed that Gradle > Global Gradle settings > Offline work is not checked. Still somehow facebook depedency is not getting downloaded.
Any suggestions what could be the issue? Appreciate any pointers.
Thanks.
In your build.gradle you have to add
repositories {
jcenter()
}
It this way gradle knows where are the dependencies to download.
It is somenthing different from the repositories inside the buildscript block.
Otherwise you can add in the top-level build.gradle file:
allprojects {
repositories {
jcenter()
}
}
In this case, the repository block is valid for all modules in the project.
Could you post the error AndroidStudio is showing? (check on the Gradle Console, on the Run section and Android Monitor section)
One possible option that comes to my mind is that you don't have the lastest Android Support repository / Google repository installed: Check for updates on your Android SDK Manager.

Cannot add CircularReveal library by ozodrukh in Android studio

I am using Android Studio 1.1.0 and am trying to add CircularReveal library .I have followed the instructions mentioned there.
my build.gradle(Module: app) is :
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.1"
defaultConfig {
applicationId "com.geronimo.myapplication"
minSdkVersion 18
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.github.ozodrukh:CircularReveal:(latest-release)#aar'
}
I have added the repository in `build.gradle(Project: MyApplication3)`
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
maven {
url "https://jitpack.io"
}
}
dependencies {
classpath 'com.android.tools.build:gradle:1.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://jitpack.io"
}
}
}
The error that I am getting is
D:\Workspaces\AndroidStudio\Studio1.0\MyApplication3\app\build.gradle
Error:(24, 13) Failed to resolve: com.github.ozodrukh:CircularReveal:(latest-release)
Show in File<br>Show in Project Structure dialog
I have tried variations of the dependency too ie:
compile 'com.github.ozodrukh:CircularReveal:(latest-release)#aar'
compile 'com.github.ozodrukh:CircularReveal:(v1.0.4)#aar'
compile 'com.github.ozodrukh:CircularReveal-v1.0.4 #aar'
The error always remains as Failed to resolve...
Is there any other way to import a remote aar file and to add this dependency?
Copy #aar file to the libs directory manually. Then by going to
Files>Project Structure>Dependency
on the right red cross choose library dependency. This will prompt you a dialog where you can search for your dependency and add them.
or
download circularReveal library from github and import it as Module Dependency from Files>Project Structure>Dependency
You need to put only version number without brackets and 'v' char
com.github.ozodrukh:CircularReveal:1.0.4#aar
I had the same problem before. After I checked, I saw that the problem was the miniSDKversion which was lower than 15. Once I changed it to 15, it worked.
minSdkVersion 14 (change it to 15 or above)
targetSdkVersion 26
Then paste this to your library dependency
implementation ('com.github.ozodrukh:CircularReveal:2.0.1#aar') {
transitive = true;
}
Also add remote maven url
repositories {
maven {
url "https://jitpack.io"
}
}

Android studio 1.0.2 - gradle project sync failed

I have started using Android Studio 1.0.2 and I am trying to add Library dependency. For example I am adding loopj library in my project.
Steps which I follow:
File > Project Structure > Module(app) > Dependencies tab > Click on + icon > select loopj library > Apply > OK
Now I am getting issue of Gradle project sync failed.
Message : Failed to find: com.loopj.android:android-async-http:1.4.6
Somebody else facing the same problem? Please provide me suggestion if any.
Other information
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.test.testapplication"
minSdkVersion 14
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.loopj.android:android-async-http:1.4.6'
}
//
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
//
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https://services.gradle.org/distributions/gradle-2.2.1-all.zip
I've faced the same problem. The solution was simple, all you need is upgrade your gradle version. To do this, open your build.gradle (root project) and edit the next line:
classpath 'com.android.tools.build:gradle:1.0.0'
to
classpath 'com.android.tools.build:gradle:1.1.0'
So if you are using Android Studio you will notice that you are using offline mode that's not available in the new gradle version. Confirm the change and now you can download the dependencies you want.

Error:Artifact 'support-v4.jar (com.android.support:support-v4:21.0.3)' not found. Android studio 1.0.2

I did a new install of Android Studio 1.0.2. Getting the following error when opening my first existing android project:
Gradle 'MyApplication' project refresh failed
Error:Artifact 'support-v4.jar (com.android.support:support-v4:21.0.3)' not found.
Searched in the following locations: file:/C:/Users/Ntokozo/AppData/Local/Android/sdk/extras/android/m2repository/com/android/support/support-v4/21.0.3/support-v4-21.0.3.jar
And if I navigate to that searched location I found two jar files which are: support-v4-21.0.3-sources.jar and support-v4-21.0.3-javadoc.jar
Here is my build.gradle file:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
Gradle file under App folder:
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.example.ntokozo.myapplication"
minSdkVersion 15
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.android.support:support-v4:21.0.3'
}
Thank you in advance, please bare in mind in responses that I'm a novice and I might not know advanced features.
After re-installing windows OS and a new Android Studio setup the problem disappeared. I don't know what was the problem at first.

Categories

Resources