Android Gradle build - dependencies Error - android

I use:
android studio 1.5.1
java version "1.7.0_80"
I want to create a new android project as
Min Api-version = 15
But android studio cannot create new application , a dialog is opened with this title :
"Building 'MyApplication' Gradle project info"
and its content is :
a text: "Gradle: Resolve dependencies ':app:_debugCompile'"
and a progressBar;
unfortunately this dialog is opened for long time,just now ...
I had some projects , but when I want to build gradle for them below error is shown to me :
Error:(3, 0) Gradle DSL method not found: 'android()'
Possible causes:The project 'e-project' may be using a version of the Android Gradle plug-in that does not contain the method (e.g. 'testCompile' was added in 1.1.0).
Fix plugin version and sync project
The project 'e-project' may be using a version of Gradle that does not contain the method.
openGradleSettings Gradle settings The build file may be missing a Gradle plugin.
"apply.gradle.plugin Apply Gradle plugin
Edit 1: I added build.gradle
apply plugin: 'application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.e_example.android.app"
minSdkVersion 14
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'])
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile 'com.android.support:support-v4:23.1.1'
compile 'com.google.android.gms:play-services:8.4.0'
}

Related

Plugin is too old, please update to a more recent version,Fix plugin version and sync project

I have setup android studio 2.2 and my sdk contains api 23 as well as api 24.
My build.gradle file is as below :
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "24.0.2"
defaultConfig {
applicationId "com.example.sanjay.myapplication"
minSdkVersion 15
targetSdkVersion 24
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
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:24.2.1'
compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha1'
testCompile 'junit:junit:4.12'
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2'
androidTestCompile 'com.android.support.test:runner:0.5'
androidTestCompile 'com.android.support:support-annotations:24.2.1'
}
I have getting below error :
Error:(1, 0) Plugin is too old, please update to a more recent version, or set ANDROID_DAILY_OVERRIDE environment variable to "9d813ee66dd60f65615706c5deaa14afed669ca5"
Fix plugin version and sync project</a><br>Open File
Please let me know, Whats going wrong here, Thank you.
When such error is shown (Plugin is too old, please update to a more recent version, Fix plugin version, and sync project), click on the Fix plugin version and sync project which appeared in the log cat. the Gradle will sync and you are good to go.
Update your Project level Build.gradle to
dependencies {
classpath 'com.android.tools.build:gradle:2.2.0'
}
Download the latest gradle from https://gradle.org/gradle-download/ and
Goto: Build, Execution, Deployment ->> Build Tools ->> Gradle (Or just type in the searchbar Gradle)
Select: (X) Use local gradle distribution and set Gradle home to your extracted Gradle directory. Click on apply.
Update your Project Build.gradle to
dependencies
{
classpath 'com.android.tools.build:gradle: "latest version here" '
}
see Grade Version Compatibility for Android Studio

How to change build tools version in Android Studio

I have a problem using jfeinstein10 Sliding Menu
I added the library into my root project folder. But I get this error :
Error:The SDK Build Tools revision (17.0.0) is too low for project
':SlidingMenu'. Minimum required is 19.1.0
But I'm already using "19.1.0" but it still says I'm using 17.0.0
Here is my build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "19.1.0"
defaultConfig {
applicationId "com.repliklernet.replikler"
minSdkVersion 14
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 group:'com.squareup.picasso', name:'picasso', version:'2.5.0'
compile project(':SlidingMenu')
}
What am I missing ?
If you look at the build.gradle file for the library, you can see that it references build tools 17: https://github.com/jfeinstein10/SlidingMenu/blob/master/library/build.gradle#L17
You need to update that line.
The error is actually giving you a hint by mentioning project ':SlidingMenu', referring to the project SlidingMenu.
Right click on the project folder and choose 'Open Module Setings'
Select 'app' on the Modules List(Left pane)
Select 'Properties' tab and will present you with 'Compile SDK Version', 'Build Tools Version'.
Click OK
Reference : https://www.youtube.com/watch?v=v4b7C6Q-9dI
You should change the build.gradle within your library

