SlidingMenu ABS and Android Studio - android

I have read through a bunch of different Stack Overflow posts and various blogs all offering different ways to get these libraries working with android studio but I have yet to be successful with any of them.
I am currently using android studio 0.2.5.
The current error I am getting when trying to run gradlew assemble:
What went wrong:
Execution failed for task ':libraries:ActionBarSherlock:actionbarsherlock:compileReleaseAidl'.
tried to access class com.android.build.gradle.internal.tasks.DependencyBasedCompileTask$DepFileProcessor from class com.android.build.gradle.i
nternal.tasks.DependencyBasedCompileTask
My project structure is as follows:
|MyProject
----|MyProject
----|libraries
--------|ActionBarSherlock
------------|actionbarsherlock
----------------build.gradle
------------|actionbarsherlock-fest
------------|actionbarsherlock-i18n
------------|actionbarsherlock-samples
------------build.gradle
------------settings.gradle
--------|SlidingMenu
------------|library
----------------build.gradle
----|MyProject
----build.gradle
settings.gradle
All the build.gradle files are below:
MyProject - > MyProject -> build.gradle
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.+'
}
}
apply plugin: 'android'
repositories {
mavenCentral()
}
android {
compileSdkVersion 17
buildToolsVersion "17.0.0"
defaultConfig {
minSdkVersion 16
targetSdkVersion 16
}
}
dependencies {
compile 'com.android.support:support-v4:13.0.0'
compile files('libs/Parse-1.3.3/Parse-1.3.3.jar')
compile project(':libraries:ActionBarSherlock:actionbarsherlock')
compile project(':libraries:SlidingMenu:library')
}
MyProject - > libraries -> ActionBarSherlock -> build.gradle
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.+'
}
}
allprojects {
group = 'com.actionbarsherlock'
version = '4.4.0'
repositories {
mavenCentral()
}
tasks.withType(Compile) {
options.encoding = "UTF-8"
}
}
MyProject - > libraries -> ActionBarSherlock -> actionbarsherlock -> build.gradle
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.+'
}
}
apply plugin: 'android-library'
dependencies {
compile 'com.android.support:support-v4:13.0.0'
}
android {
compileSdkVersion 17
buildToolsVersion "17.0.0"
defaultConfig {
minSdkVersion 16
targetSdkVersion 16
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
instrumentTest.setRoot('tests')
}
}
MyProject - > libraries -> ActionBarSherlock -> settings.gradle
include 'actionbarsherlock'
include 'actionbarsherlock-fest'
include 'actionbarsherlock-i18n'
MyProject - > libraries -> SlidingMenu -> library -> build.gradle
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.+'
}
}
apply plugin: 'android-library'
repositories {
mavenCentral()
}
dependencies {
compile 'com.android.support:support-v4:13.0.0'
compile project(':libraries:ActionBarSherlock:actionbarsherlock')
}
android {
compileSdkVersion 17
buildToolsVersion "17.0.0"
defaultConfig {
minSdkVersion 16
targetSdkVersion 16
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
instrumentTest.setRoot('tests')
}
}
MyProject - > settings.gradle
include ':MyProject', ':libraries:SlidingMenu:library', ':libraries:ActionBarSherlock:actionbarsherlock'
I think that's all the important files but please let me know if I missed one.
Thanks for any advice you can give!
Edit 1:
Made sure all the build.gradle files had:
compileSdkVersion 16
buildToolsVersion "18.0.1"
as some were different.
Made sure all manifests had:
<uses-sdk
android:minSdkVersion="16"
android:targetSdkVersion="16"/>
I also updated everything the sdk updater tool had to update but still no luck.

Did you add Dependency to your project in Project Structure

Related

After add Fabric for crash report I can't add new libs in gradle

