1

I have seen all the posts pointing to various guides purporting to get ABS working with IntelliJ (Android Studio), including here, and here.

For the most recent version of ABS and AS, they don't work.

Generally, the tutorial doesn't match the IDE. Getting past that, and assuming that doing an 'import module' using gradle instead of maven is allowed, I eventually get:

Plugin with id 'android-library' not found

Does anyone have a tutorial for getting the latest version of ABS working with the latest version of AS?

Fwiw, I tried going the Eclipse route with the intention of exporting and then trying to bring it into AS (this is definitely not my preferred path), but I ended-up getting a bunch of "Unable to execute dex: Multiple dex files define..." errors surrounding Jackson.

If it's useful, here is my build.gradle, but my preferred solution would use more "standard" mechanisms than mucking with that and would also, then, more likely be useful to others. Here's the file:

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.5.+'
    }
}
apply plugin: 'android'

dependencies {
    compile fileTree(dir: 'libs', include: '*.jar')
}

android {
    compileSdkVersion 17
    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']
        }

        instrumentTest.setRoot('tests')
    }
}

And, my project directory structure:

D:.
└───T-n-T
    ├───.gradle
    │   └───1.6
    │       └───taskArtifacts
    ├───.idea
    │   ├───copyright
    │   ├───libraries
    │   └───scopes
    ├───assets
    ├───bin
    │   ├───classes
    │   │   └───com
    │   │       └───pha
    │   │           └───t-n-t
    │   │               ├───models
    │   │               └───services
    │   └───res
    ├───build
    │   ├───apk
    │   ├───assets
    │   │   └───debug
    │   ├───classes
    │   │   └───debug
    │   │       └───com
    │   │           └───pha
    │   │               └───t-n-t
    │   │                   ├───models
    │   │                   └───services
    │   ├───dependency-cache
    │   │   └───debug
    │   ├───incremental
    │   │   ├───aidl
    │   │   │   └───debug
    │   │   ├───dex
    │   │   │   └───debug
    │   │   ├───mergeAssets
    │   │   │   └───debug
    │   │   └───mergeResources
    │   │       └───debug
    │   ├───libs
    │   ├───manifests
    │   │   └───debug
    │   ├───res
    │   │   ├───all
    │   │   │   └───debug
    │   │   │       ├───drawable-hdpi
    │   │   │       ├───drawable-mdpi
    │   │   │       ├───drawable-xhdpi
    │   │   │       ├───drawable-xxhdpi
    │   │   │       ├───layout
    │   │   │       ├───menu
    │   │   │       ├───values
    │   │   │       ├───values-sw720dp-land
    │   │   │       ├───values-v11
    │   │   │       ├───values-v14
    │   │   │       └───xml
    │   │   └───rs
    │   │       └───debug
    │   ├───source
    │   │   ├───aidl
    │   │   │   └───debug
    │   │   ├───buildConfig
    │   │   │   └───debug
    │   │   │       └───com
    │   │   │           └───pha
    │   │   │               └───t-n-t
    │   │   ├───r
    │   │   │   └───debug
    │   │   │       └───com
    │   │   │           └───pha
    │   │   │               └───t-n-t
    │   │   └───rs
    │   │       └───debug
    │   └───symbols
    │       └───debug
    ├───gen
    │   └───com
    │       └───pha
    │           └───t-n-t
    ├───gradle
    │   └───wrapper
    ├───libs
    ├───res
    │   ├───drawable-hdpi
    │   ├───drawable-ldpi
    │   ├───drawable-mdpi
    │   ├───drawable-xhdpi
    │   ├───drawable-xxhdpi
    │   ├───layout
    │   ├───menu
    │   ├───values
    │   ├───values-sw600dp
    │   ├───values-sw720dp-land
    │   ├───values-v11
    │   ├───values-v14
    │   └───xml
    └───src
        └───com
            └───pha
                └───t-n-t
                    ├───models
                    └───services

It should be noted that this represents the project after having rolled it back after a failed attempt to get this working.

UPDATE

I don't know if it's progress, but it's different. I have what I think is the library project from ABS sitting with my main project, and added as a module. I think this is the case because in the IDE, in the main project, SherlockActivity seems to be available. I can extend it (sort of) and can import it's namespace (com.actionbarsherlock.app). I say sort of because everything is fine until I try to build, at which point I get:

Gradle: package com.actionbarsherlock.app does not exist
Gradle: cannot find symbol class SherlockActivity

and the build fails. So something is clearly not quite right.

Any suggestions?

SOLVED Wow. What a pain. What I ultimately ended-up doing:
As described by others
1) Download and extract ABS
2) Save it in its own folder under your primary project (say ActionBarSherlock)
3) Import it as a Module (new: use Maven / pom.xml - make sure Export is checked) Pulled from other sources
4) Exclude the ActionBarSherlock/target directory (Open Module Settings)
5) If your primary project uses the support library, change that dependency to Provided (Open Module Settings)

