Cannot build app when using gradle (Android Studio) and local maven repo - android

I am trying to include the library Slik and Cards-UI in my app, I'm using android studio and gradle to build. The app builds fine without this but adding the dependency make the build fail. Looking at the debug log of the build it doesn't seem to be looking in the local repo for the arr file. I can see the files are there and I have followed the tutorial on the github wiki page for the install and that works fine. The error is:
A problem occurred configuring project ':climbtrack'.
> Could not resolve all dependencies for configuration ':climbtrack:_debugCompile'.
> Could not find com.afollestad.cardsui:library:1.0-SNAPSHOT.
Required by:
ClimbTrack:climbtrack:unspecified
> Could not find com.afollestad.silk:library:1.0-SNAPSHOT.
Required by:
ClimbTrack:climbtrack:unspecified
Here is my build.gradle
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.7.+'
}
}
apply plugin: 'android'
repositories {
mavenLocal()
mavenCentral()
}
android {
compileSdkVersion 18
buildToolsVersion "19.0.0"
defaultConfig {
minSdkVersion 15
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.google.android.gms:play-services:4.0.30'
compile 'com.afollestad.cardsui:library:1.0-SNAPSHOT'
compile 'com.afollestad.silk:library:1.0-SNAPSHOT'
}
The google play services dependency works fine and is found from the maven central repo as expected.
Any ideas anyone?
Thanks

This is bug https://code.google.com/p/android/issues/detail?id=63908
If you look at comment #3 in that bug, there's a workaround. Try it and see if it helps:
This appears to be a bug in Gradle 1.9 with local Maven repositories.
See https://plus.google.com/109385828142935151413/posts/hF7W59uZ7rX
The workaround for now is to use
maven { url "${System.env.HOME}/.m2/repository" }
instead of mavenLocal()

In Android Studio 0.4.6 using mavenLocal works fine:
repositories {
mavenCentral()
mavenLocal()
}
Check and configure your Maven installation on Preferences >> Maven to ensure it points to your local repository.
I hope this update helps newcomers.

Related

Setting up Gradle for api 26 (Android)

Since I have upgraded my Nexus 5x to Android O DP3 I am not able to test my applications. I get the error for not having configured my Gradle-file to work with the new API-level (26).
So I changed this and the dependencies, but I keep getting errors on ALL my support libraries like
Failed to resolve: com.android.support:design:26.0.0-beta2
Clicking on
Install repository and sync project
Pops up a progressdialog for downloading the right dependency but does not remove the error. Cleaning up project, installing repositories and then rebuilding the project won't work either.
appcompat-v7
On appcompat-v7:26.0.0-beta2 I get (before even a Gradle sync) squickly lines with the error:
When using a compileSdkVersion older than android-O revision 2,
the support library version must be 26.0.0-alpha1 or lower (was 26.0.0-beta2)
Can someone help me get the gradle file to be configured correctly for Android API 26?
Any help would be appreciated.
PS: I'm using Gradle 3.0.0-alpha3 at the moment but get the same error on Gradle 2.3.2
My Gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion '26.0.0'
defaultConfig {
applicationId "********"
minSdkVersion 21
targetSdkVersion 26
versionCode 3
versionName "2.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:26.0.0-beta2'
compile 'com.android.support:design:26.0.0-beta2'
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.android.support:cardview-v7:26.0.0-beta2'
compile 'com.android.support:recyclerview-v7:26.0.0-beta2'
compile 'com.redbooth:WelcomeCoordinator:1.0.1'
compile 'com.github.kittinunf.fuel:fuel-android:1.4.0'
compile 'com.pkmmte.view:circularimageview:1.1'
compile 'com.ramotion.foldingcell:folding-cell:1.1.0'
}
Have you added the google maven endpoint?
Important: The support libraries are now available through Google's Maven repository. You do not need to download the support repository from the SDK Manager. For more information, see Support Library Setup.
Add the endpoint to your build.gradle file:
allprojects {
repositories {
jcenter()
maven {
url 'https://maven.google.com'
}
}
}
Which can be replaced by the shortcut google() since Android Gradle v3:
allprojects {
repositories {
jcenter()
google()
}
}
If you already have any maven url inside repositories, you can add the reference after them, i.e.:
allprojects {
repositories {
jcenter()
maven {
url 'https://jitpack.io'
}
maven {
url 'https://maven.google.com'
}
}
}
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
}
android {
compileSdkVersion 26
buildToolsVersion "26.0.1"
defaultConfig {
applicationId "com.keshav.retroft2arrayinsidearrayexamplekeshav"
minSdkVersion 15
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
compile 'com.android.support:appcompat-v7:26.0.1'
compile 'com.android.support:recyclerview-v7:26.0.1'
compile 'com.android.support:cardview-v7:26.0.1'
Appart from setting maven source url to your gradle, I would suggest to add both design and appcompat libraries.
Currently the latest version is 26.1.0
maven {
url "https://maven.google.com"
}
...
compile 'com.android.support:appcompat-v7:26.1.0'
compile 'com.android.support:design:26.1.0'
You could add google() to repositories block
allprojects {
repositories {
jcenter()
maven {
url 'https://github.com/uPhyca/stetho-realm/raw/master/maven-repo'
}
maven {
url "https://jitpack.io"
}
google()
}
}
Appears to be resolved by Android Studio 3.0 Canary 4 and Gradle 3.0.0-alpha4.
you must add in your MODULE-LEVEL build.gradle file with:
//module-level build.gradle file
repositories {
maven {
url 'https://maven.google.com'
}
}
see: Google's Maven repository
I have observed that when I use Android Studio 2.3.3 I MUST add repositories{maven{url 'https://maven.google.com'}} in MODULE-LEVEL build.gradle.
In the case of Android Studio 3.0.0 there is no need for the addition in module-level build.gradle. It is enough the addition in project-level build.gradle which has been referred to in the other posts here, namely:
//project-level build.gradle file
allprojects {
repositories {
jcenter()
maven {
url 'https://maven.google.com/'
name 'Google'
}
}
}
UPDATE 11-14-2017: The solution, that I present, was valid when I did the post. Since then, there have been various updates (even with respect to the site I refer to), and I do not know if now is valid. For one month I did my work depending on the solution above, until I upgraded to Android Studio 3.0.0

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.

Getting error while adding Facebook SDK in build.gradle

I am working on a project where I need to implement facebook login. For that purpose I followed the steps from the developer website as mentioned. But unfortunately getting build error after adding'com.facebook.android:facebook-android-sdk:4.1.0' in build.gradleas follows
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.example.facebook"
minSdkVersion 11
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
repositories {
mavenCentral()
}
dependencies {
compile 'com.android.support:appcompat-v7:22.2.0'
compile 'com.facebook.android:facebook-android-sdk:4.1.0'
}
Error log which I am getting:
Error:A problem occurred configuring project ':app'.
> Could not resolve all dependencies for configuration ':app:_debugCompile'.
> Could not resolve com.facebook.android:facebook-android-sdk:4.1.0.
Required by: ExampleApp:app:unspecified
> No cached version of com.facebook.android:facebook-android-sdk:4.1.0 available for offline mode.
> No cached version of com.facebook.android:facebook-android-sdk:4.1.0 available for offline mode.
Please help me to resolve this issue which I am facing right for a couple of days. I am really helpless and stuck up with the solutions. Any kind of suggestions would be much useful to fix my issue.
Your log gives the answer:
No cached version of com.facebook.android:facebook-android-sdk:4.1.0 available for offline mode.
Gradle is in offline mode, so it cannot download a new version of your library.
Go to Preferences > Build, Execution, Deployment > Build Tools > Gradle
and disable "Offline work".
Preferences can be accessed from here:
You do not need repositories in this gradle file as you should have one "global" build.gradle so remove this entry from module's grade file. And you should also check what repository is set there as it should be jcenter() not mavenCentral() as the latter is replaced with jcenter() for some time now.
allprojects {
repositories {
jcenter()
}
}

Gradle Build stuck at generate debug sources

Gradle gets stuck when I try to build on the task [:android:generateDebugSources].
I've left it running for hours without a successful build.
I've tried it in Android Studio 1.0.0, 0.8.1, with Gradle versions 2.1.1, 1.12, 1.14, Android plugin versions 0.12.+ and 0.14.4 using the default wrapper as well as local distributions. I've reinstalled Android Studio and rebooted without any luck. Also tried File --> invalidate caches/Restart.
Here is my android package's build.gradle:
buildscript {
repositories
{
maven { url 'https://maven.fabric.io/repo' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'android'
apply plugin: 'io.fabric'
repositories {
maven { url 'https://maven.fabric.io/repo' }
}
android {
compileSdkVersion 21
buildToolsVersion '21.1.1'
defaultConfig {
minSdkVersion 11
targetSdkVersion 21
versionCode 13
versionName "onBoarding"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile files('libs/android-query-full.0.26.8.jar')
compile files('libs/gson-2.3.jar')
compile 'com.android.support:appcompat-v7:21.+'
compile 'com.android.support:support-v4:21.+'
compile 'com.android.support:recyclerview-v7:21.+'
compile 'com.google.android.gms:play-services:6.1.71'
}
And then my project-level gradle.build file:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.12.+'
}
}
allprojects {
repositories {
mavenCentral()
}
}
Any advice greatly appreciated.
Got it! Changing the buildToolsVersion from 21.1.1 to 20 yielded a successful build.
You can also, just install the correct version of the tools.
I know this is an old question, but I spent a lot of time in this problem and read at least 30 answers until I found out what was hapenning.
I constantly got a message that another aplication was locking a file that Android-Studio needed to complete gradle building. Finally, I found out that it was Avast. So I simply deactivated it and the build finished successfully, but it still took a long time (about 10 minutes).
Tried below option and it worked!
Add below properties to your .gradle file
org.gradle.daemon=true
org.gradle.parallel=true
Set SLAVE_AAPT_TIMEOUT environment variable to 30 in windows and restart your system.
Second solution credit goes to semuzaboi.

Network is unreachable: connect

After Upgrading to version 0.4.0 of Android Studio, I have started getting the following error when compiling my project:
A problem occurred configuring project ':muve'.
> Could not resolve all dependencies for configuration ':muve:classpath'.
> Could not resolve com.android.tools.build:gradle:0.7.+.
Required by:
MUVE:muve:unspecified
> Failed to list versions for com.android.tools.build:gradle:0.7.+.
> Could not list versions using M2 pattern 'http://repo1.maven.org/maven2/[organisation]/[module]/[revision]/[artifact]-[revision](-[classifier]).[ext]'.
> Could not GET 'http://repo1.maven.org/maven2/com/android/tools/build/gradle/'.
> Network is unreachable: connect
My build.gradle file is:
buildscript {
repositories {
maven { url 'http://repo1.maven.org/maven2' }
}
dependencies {
classpath 'com.android.tools.build:gradle:0.7.+'
}
}
apply plugin: 'android'
repositories {
mavenCentral()
}
android {
compileSdkVersion 18
buildToolsVersion "19.0.0"
defaultConfig {
minSdkVersion 11
targetSdkVersion 18
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:appcompat-v7:+'
}
I am at a loss on how to resolve the issue. Any help would be highly appreciated.
Thanks
It's a networking problem, somewhere between you and Maven Central. Try again after a while, perhaps with --refresh-dependencies. I've you've successfully built with the same dependencies before, you can also try an offline build (-o).
Try this and check whether your studio can make connection successful with mention maven repository in error.
Go to File > Settings > HTTP proxy , select auto detect proxy settings just for test.
In my case, I was using an HTTP proxy, and this was my .gradle/gradle.properties :
systemProp.http.proxyHost=10.23.201.11
systemProp.http.proxyPort=3128
I changed it to HTTPS, even though I was using HTTP
systemProp.https.proxyPort=3128
systemProp.https.proxyHost=10.23.201.11
When I hit Sync, Android Studio Popped this:
Android Studio Pop up
Uncheck the HTTPS proxy and then OK.

Categories

Resources