I have two projects. DataModel and my application.
My application starts successfully but then fails with classnotfoundexception. Cant find DataModel project.I used to have the same problem before but I could fix it by updating gradle files although randomly android studio would screw them
DataModel build.gradle
apply plugin: 'java'
MyApplication build.gradle
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.6.+'
}
}
apply plugin: 'android'
repositories {
mavenCentral()
}
android {
compileSdkVersion 18
buildToolsVersion "18.1.1"
defaultConfig {
minSdkVersion 10
targetSdkVersion 18
}
}
dependencies {
compile 'com.android.support:appcompat-v7:18.0.0'
compile 'com.android.support:gridlayout-v7:18.0.0'
compile 'com.android.support:support-v4:18.0.0'
compile 'com.google.code.gson:gson:2.2.4'
compile 'com.squareup.okhttp:okhttp:1.2.1'
compile 'com.squareup.retrofit:retrofit:1.2.2'
compile project(':DataModel')
}
MyApplication settings.gradle
include ':MyApplication ', ':DataModel'
Have you tried to clean the project? Build--> Clean
There is actually a known issue about something like that, maybe it's enough if you update to 0.3.6.
https://code.google.com/p/android/issues/detail?id=62011
Related
I'm trying to add a library as a dependency but it keeps giving me this error:
Class android.support.v4.accessibilityservice.AccessibilityServiceInfoCompat.AccessibilityServiceInfoIcsImpl
has already been added to output. Please remove duplicate copies.
Execution failed for task ':BrooklynTech:dexDebug'.
Could not call IncrementalTask.taskAction() on task ':BrooklynTech:dexDebug'
Here is my build.gradle:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.6.+'
}
}
apply plugin: 'android'
repositories {
mavenCentral()
}
android {
compileSdkVersion 19
buildToolsVersion '19.0.0'
defaultConfig {
minSdkVersion 14
targetSdkVersion 19
}
}
dependencies {
compile files('libs/Simple-Rss2-Android.jar')
compile 'org.jsoup:jsoup:1.7.3'
compile 'uk.co.androidalliance:edgeeffectoverride:1.0.1'
compile 'com.github.chrisbanes.actionbarpulltorefresh:library:+'
compile project(':libraries:calendar-card')
compile 'com.twotoasters.jazzylistview:library:1.0.0' }
the dependency I added was for jazzylistview - https://github.com/twotoasters/JazzyListView
How can I fix the error?
More than one of your dependencies is including the classes from the v4 support library; you'll need to track it down. You ought to be able to open up the jar files from the project viewer and find the culprit.
Ideally none of your dependencies ought to be bundling the support library; it's the responsibility of your app's build to make sure that gets finally linked in.
Not sure, but could you try the following snippet. Maybe the transitive libs are causing the trouble
dependencies{
...
compile ('com.twotoasters.jazzylistview:library:1.0.0'){
transitive = false
}
}
cheers,
René
In Android Studio I'm trying to compile an Android application module which uses an Android library.
The library includes a jar file for Bugsense (included automatically by gradle).
Although the library module compiles correctly, the application module fails because it is looking for the Bugsense jar file that is used within the library module.
I do have a workaround which allows the project to compile. By also including the Bugsense dependency in the project everything works.
My question is: How do I make the project compile without duplicating the Bugsense dependency?
Here is my build.gradle file for the library project.
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.6.+'
}
}
apply plugin: 'android-library'
repositories {
mavenCentral()
maven { url 'http://www.bugsense.com/gradle/' }
}
android {
compileSdkVersion 15
buildToolsVersion "19.0.0"
defaultConfig {
minSdkVersion 15
targetSdkVersion 15
}
}
dependencies {
compile 'com.bugsense.trace:bugsense:3.6'
}
The library project is called "util"
Following is the android section of the build.gradle for the application
android {
compileSdkVersion 15
buildToolsVersion '19.0.0'
defaultConfig {
minSdkVersion 15
targetSdkVersion 15
}
dependencies {
compile project(':util')
}
}
When I compile this I get the following error:
* What went wrong:
A problem occurred configuring project ':br'.
> Failed to notify project evaluation listener.
> Could not resolve all dependencies for configuration ':br:_DebugCompile'.
> Could not find com.bugsense.trace:bugsense:3.6.
Required by:
dss:br:unspecified > dss:util:unspecified
I can make the compile work by adding Bugsense to the repositories section of the build.gradle file for the application. Following is the code I added to the build.gradle file for the application project.
repositories {
mavenCentral()
maven { url 'http://www.bugsense.com/gradle/' }
}
Remember, the above code is in the build.gradle for the application project AND the library.
How do I avoid adding the Bugsense dependency to both the application and library projects?
UPDATES:
I'm using Gradle 1.8
I'm compiling from the command line with "gradle clean assembleDebug"
The following is the complete build.gradle file for the application project:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.6.+'
}
}
apply plugin: 'android'
repositories {
mavenCentral()
//maven { url 'http://www.bugsense.com/gradle/' }
}
android {
compileSdkVersion 15
buildToolsVersion '19.0.0'
defaultConfig {
minSdkVersion 15
targetSdkVersion 15
testPackageName "com.myapp.test"
}
dependencies {
compile project(':common')
compile project(':util')
}
}
dependencies {
instrumentTestCompile 'com.jayway.android.robotium:robotium-solo:4.3'
instrumentTestCompile 'com.squareup:fest-android:1.0.+'
instrumentTestCompile 'com.squareup.spoon:spoon-client:1.0.+'
instrumentTestCompile 'com.google.guava:guava:15.0'
}
configurations { spoon }
dependencies { spoon 'com.squareup.spoon:spoon-runner:1.0.5' }
It's the expected behavior. Only the repository declarations for the project whose configuration is currently resolved are taken into account, even when transitive dependencies are involved. Typically, repositories are declared inside the root project's allprojects { .. } or subprojects { ... } block, in which case this problem can never occur.
PS: dependencies { .. } needs to go outside the android { ... } block.
I have been following this tutorial for integrating ActionBarSherlock in the Android Studio IDE.
After following all the steps I get the following error:
Gradle: A problem occurred evaluating project ':MyApp'.
> Could not find property ':actionbarsherlock' on DefaultProjectDependency{dependencyProject='project ':MyApp'', configuration='default'}.
The source of the error is my AndroidStudioProjects\MyApp\myapp\build.gradle file with the contents as follows:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.+'
}
}
apply plugin: 'android'
repositories {
mavenCentral()
}
dependencies {
compile 'com.android.support:support-v4:13.0.+'
compile 'com.google.code.gson:gson:2.2.+'
compile project ':actionbarsherlock'
}
android {
compileSdkVersion 17
buildToolsVersion "17.0.0"
defaultConfig {
minSdkVersion 7
targetSdkVersion 16
}
}
Maybe a late answer, but try like that :
compile project(':actionbarsherlock')
I created a project in Android Studio and added a few dependencies using Maven Central and when I try to compile, I run into this type of errors:
Error:Gradle: Attribute "titleTextStyle" has already been defined
Error:Gradle: Attribute "subtitleTextStyle" has already been defined
[...]
And so on... Here is my build.gradle file:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.+'
}
}
apply plugin: 'android'
repositories {
mavenCentral()
}
android {
compileSdkVersion 18
buildToolsVersion "17.0.0"
defaultConfig {
minSdkVersion 8
targetSdkVersion 18
}
}
dependencies {
// Support Libraries
compile 'com.android.support:support-v4:18.0.0'
compile 'com.android.support:appcompat-v7:18.0.0'
compile 'com.android.support:support-v13:18.0.0'
// Third-Party Librairies
compile 'com.actionbarsherlock:actionbarsherlock:4.4.0#aar'
compile 'ch.acra:acra:4.5.0'
}
Sadly the Make Console doesn't speak as much as Eclipse's Console, so I have no idea of the problem's origin.
Does anyone have an idea of what causes these compile errors?
You should remove this line in your dependencies :
compile 'com.android.support:appcompat-v7:18.0.0'
The last version of Google Play Services now uses appcompat-v7, so u can't use it with actionbarsherlock. You have to use only appcompat-v7 or the previous version of play services:
compile 'com.google.android.gms:play-services:7.0.0'
I am trying to add a library greenDAO from Github to an Android project created in Android Studio. The content of latest build.gradle created are as follow
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.+'
}
}
apply plugin: 'android'
repositories {
mavenCentral()
}
android {
compileSdkVersion 18
buildToolsVersion "18.0.0"
defaultConfig {
minSdkVersion 7
targetSdkVersion 16
}
}
dependencies {
compile 'com.android.support:appcompat-v7:18.0.0'
}
How to go about doing it?
Any pointer to latest blog on Gradle build system with added help.
GreenDao is on Maven Central (here) so you can reference it in your final dependencies block:
dependencies {
compile 'com.android.support:appcompat-v7:18.0.0'
compile 'de.greenrobot:greendao:1.3.2'
}
Then just reference like you normally would. Android Studio will automatically download the jar file and build it into your app.
Just add compile 'de.greenrobot:greendao-generator:2.1.0' to build.gradle and sync it. You can always check the latest version here.
See this blog post for a step by step greenDAO integration tutorial.