I'm just installed the library Fabric for Crash monitoring, but now, I'm trying to add a library to rate your app (compile 'com.androidsx:rate-me:4.0.0') but now gradle stops showing that it failed to resolve the library.
buildscript {
repositories {
mavenCentral()
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'com.android.tools.build:gradle:1.0.0'
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'android'
apply plugin: 'io.fabric'
repositories {
maven {
url 'https://maven.fabric.io/public'
}
}
dependencies {
compile('com.crashlytics.sdk.android:crashlytics:2.3.2#aar') {
transitive = true;
}
compile 'com.android.support:support-v4:22.1.1'
compile files('libs/library-1.0.6.jar')
compile files('libs/gcm.jar')
compile files('libs/acra-4.6.1.jar')
compile files('libs/acra-4.6.1-sources.jar')
compile files('libs/acra-4.6.1-javadoc.jar')
compile files('libs/TestFlightLib.jar')
compile files('libs/crouton-1.8.4.jar')
compile project(':LVL')
compile files('libs/bugsense-3.5.jar')
compile 'com.androidsx:rate-me:4.0.0'
}
android {
compileSdkVersion 21
buildToolsVersion '21.1.2'
defaultConfig {
minSdkVersion 8
targetSdkVersion 19
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
instrumentTest.setRoot('tests')
}
}
The output:
What is the problem?
Solved:
jcenter() was missing inside repositories section.
Thanks.

Application Apk built with Android Studio is larger than one built with Eclipse

Recently I migrated my project to Android Studio. The project references a library project without copying it (See this answer).
I noticed that the apk generated from Android Studio is larger than the one generated from Eclipse (almost twice larger). When I unrar the two apk files I see that in the apk from Android Studio there is one more folder "main" and it contains "res" folder and AndroidManifest.xml.
The problem is that there is "res" folder (/res) in apk's main directory which contains the same resources (/main/res).
I think that the next gradle file causes the problem but without it the project can not be built.
build.gradle for my library module - my_android_project_lib module
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.0.0'
}
}
allprojects {
repositories {
jcenter()
}
}
apply plugin: 'com.android.library'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
minSdkVersion 15
targetSdkVersion 21
}
// I think this duplicates the resources
sourceSets {
main {
manifest.srcFile 'my_android_project_lib/src/main/AndroidManifest.xml'
java.srcDirs = ['my_android_project_lib/src']
resources.srcDirs = ['my_android_project_lib/src']
aidl.srcDirs = ['my_android_project_lib/src']
renderscript.srcDirs = ['my_android_project_lib/src']
res.srcDirs = ['my_android_project_lib/src/main/res', 'slidingMenuLib/src/main/res']
assets.srcDirs = ['my_android_project_lib/src/main/assets']
}
}
}
dependencies {
compile project(':slidingMenuLib')
compile fileTree(dir: 'my_android_project_lib/libs', include: ['*.jar'])
compile fileTree(dir: 'slidingMenuLib/libs', include: ['*.jar'])
compile 'com.google.code.gson:gson:1.7.1'
}
settings.gradle
include ':my_android_app'
include ':my_android_project_lib'
include ':slidingMenuLib'
project(':my_android_project_lib').projectDir = new File(settingsDir, '../my_android_project_lib')
build.gradle for my_android_app module
apply plugin: 'com.android.application'
android {
compileSdkVersion 19
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "my.android.app"
minSdkVersion 15
targetSdkVersion 19
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile project(path: ':my_android_project_lib')
}
build.gradle for my_android_app project
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.0.0'
}
}
allprojects {
repositories {
jcenter()
}
}
Do you know how to fix the problem? I'm missing something important.
I found the problem. When I removed the following line from my build.gradle of my_android_project_lib module, application's size changed back to normal.
resources.srcDirs = ['anyoption_android_v2_lib/src']
The final build.gradle for my_android_project_lib module is:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.0.0'
}
}
allprojects {
repositories {
jcenter()
}
}
apply plugin: 'com.android.library'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
minSdkVersion 15
targetSdkVersion 21
}
// The problem is here.
sourceSets {
main {
manifest.srcFile 'my_android_project_lib/src/main/AndroidManifest.xml'
java.srcDirs = ['my_android_project_lib/src']
res.srcDirs = ['my_android_project_lib/src/main/res']
// Removed
// resources.srcDirs = ['my_android_project_lib/src'] - MAIN PROBLEM
// aidl.srcDirs = ['my_android_project_lib/src']
// renderscript.srcDirs = ['my_android_project_lib/src']
// res.srcDirs = ['my_android_project_lib/src/main/res', 'slidingMenuLib/src/main/res']
// assets.srcDirs = ['my_android_project_lib/src/main/assets']
}
}
}
dependencies {
compile project(':slidingMenuLib')
compile fileTree(dir: 'my_android_project_lib/libs', include: ['*.jar'])
compile fileTree(dir: 'slidingMenuLib/libs', include: ['*.jar'])
compile 'com.google.code.gson:gson:1.7.1'
}
on commenting
resources.srcDirs = ['src']
in build.gradle file, worked for me.
The SourceSets in build.gradle file looks like this,
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')
}

