4

Started Android Studio today, and it popped up an update notice. Since I'm eager to explore new features and bug fixes, I clicked yes. Now the Project Structure dialog where you setup dependencies is missing, and has been replaced by a message:

We will provide a UI to configure project settings later. Until then, please manually edit your build.gradle file(s.)

So, I go out to try to figure out how to add ActionBarSherlock to my project as a project dependency, and have hit a brick wall. I have no idea how to import ActionBarSherlock project as a Library Project, and configure my project to use it. There isn't much documentation on this at Google, IntelliJ, and the Gradle docs assume a LOT of pre-existing knowledge of build systems.

regretoverflow
  • 2,093
  • 1
  • 23
  • 45

1 Answers1

4

There are plenty of posts on SO how to do this (although referenced with already missing Project structure dialog)

How do I add a library project to Android Studio?

Android-Studio ActionBar sherlock error with gradle

Installing ActionbarSherlock with Android Studio?

Problems importing project into Android Studio regarding ActionBarSherlock

In short:

  1. Create a folder (i.e. /libraries) in your root.
  2. Extract actionbarsherlock there
  3. Create a new file build.gradle in actionbarsherlock root with the following contents

    buildscript {
        repositories {
            maven { url 'http://repo1.maven.org/maven2' }
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:0.4'
        }
    }
    apply plugin: 'android-library'
    
    dependencies {
        compile files('libs/android-support-v4.jar')
    }
    
    android {
        compileSdkVersion 17
        buildToolsVersion "17.0.0"
    
    
    defaultConfig {
        minSdkVersion 7
        targetSdkVersion 16
    }
    
    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src']
            resources.srcDirs = ['src']
            res.srcDirs = ['res']
        }
    }
    
    }
  4. In your project's build.gradle

    dependencies {
        //NOTE that "libraries" is actually a folder name you created in step 1
        compile project(":libraries:actionbarsherlock")
        //Any other dependencies here
        //Make sure there is no android-support-v4.jar in this build file
        //as it is already contained in actionbarsherlock project
    }
    
  5. In settings.gradle
    //NOTE that "libraries" is actually a folder name you created in step 1
    include ':libraries:actionbarsherlock', ':<Your project name>'
    

EDIT

Last step: Close your project and open it back again for Studio to pick up the Intelli-sense data

Community
  • 1
  • 1
SidhNor
  • 76
  • 3
  • Your first link is invalid - It says to go to the Project Structure UI, which is now missing post-update. Your second link also makes no mention of WHICH gradle files to edit, again assuming I understand how to use gradle. It's just a copy-paste from chapter 55 of the gradle docs. – regretoverflow May 29 '13 at 15:16
  • I made a screencast of your instructions, followed to the letter: http://www.youtube.com/watch?v=UYns7b2Plvw Still can't figure out how to actually USE actionbarsherlock once I have it built. – regretoverflow May 29 '13 at 18:33
  • @NikMartin See update above. You could still use the library and compile/run your app with the steps above. It's just you had to do a project reload for Android Studio to pick up the dependency changes you made in the gradle file. Hope this helps now – SidhNor May 29 '13 at 19:24
  • @NikMartin, although the above links do reference Projects structure UI, they contain information that may help you figure out how to do stuff. – SidhNor May 29 '13 at 19:27
  • Alas I have thrown in the towel. I deleted Android Studio and reinstalled InrelliJ Community Edition with Android Plug-ins. Android Studio just isn't ready for use except for testing IMO. The final straw was closing the project and reopening when Android Studio popped up a dialog telling me it was deleting BOTH my projects because they were un-used. – regretoverflow May 29 '13 at 22:17
  • @NikMartin, without doubt, Android Studio is really raw right now. It's connectivity with the actual build system is still in a poor state. I've moved to completely using CLI to build and run the project and using Studio just for code editing :) – SidhNor May 30 '13 at 07:32