Gradle doesn't find dependency - Android Studio - android

Gradle no longer finds dependencies declared in the build.gradle. Everything was working fine and today when I open Android Studio I get an error :
Error:Failed to find: com.readystatesoftware.systembartint:systembartint:1.0.3
The library referenced is SystemBarTint. I had the library work previously using the same build.gradle file but now it no longer works.
My app/build.gradle looks like this :
apply plugin: 'com.android.application'
android {
compileSdkVersion 19
buildToolsVersion "20.0.0"
defaultConfig {
applicationId "com.example.adnan.systembartintdemo"
minSdkVersion 19
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.readystatesoftware.systembartint:systembartint:1.0.3'
}
My root/build.gradle looks like this :
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.12.+'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
mavenCentral()
}
}
Any ideas what I am doing wrong here? Thanks !
Edit : Tried importing a project which I work on daily at my work, it fails to find any dependencies in that project either. Tried re installing Android Studio, still the same error

Ok finally got this fixed.The problem was weird, for some reason it was trying to pick up a local offline copy of the dependency, I went to Settings -> Compiler -> Gradle -> Enabled offline Work and disabled it again. Save and Apply changes.
And now it works !

Related

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.

Android change build.gradle to import external library

I'm trying to use MaterialDialog in my project, but this library doesn't support my Right to Left language and I must edit that. After downloading the project and importing it into current project I get this error when building my project:
Error:(2, 0) Plugin with id 'com.novoda.bintray-release' not found.
After many searches on the web I find this link to resolve this. But that doesn't work for my project:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.0.0'
/* I'm adding this below line */
classpath 'com.novoda:bintray-release:0.2.7'
}
}
allprojects {
repositories {
jcenter()
}
}
If you have downloaded the actual library and have imported it to Android studio and modified it then you want to add the dependency in your gradle.build (Module:app). The code you are showing is from gradle.build (Project: NameOfYourProject) so I would delete that line you added there.
Go to the build.gradle (Module:app) file which will look something like shown below and add the library as shown.
android {
compileSdkVersion 22
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.yourappname"
minSdkVersion 22
targetSdkVersion 22
versionCode 1
versionName "1"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-project.txt'), 'proguard-rules.pro'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.2.0'
compile project(':nameOfTheLibrary')
}
Add
dependencies {
compile 'com.afollestad:material-dialogs:0.7.7.0'
}
and press the sync button.

android studio , Connot resolve any new library as dependency

I'm using android studio for my project , now , everytime I find a library in google and want to add that library and use it , I get this error :
I've tested , and seen that , any library that I want to add , I get that error .
here is my gradle.build
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.agahi.www.adevertisement"
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.android.support:recyclerview-v7:21.0.3'
**compile 'com.rengwuxian.materialedittext:library:1.8.3'** ------> I added this line , and got the error again
}
And here is my another gradle file :
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.0'
}
}
allprojects {
repositories {
jcenter()
}
}
what should I do ?
This is a shame that most of my time , gets to fix android studio bugs and errors , instead of actual coding and thinking :(
EDIT :
I want to use this library , : https://github.com/rengwuxian/MaterialEditText
EDIT :
Even if I try to make a completely new project and add libraries , I face same error .
Try adding this to gradle file.
repositories {
jcenter()
mavenCentral() }
Ensure these lines in the build.gradle file of the project and sync.
It will work for sure.
allprojects {
repositories {
jcenter()
}
}
I finally made it work ,
I went to the default setting of android studio
The in the gradle section
there was a checkbox that was : gradle work offline
I remove the tik .
By the way , this was default android sturio configuration , that is embarrassing.

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.

debug: file not found in Android 1.0

Today I updated to Android Studio v 1.0 and I'm getting the following error when trying to compile whatever project.
....\app\build\intermediates\classes\debug: file not found
The thing is that before updating it I had no problems. Here is the code I'm actually trying to compile.
build.grade
apply plugin: 'com.android.application'
android {
compileSdkVersion 20
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "razvitrance.testnavdrawerplz"
minSdkVersion 16
targetSdkVersion 20
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:support-v13:21.0.3'
}
build.gradle (for the 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.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
And the activity code is a simple Navigation Drawer.
Thank you for helping.
This is the erorr i'm getting.
http://gyazo.com/bdf375a160b1662ce4eb0d4e9aed8f30
Check this and this answers.
Generally, you will need to delete your grandle file and let Android Studio generate the one it thinks that it is correct, as it is being mentioned in the given posts. Happened to me too when i upgrated to newer version and that solved my problem.
It seems that Android Studio does not recognize non-alphanumeric symbols in path (cyrillic, for example). I had the same problem, and it was solved with creating project in another folder not containing cyrillic symbols in its path. In your case it may be '#' synmbol that makes a trouble

Categories

Resources