So I have bees stuck on this all day on android studio.
I have tried to follow this tutorial to add support for google maps API for my application
https://developers.google.com/maps/documentation/android/start#install_the_android_sdk
but when I try to build the application this error appears
Gradle: Execution failed for task ':dexDebug'.
Could not call IncrementalTask.taskAction() on task ':dexDebug'
here is my build.gradel
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.6.+'
}
}
apply plugin: 'android'
dependencies {
compile 'com.android.support:appcompat-v7:+'
compile 'com.google.android.gms:play-services:4.0.30'
compile fileTree(dir: 'libs', include: '*.jar')
}
android {
compileSdkVersion 16
buildToolsVersion "18.1.1"
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
// Move the tests to tests/java, tests/res, etc...
instrumentTest.setRoot('tests')
// Move the build types to build-types/<type>
// For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
// This moves them out of them default location under src/<type>/... which would
// conflict with src/ being used by the main source set.
// Adding new build types or product flavors should be accompanied
// by a similar customization.
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}
}
When I remove remove this line for testing the said error doesn't appear.
compile 'com.google.android.gms:play-services:4.0.30'
Does anyone know what the error code be?
Do you have the Play Services installed? In Android Studio, go to the SDK Manager. Under Extras, make sure you have the latest revision of Google Play services. After you install, you may have to restart Android Studio.
To double-check that 4.0.30 was downloaded, you can check that the Android Studio's local Maven repository contains the folder. The path is something like:
/Applications/Android Studio.app/sdk/extras/google/m2repository/com/google/android/gms/4.0.30
Related
I tired so much things about this error but I couldn't fix it.
Error:Execution failed for task ':app:processDebugResources'.
Error: more than one library with package name 'com.google.android.gms'
Build.gradle:
apply plugin: 'android-library'
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
compile project(':google-play-services_lib')
}
android {
compileSdkVersion 10
buildToolsVersion "25.0.2"
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
// Move the tests to tests/java, tests/res, etc...
instrumentTest.setRoot('tests')
// Move the build types to build-types/<type>
// For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
// This moves them out of them default location under src/<type>/... which would
// conflict with src/ being used by the main source set.
// Adding new build types or product flavors should be accompanied
// by a similar customization.
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}
}
Thanks a lot.
You are comping google play service library, but in your gradle file, have some libraries depend on this lib. So having you error more than one library with package. First, you check your libs dir which lib contains google play service library, if having you no need to compile compile project(':google-play-services_lib'). I think the best way you can follow https://developers.google.com/android/guides/setup to setup exactly google play service.
I have problem with Android Studio in build.gradle after I converted Eclipse project to Android Studio project.
I spent more than 2 hours finding a solution, with no results!!
build.gradle code:
apply plugin: 'android'
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
}
android {
compileSdkVersion 19
buildToolsVersion "17.0.0"
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
// Move the tests to tests/java, tests/res, etc...
instrumentTest.setRoot('tests')
// Move the build types to build-types/<type>
// For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
// This moves them out of them default location under src/<type>/... which would
// conflict with src/ being used by the main source set.
// Adding new build types or product flavors should be accompanied
// by a similar customization.
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}
}
It gives: Error:(1, 0) Plugin with id 'com.android.application' not found.
Screen Shot
Any help will be appreciated ...
This error message means that it can't find the plugin at all. In Gradle, you need to tell it where to go to look for plugins, which is different from telling it where to go to resolve module dependencies. Add this block to the beginning of your build 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
}
}
In projects that Android Studio creates, the New Project wizard will put this in the top-level build file in your project, but based on the screenshot it looks like your project only has a single build file, so there's only one place to put it.
I want to be able to make unit tests and instrumentation tests in Android Studio, and using Mockito in them.
I'm using the new approach for tests in Android Studio 0.8. This is:
building with gradle
using official Android API for testing (ActivityInstrumentationTestCase2, etc)
having the tests inside the directory of the app, not as a separate module
launching the tests in Android Studio as a "Android Test" run configuration
How can I write code in my tests that depends on libraries used only for the tests, such as mockito or hamcrest?
I'd like to include these libraries when compiling and running the tests, but avoid them to be exported to the released .apk.
In https://code.google.com/p/mockito/wiki/DeclaringMockitoDependency I've read that I should add the dependency as:
dependencies {
....
testCompile "org.mockito:mockito-core:1.9.5"
}
But when running I get:
Build script error, Unsupported Gradle DSL method found:
'testCompile()'!
Although I'm not sure it's relevant, the gradle build file I'm using is:
apply plugin: 'android'
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
compile project(':android-sdk')
testCompile "org.mockito:mockito-core:1.9.5"
}
android {
compileSdkVersion 19
buildToolsVersion "20.0.0"
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
// Move the tests to tests/java, tests/res, etc...
androidTest.setRoot('tests')
// Note - to run the tests from command line:
// $ gradle clean connectedCheck build
// (requires gradle 1.10)
// Move the build types to build-types/<type>
// For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
// This moves them out of them default location under src/<type>/... which would
// conflict with src/ being used by the main source set.
// Adding new build types or product flavors should be accompanied
// by a similar customization.
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}
}
I got it working by using the "androidTestCompile" options under "dependencies", as explained here.
What I have done is:
created a folder called libs-tests with the jars that should only be used for testing.
added that folder as a dependency for tests with "androidTestCompile"
Now, the gradle build file stands as:
apply plugin: 'android'
dependencies {
compile project(':android-sdk')
// The libs folder is included in the apk of the real app
compile fileTree(dir: 'libs', include: '*.jar')
// The tests-libs folder is included only for tests
androidTestCompile fileTree(dir: 'libs-tests', include: '*.jar')
}
android {
compileSdkVersion 19
buildToolsVersion "20.0.0"
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
// Move the tests to tests/java, tests/res, etc...
androidTest.setRoot('tests')
// Note - to run the tests from command line:
// $ gradle clean connectedCheck build
// (requires gradle 1.10)
// Move the build types to build-types/<type>
// For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
// This moves them out of them default location under src/<type>/... which would
// conflict with src/ being used by the main source set.
// Adding new build types or product flavors should be accompanied
// by a similar customization.
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}
}
I had that exact problem too.
I used androidTestCompile instead of testCompile
I also had to have the classpath 'com.android.tools.build:gradle:1.1.0' [or higher]
then i did a buildDependecies before doing a sync.
thats all i did for this error to go away.
Since the android gradle plugin version 1.1.0, there is support for unit testing so you can use testCompile in the gradle files. Turn it on with settings > gradle > experimental and update the gradle plugin version:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.0'
}
}
I used androidTestCompile instead of testCompile
This is my first project using Android Studio so spare me if you find this question naive. I am trying to include the Cardslib library to my project in Android Studio (version 0.8.1). Initially I tried to include it by adding the following line in build.gradle:
compile 'com.github.gabrielemariotti.cards:library:1.7.3'
But it returned the following error (upon sync)
Error:Failed to find: com.github.gabrielemariotti.cards:library:1.7.3
The I tried to include the jar file by,
Downloading it from maven repository
Adding jar file to libs folder.
Adding following line in build.gradle
compile files('libs/library-1.7.3-sources.jar')`
Though gradle project sync without any error but I am not able to create simple cards i.e still not working for me.
I wanted the first method to work since Android Studio would then handle everything but I guess I am doing something horribly wrong.
[Edit] - Adding the build.gradle code
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.12.+'
}
}
apply plugin: 'android'
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
compile 'com.github.gabrielemariotti.cards:library:1.7.3'
}
android {
compileSdkVersion 19
buildToolsVersion '20.0.0'
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
// Move the tests to tests/java, tests/res, etc...
instrumentTest.setRoot('tests')
// Move the build types to build-types/<type>
// For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
// This moves them out of them default location under src/<type>/... which would
// conflict with src/ being used by the main source set.
// Adding new build types or product flavors should be accompanied
// by a similar customization.
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}
}
Add this block in your script to tell gradle where it can find the repo with libs.
repositories {
mavenCentral()
}
So your script will be something like this:
.......
apply plugin: 'android'
repositories {
mavenCentral()
}
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
compile 'com.github.gabrielemariotti.cards:library:1.7.3'
}
.......
I have exported my Android project in Eclipse as gradle build files, and imported in Android Studio.
I have updated my Android Studio today to v0.6.0 which built on June 05, 2014.
As a remote dependency I have added AppCompat to the dependencies which works fine as expected.
compile 'com.android.support:appcompat-v7:19.+'
But when I try to add other libraries such as SmoothProgressBar, actionbarsherlock, nineoldandroids and etc, it fails. When I run the app it shows following in Gradle Build tab:
Error:A problem occurred configuring root project 'MyApp'.
> Could not resolve all dependencies for configuration ':_debugCompile'.
> Could not find com.github.castorflex.smoothprogressbar:library:0.5.1.
Required by:
:MyApp:unspecified
And when I sync project with Gradle file, it shows following in Gradle Sync tab:
Error:com.github.castorflex.smoothprogressbar:library:0.5.1 (double-click here to find usages.)
I tried an empty new project and add remote dependency for mentioned libraries(Sherlock and etc) worked as expected. So I guess I missed something in build.gradle or any other solution?
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.11.+'
}
}
apply plugin: 'android'
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
compile 'com.github.castorflex.smoothprogressbar:library:0.5.1'
compile 'com.android.support:appcompat-v7:19.+'
}
android {
compileSdkVersion 19
buildToolsVersion "19.1.0"
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
// Move the tests to tests/java, tests/res, etc...
instrumentTest.setRoot('tests')
// Move the build types to build-types/<type>
// For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
// This moves them out of them default location under src/<type>/... which would
// conflict with src/ being used by the main source set.
// Adding new build types or product flavors should be accompanied
// by a similar customization.
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}
}
Add this code to your build.gradle
repositories {
mavenCentral()
}
Update to explain the answer:
To resolve your dependencies, you have to indicate in the gradle script which are the repositories to be used. You can use more repositories...
With the support libs (support and support-compact) it is not necessary, because the android plugin searches in your androidRepository and googleRepository downloaded with your SDK Manager.