Search code examples
actionbarsherlockandroid-studio

ActionBarSherlock / IntelliJ (Android Studio) - Newest Versions


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.


Solution

  • 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.