Configuration default not found Android studio - Import from Eclipse

I have been using Eclipse and ADT for building my project. It has been working fine. Recently, I tried migrating my project to Android studio 0.3.7 and I am facing some issues.
My project has a src project, test project, and a library project that successfully get exported from Eclipse.
When I choose the Import Library option, I get the following error.
"Configuration name default not found".
This is my build.gradle for the top level project:
// Top-level build file where you can add configuration options common to all sub-
projects/modules.
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.+'
}
}
And this is my settings.gradle,
include ':tests:MyProjectTest'
include ':mylibrary'
include ':
The only modification I have done after the eclipse export is to change the following file:
./gradle/wrapper/gradle-wrapper.properties
To change
distributionUrl=http\://services.gradle.org/distributions/gradle-1.8-bin.zip
I changed the above line to use 1.8 instead of 1.6.
Any ideas?
You should do like this:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.6.+'
}
}
apply plugin: 'android'
dependencies {
compile files('libs/my_lib_jar.jar')
compile project(':mylibrary')
compile 'com.android.support:support-v4:18.0.+'
}
android {
compileSdkVersion 19
buildToolsVersion '19.0.0'
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
instrumentTest.setRoot('tests')
}
}
By the way, your tests must have path 'project_directory/tests/java/package_name/test'
You should have a structure like this:
Root
- MyProjectTest
build.gradle
src
res
- myLibrary
build.gradle
src
res
settings.gradle
build.gradle
In settings.gradle:
include ':MyProjectTest', ':myLibrary'
In myLibrary/build.gradle:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.6.+'
}
}
apply plugin: 'android-library'
android {
compileSdkVersion 19
buildToolsVersion "19.0.0"
defaultConfig {
minSdkVersion XX
targetSdkVersion 19
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
res.srcDirs = ['res']
}
}
}
In Project/build.gradle:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.6.+'
}
}
apply plugin: 'android'
dependencies {
// Libraries
compile project(':myLibrary')
}
android {
compileSdkVersion 19
buildToolsVersion "19.0.0"
defaultConfig {
minSdkVersion XX
targetSdkVersion 19
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
res.srcDirs = ['res']
}
}
}
In your script you are using:
classpath 'com.android.tools.build:gradle:0.5.+'
Gradle 1.8 require 0.6.3 version.
You can use
classpath 'com.android.tools.build:gradle:0.6.+'

ActionBar Sherlock with Android Studio 0.2.2

I am developing a demo app using ActionBar Sherlock and Android Studio.
Android Studio Version is 0.2.2, gradle version is 1.6 and plugin version is 0.5.1 and i am following these tutorials :-
www.grokkingandroid.com
showlabor.blogspot.ca
i am getting following error :-
Gradle: Execution failed for task ':libraries:ActionBarSherlock:actionbarsherlock:compileReleaseAidl'.tried to access class com.android.build.gradle.internal.tasks.DependencyBasedCompileTask$DepFileProcessor from class com.android.build.gradle.internal.tasks.DependencyBasedCompileTask
actionbarsherlock build.gradle file goes like this :-
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.+'
}
}
apply plugin: 'android-library'
dependencies {
compile 'com.android.support:support-v4:18.0.+'
}
android {
compileSdkVersion 17
buildToolsVersion '17.0.0'
defaultConfig {
minSdkVersion 7
targetSdkVersion 16
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
instrumentTest.setRoot('tests')
}
}
and my project build file goes like this :-
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.+'
}
dependencies {
compile project(':libraries:ActionBarSherlock:actionbarsherlock')
}
android {
compileSdkVersion 17
buildToolsVersion "17.0.0"
defaultConfig {
minSdkVersion 7
targetSdkVersion 16
}
}
any leads on this is highly appreciated
Thanks :)
try
dependencies {
compile 'com.actionbarsherlock:actionbarsherlock:4.4.0#aar'
compile 'com.android.support:support-v4:13.0.+'
}
I had the same error until I used the same gradle file as the one from the sample for ABS and gradle here, that's a working sample project: https://github.com/JakeWharton/ActionBarSherlock-Gradle-Sample