iTextPdf - Android Studio Adding Library Error

I want to add itext lib to my project.(http://itextpdf.com/itextg-android)
I added to jar file into libs folder. After that i wrote to build.gradle that : compile files('libs/itextg-5.5.4.jar') .
But after the sync , i am getting that error :
Error:(12, 0) Gradle DSL method not found: 'compile()'
Possible causes:The project 'Pdf' may be using a version of Gradle that does not contain the method.
Gradle settingsThe build file may be missing a Gradle plugin.
Apply Gradle plugin
Also here(http://www.codeproject.com/Articles/986574/Android-iText-Pdf-Example) is a solution about this but when i do that i am getting another error
Error:Failed to resolve: org.apache.commons:commons-imaging:1.0-SNAPSHOT
Open FileShow in Project Structure dialog
Please check if you added all needed packages and after this your buil.gradle looks like:
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.proyecto.alberto.monedero"
minSdkVersion 16
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.0.0'
compile files('libs/itextg-5.5.4.jar')
compile files('libs/itextg-5.5.4-sources.jar')
compile files('libs/itextg-5.5.4-javadoc.jar')
compile 'com.google.android.gms:play-services:7.0.0'
}
From: https://github.com/alonsoat/ProyectoMonedero/blob/master/app/build.gradle
Hope it help
You can also add a .jar or a library via right clicking on
"app" > New > Module
Then select the
Import .JAR/.AAR Package option.
You can click the "browse" [...] on the far right and locate your jar.
Sync the project right click app > Sync app
You should be golden after that.
Alt-Shift over RED methods/code relevant to your added library and you should now be able to quick import.
Just another option.

Unable to add Minim-Android library in Android Studio with jitpack

I am trying to add to my build.gradle file in Android Studio the following dependency:
https://android-arsenal.com/details/1/1883
I followed the intstructions found in package tab of this page, but when I tried to build the project I got the following message:
Error:(32, 13) Failed to resolve:
com.github.DASAR:Minim-Android:a73b596916
Anyone can help me?
I also tried to download the project code and import it in Android Studio as a module, but it wasn't recognized as a library from the wizard.
Thank you all in advance.
You can download relative API in your AS SDK Manager, then add it in build.gradle. After that, check out the compileSdkVersion, targetSdkVersion are same with appcompat. My build.gradle is:
apply plugin: 'com.android.application'
android {
compileSdkVersion 19
buildToolsVersion "21.0.1"
defaultConfig {
applicationId "com.example.android"
minSdkVersion 9
targetSdkVersion 19
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:19.0.0'
}
my sdk is 19
Best option is to fork the project and add a Gradle build file. Then use JitPack to build the fork.
Note that the project has dependencies in a libs/ folder so these would need to be converted to dependencies in Gradle.

Failed to find: com.android.support:support-v4:22.2.0

I am trying to do an application but there seems to be some error with the gradle files now. It was working fine until I upgraded the support libraries.
I was working with api 21 which worked fine, but then i upgraded to api22 and changed the gradle files accordingly.. Now this error shows up.
Error:Failed to find: com.android.support:support-v4:22.2.0
This is my current gradle file :
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.example.sampleapp"
minSdkVersion 12
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.0'
compile 'com.android.support:recyclerview-v7:22.2.0'
compile 'com.jakewharton:butterknife:6.1.0'
}
Any help would be appreciated.
If this might help someone, after MANY trials and errors, I found that I was targeting the wrong SDK version (an older one) in the build.gradle file corresponding to "library". To change this you can do it by hand or go to the Module Settings Menu (right click on your project folder -> Open Module Settings. Then in "library" - Properties you can change the Compile Sdk and the Build Tools Versions
Using Android SDK Manager. Go to Extras and then Android Support Repository and update it to the latest version.
(This is essentially the comment #natario made, but it should be an answer.)

Categories

Resources