Again, I'm not sure why this was so difficult, or if I've done it correctly, or that there aren't any issues yet to be found (I have an empty Activity which extends SherlockActivity, it does build, and I can deploy it to, and run it on, an emulator), but there you go.

Community
  • 1
  • 1
Michael
  • 4,010
  • 4
  • 28
  • 49
  • Like you, I exported my project from Eclipse (with ABS), but that was not really working :-( So I managed to customize myself the build files (ActionBarSherlock build.gradle file + my app build.gradle file). If you can post your build+settings.gradle file, perhaps I can help you. Another solution might be to get the latest ABS version from GitHub which support Gradle :-) (but i have not tried that) – Rémi F Aug 06 '13 at 21:02
  • I don't see a settings.gradle. I've posted my build.gradle. – Michael Aug 07 '13 at 08:28
  • compile fileTree is used for building dependencies. This is a way to say to gradle : "build whatever is in those folders". This is a bit rude :) For me, you should have a build.gradle file for each library or module (1 for ABS and 1 for your app). The setting.gradle file tells gradle which project he must build (http://www.gradle.org/docs/current/userguide/multi_project_builds.html) – Rémi F Aug 07 '13 at 09:05
  • This project itself was originally imported from Eclipse. I don't know what went into creating that build.gradle. Can you post a suggested change? Also, where *should* this settings.gradle be, and what should be in it? All that aside - is there really no boilerplate way to get this working? – Michael Aug 07 '13 at 10:20
  • ok. could you please share your project's folder structure (with position of gradle and manifest files)? – Rémi F Aug 07 '13 at 12:37
  • Project dir structure posted. It should be noted that this represents the project after having rolled it back after a failed attempt to get this working. – Michael Aug 07 '13 at 15:34

2 Answers2

0

For me the following works fine :

Copy the actionbarsherlock directory to your project root to have

MyAppProject
|-actionbarsherlock
|--build.gradle
|-MyApp
|--build.gradle
|-build.gradle
|-settings.gradle

build.gradle of actionbarsherlock

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'

    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src']
            resources.srcDirs = ['src']
            res.srcDirs = ['res']
        }
    }
}

build.gradle of MyApp

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.5.+'
    }
}
apply plugin: 'android'

repositories {
    mavenCentral()
}

dependencies {
    compile 'com.android.support:support-v4:18.0.+'
    compile project(':actionbarsherlock')
}

android {
    compileSdkVersion 17
    buildToolsVersion "17.0.0"

    defaultConfig {
        minSdkVersion 10
        targetSdkVersion 17
    }
}

settings.gradle

include ':MyApp', ':actionbarsherlock'

and nothing in the MyAppProject build.gradle

Next Right clik on your MyAppProject > Open Module settings And on the module section import module and select actionbarsherlock directory. Apply and to verify re open modul settings, go Modules, click on YourApp and verify if on the dependencies you have actionbarsherlocj on scope compile. if yes, you are ready .

agonist_
  • 4,890
  • 6
  • 32
  • 55
  • When trying to Import Module, I get: Could not find any version that matches com.android.support:support-v4:18.0.+. Required by: :actionbarsherlock:unspecified. Of course, I do have a version of that installed and being used in the project (In my libs dir - I don't know if the version is 18, but I do have that downloaded). All the same, this tweaking about seems more complex than it ought to be. – Michael Aug 08 '13 at 00:36
  • answer of @agonist_ seems ok (I have done pretty the same in my project). To fix the error, you should update your SDK and add or update some extras : Android Support Repository & Android Support Library – Rémi F Aug 08 '13 at 06:48
  • Yes check on your SDK manager if you have all the latest version of extras installed – agonist_ Aug 08 '13 at 07:07
  • How do I check which version that jar actually is (the SDK manager has it as 18, but that may not be the same as the one in the project)? – Michael Aug 08 '13 at 17:46
0

From my update to the question, above:

What I ultimately ended-up doing:

As described by others

1) Download and extract ABS
2) Save it in its own folder under your primary project (say, ActionBarSherlock)
3) Import it as a Module (new: use Maven / pom.xml - make sure Export is checked)

Pulled from other sources

4) Exclude the ActionBarSherlock/target directory (Open Module Settings)
5) If your primary project uses the support library, change that dependency to Provided (Open Module Settings)

Again, I'm not sure why this was so difficult, or if I've done it correctly, or that there aren't any issues yet to be found (I have an empty Activity which extends SherlockActivity, it does build, and I can deploy it to, and run it on, an emulator), but there you go.

UPDATE
This configuration ended up not working. How or why it fell apart, I don't know. But after restarting AS, it fell apart. Following the steps here - again - did, this time, get it working.

Community
  • 1
  • 1
Michael
  • 4,010
  • 4
  • 28
  • 49