Android Studio Gradle build failing when trying to include local library - android

The error I am getting is:
Gradle 'MyProject' project refresh failed:
Project with path 'libraries:mylibrary_sdk' could not be found in project':myproject'
This is my settings gradle
include ':libraries:mylibrary_sdk',':myproject'
Top level build gradle
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.9+'
}
}
allprojects {
repositories {
mavenCentral()
}
}
myproject build gradle
apply plugin: 'android'
dependencies {
compile 'com.android.support:support-v4:19.0.1'
compile project ("libraries:mylibrary_sdk")
}
android {
compileSdkVersion 19
buildToolsVersion "19.0.3"
defaultConfig {
minSdkVersion 16
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
}
mylibrary_sdk build gradle
apply plugin: 'android-library'
android {
compileSdkVersion 19
buildToolsVersion "19.0.3"
defaultConfig {
minSdkVersion 9
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:appcompat-v7:+'
compile fileTree(dir: 'libs', include: ['*.jar'])
}
I have read over all the similar answers but I am still stuck on this issue. If I remove compile project ("libraries:mylibrary_sdk") and the libraries:mylibrary_sdk include then myproject builds fine, just without access to mylibrary. The libraries folder is at the same level as settings.gradle, the top level build.gradle and the folder with myproject.
Any help would be appreciated.

This works, adding in answer..it might help someone later
dependencies { compile 'com.android.support:support-v4:19.0.1' compile project (":libraries:mylibrary_sdk") }

Related

Android Studio Failed to resolve:com.github.PhilJay:MPAndroidChart:v2.1.3

Hi all i am using charts library in my project a month ago it was working fine but now i have reinstalled android studio and when i build my project it gives gradle sync error.
Failed to resolve:com.github.PhilJay:MPAndroidChart:v2.1.3
I am stuck on this any suggestions how to solve this.My android studio version is 2.1
Here is project dependencies
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion '23.0.2'
defaultConfig {
applicationId "com.app.comismv"
minSdkVersion 14
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
repositories {
maven {
jcenter()
url "https://jitpack.io"
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.2.0'
compile 'com.github.PhilJay:MPAndroidChart:v2.1.3'
compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.3'
//compile 'com.cardiomood.android:android-widgets:0.1.1'
}
Thanks in advance
I had the same problem, here is the latest version of MPAndroidChart-v2.2.5.jar jar file.
Just put the MPAndroidChart-v2.2.5.jar inside app/libs/
and add
dependencies {
.
.
compile files('libs/MPAndroidChart-v2.2.5.jar')
}
in gradle file

How to fix "Error:Error:line (23)Gradle DSL method not found: 'android()"

I was working on my project in Android Studio on Windows but now I am trying to open it on Ubuntu but it keeps complaining that:
Error:Error:line (23)Gradle DSL method not found: 'android()' Possible causes: //(Error23,0)
The project 'POSTER' may be using a version of Gradle that does not contain the method. Open Gradle wrapper file
The build file may be missing a Gradle plugin. Apply Gradle plugin
Project Gradle
// 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:2.1.2'
classpath 'com.google.gms:google-services:3.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
android {
compileSdkVersion 23
buildToolsVersion '24.0.0'
}
App Gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "24.0.0"
defaultConfig {
applicationId "com.ozuf.poster"
minSdkVersion 16
targetSdkVersion 23
versionCode 5
versionName "0.5 Beta"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile project(':volley')
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'
compile 'org.jsoup:jsoup:1.9.1'
compile 'com.android.support:support-v4:23.4.0'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:design:23.4.0'
compile 'com.android.support:cardview-v7:23.4.0'
compile 'com.android.support:recyclerview-v7:23.4.0'
compile 'ch.acra:acra:4.9.0-RC-2'
compile 'com.google.firebase:firebase-core:9.0.2'
compile 'com.google.firebase:firebase-ads:9.0.2'
}
apply plugin: 'com.google.gms.google-services'
Gradle-wrapper.properties
#Fri Apr 08 19:27:52 WAT 2016
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
Please, do you have any idea what's causing this and how to fix it?
delete android settings in project gradle
android {
compileSdkVersion 23
buildToolsVersion '24.0.0'
}
if you want to set as common config, you can use is like this:
project gralde:
ext {
compileSdkVersion 23
buildToolsVersion '24.0.0'
}
app gralde:
apply plugin: 'com.android.application'
android {
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion
defaultConfig {
applicationId "com.ozuf.poster"
minSdkVersion 16
targetSdkVersion 23
versionCode 5
versionName "0.5 Beta"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

Failed to resolve: com.github.moondroid.coverflow:library:1.0

CoverFlow is pushed to Maven Central as a AAR, so you just need to add the it's dependency to local build.gradle (usually locate in app module). Because of this libary is build in the min-sdk is 15, so your project must set same as it:
but when I try to use this library I got this error
Failed to resolve: com.github.moondroid.coverflow:library:1.0
this is my gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "com.example.maysara.theproject"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.3.0'
compile 'com.android.support:design:23.3.0'
compile 'com.github.moondroid.coverflow:library:1.0'
compile 'com.android.support:cardview-v7:23.0.1'
}
Add to your graldle file:
apply plugin: 'com.android.application'
repositories {
mavenCentral()
}
At first set minSdkVersion 15 instead of 16
Whats your Logcat says
so you just need to add the it's dependency to local build.gradle
(usually locate in app module). Because of this libary is build in the
min-sdk is 15, so your project must set same as it:
defaultConfig {
applicationId "com.example.maysara.theproject"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
FYI
Enable publishing AAR file to Maven Central
repositories {
jcenter() // or mavenCentral()
}

Add external library into android studio 0.5.1 project

I'm using an external library SVProgressHUD in my Android studio project as a module. Everything is fine until I upgraded my Android studio to 0.5.1. It always shows the follow error message:
Error:(7, 17) package org.lcsky does not exist
Here is my settings.gradle:
include ':app',':SVProgressHUD'
My build.gradle in project folder:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.9.+'
}
}
allprojects {
repositories {
mavenCentral()
}
}
My build.gradle in SVProgressHUD module:
apply plugin: 'android'
android {
compileSdkVersion 19
buildToolsVersion "19.0.0"
defaultConfig {
minSdkVersion 8
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:appcompat-v7:+'
}
The build.gradle in my main module:
apply plugin: 'android'
android {
compileSdkVersion 19
buildToolsVersion '19.0.0'
defaultConfig {
minSdkVersion 8
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:appcompat-v7:+'
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':SVProgressHUD')
}
The gradle-wrapper.properties
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=http\://services.gradle.org/distributions/gradle-1.10-all.zip
Can anybody tell me what could be wrong? Thanks
I solved the problem by changing the build.gradle in SVProgressHUD module:
apply plugin: 'android-library'
Previously it works (before Android 0.5.1) when I set it to:
apply plugin: 'android'

Failed to resolve: com.facebook.android:facebook-android-sdk:4.4.0

Below is code from my build.gradle file.
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "23.0.0 rc3"
defaultConfig {
applicationId "com.example.test"
minSdkVersion 14
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
repositories {
mavenCentral()
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.2.1'
compile 'com.facebook.android:facebook-android-sdk:4.4.0'
}
When I do Sync project with gradle files, it gives me error.
Error:(28, 13) Failed to resolve: com.facebook.android:facebook-android-sdk:4.4.0
Can anyone tell me why I'm getting this error?
Similar question has been asked here but no one has answered it. (
Failed to resolve: com.facebook.android:facebook-android-sdk:4.0.0 )
Finally after spending 6-8 hours on it. I got the solution for you. You have to just change repositories section in your app build.gradle file. change it from mavenCentral to jcenter as following
repositories {
jcenter {
url "http://jcenter.bintray.com/"
}
}
After having this, You can simply add the dependency as
compile 'com.facebook.android:facebook-android-sdk:4.0.0'
Try This,
dependencies {
compile 'com.facebook.android:facebook-android-sdk:4.4.1'
}
Information
buildToolsVersion "23.0.0 rc3" is not stable purely .Set minSdkVersion 15

Categories

Resources