Gradle Error: Android Studio, ActionbarSherlock, and SlidingMenu

I've been at this for a couple of days trying to get the library structure correct within Android Studio. I would have just continued with Eclipse, but performance wise, it's been really bad for me lately. Please, any guidance would be greatly appreciated as all solutions found have not worked and the documentation has lead me nowhere.
All manifests have an empty application tag except for the main TestProject.
Edit* Prior to including SlidingMenu, I did have ActionBarSherlock working without issues and building, etc.
The Error
Gradle: Execution failed for task ':libraries:SlidingMenu:processReleaseManifest'.
> Manifest merging failed. See console for more info.
Build.Gradle (SlidingMenu)
apply plugin: 'android-library'
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.+'
}
}
dependencies {
compile 'com.android.support:support-v4:13.0.+'
compile project(':libraries:actionbarsherlock')
}
android {
compileSdkVersion 17
buildToolsVersion '17.0.0'
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aild.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
}
}
Build.Gradle (ActionBarSherlock)
apply plugin: 'android-library'
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.+'
}
}
dependencies {
compile 'com.android.support:support-v4:13.0.+'
}
android {
compileSdkVersion 17
buildToolsVersion '17.0.0'
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aild.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
}
}
Build.Gradle (Test Project)
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 project(':libraries:actionbarsherlock')
compile project(':libraries:SlidingMenu')
}
android {
compileSdkVersion 17
buildToolsVersion "17.0.0"
defaultConfig {
minSdkVersion 7
targetSdkVersion 16
}
}
settings.gradle (Test Project)
include ':TestProject',':libraries:actionbarsherlock',':libraries:SlidingMenu'
For me the problem was with 'missing <application/> tag' in slidingmenu library.
After adding empty <application/> tag to manifest errors disappeared.
Maybe this will help somebody.
See thread here: https://groups.google.com/forum/#!topic/adt-dev/PIah7eYXiNs
Unfortunately, this could be happening for a lot of reasons. I'd suggest running gradle build -info from the command line to see if it gives you more information.
A common merge failure I've run into is when the minSdkVersions are conflicting. I see that your test project minSdkVersion is 7, are the minimum levels declared in the ActionBarSherlock and SlidingMenu manifests 7 or less?
I already solve it. I share my configuration. Maybe this can help you.
Project:
+ TestProject
|-- libraries
|-- ActionBarSherlock
|-- actionbarsherlock
|-- actionbarsherlock-fest
|-- actionbarsherlock-i18n
|-- actionbarsherlock-samples
|-- SlidingMenu
|-- art
|-- example
|-- library
|-- library-maps-support
|-- TestProject
setting.gradle
include ':TestProject', ':libraries:SlidingMenu:library', ':libraries:ActionBarSherlock:actionbarsherlock'
build.gradle (Test Project)
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.+'
}
}
apply plugin: 'android'
repositories {
mavenCentral()
}
dependencies {
compile project(':libraries:ActionBarSherlock:actionbarsherlock')
compile project(':libraries:SlidingMenu:library')
}
android {
compileSdkVersion 17
buildToolsVersion "17.0.0"
defaultConfig {
minSdkVersion 11
targetSdkVersion 16
}
}
build.gradle (actionbarsherlock lib)
buildscript {
repositories {
maven { url 'http://repo1.maven.org/maven2' }
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.+'
}
}
apply plugin: 'android-library'
dependencies {
compile 'com.android.support:support-v4:13.0.0'
}
android {
compileSdkVersion 17
buildToolsVersion "17.0.0"
defaultConfig {
minSdkVersion 11
targetSdkVersion 16
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
instrumentTest.setRoot('tests')
}
}
build.gradle (slidingmenu lib)
buildscript {
repositories {
maven { url 'http://repo1.maven.org/maven2' }
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.+'
}
}
apply plugin: 'android-library'
dependencies {
compile 'com.android.support:support-v4:13.0.0'
compile project(':libraries:ActionBarSherlock:actionbarsherlock')
}
android {
compileSdkVersion 17
buildToolsVersion "17.0.0"
defaultConfig {
minSdkVersion 11
targetSdkVersion 16
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
instrumentTest.setRoot('tests')
}
}

Categories

Resources