1

I had the problem like wired00 on Problems importing project into Android Studio regarding ActionBarSherlock

I do exactly the solution (Edit2) but when I run I get

Gradle: package com.actionbarsherlock.app does not exist

Strange thing is that on code I don't get any error, just on compiling.

Update 1:

build.gradle:

buildscript {
    repositories {
        maven { url 'http://repo1.maven.org/maven2' }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.4'
    }
}
apply plugin: 'android'

dependencies {
    compile files('libs/android-support-v4.jar')
}

android {
    compileSdkVersion 17
    buildToolsVersion "17.0.0"

    defaultConfig {
        minSdkVersion 7
        targetSdkVersion 16
    }
}

MainActivity:

import android.os.Bundle;
import com.actionbarsherlock.app.SherlockActivity;

public class MainActivity extends SherlockActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }

Module Settings:

Module Settings of Main Project

Structure:

Structure Project

Error:

Compiling error

Community
  • 1
  • 1
ricardopereira
  • 11,118
  • 5
  • 63
  • 81
  • Just like http://stackoverflow.com/questions/16593391/android-studio-and-using-external-library-projects. I'm on OSX – ricardopereira May 28 '13 at 08:03
  • Another one http://stackoverflow.com/questions/16768020/android-studio-adding-actionbarsherlock – ricardopereira May 28 '13 at 08:13
  • If you could post a screen shot of your project structure and maybe your main project build.gradle file I might be able to help. Having some problems myself but have gotten through this part. – Matt Whetton May 28 '13 at 11:16

2 Answers2

2

I think you need to add the following dependency in you gradle file:

compile project(':StoKit:actionbarsherlock')

(within the dependency section)

EDIT 25/05/2013

Ok, so this is my project structure which is currently compiling fine in android studio and via gradle command line:

Project Structure

EDIT 31/05/2013

Ok, so my build.gradle file within DecisionBuddy-DecisionBuddy module is:

buildscript {
    repositories {
        maven { url 'http://repo1.maven.org/maven2' }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.4'
    }
}
apply plugin: 'android'

repositories{
    mavenCentral()
}

dependencies {
    compile project(':libraries:actionbarsherlock')
    compile files('libs/GoogleAdMobAdsSdk-6.3.1.jar')
    compile files('libs/libGoogleAnalyticsV2.jar')
    compile files('libs/mobileservices-0.2.0.jar')
}

android {
    compileSdkVersion 17
    buildToolsVersion "17.0.0"

    defaultConfig {
        minSdkVersion 7
        targetSdkVersion 16
    }
}

And the one in the actionbarsherlock module is:

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('../../DecisionBuddy/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']
        }
    }
}

Does this help?

Also make sure you updated to the latest version of the tools - I was having some issues until I did that.

Matt Whetton
  • 6,616
  • 5
  • 36
  • 57
  • Gradle: FAILURE: Build failed with an exception. * Where: Build file '/Users/Development/Android/Source/Stokit/Stokit/build.gradle' line: 13 * What went wrong: A problem occurred evaluating project ':Stokit'. > Project with path ':Stokit:actionbarsherlock' could not be found in project ':Stokit'. – ricardopereira May 28 '13 at 13:55
  • actionbarsherlock need to be on Stokit folder? Can you share a project working with actionbarsherlock on Android Studio, please? – ricardopereira May 28 '13 at 13:57
  • Yes thats right, the actionbarsherlock module needs to be within the project (in your case the stokit project). I don't have a project to show with me at the minute, but I can put one up later. – Matt Whetton May 28 '13 at 14:10
  • I moved it to Stokit folder and try it but still the same gradle error. Then I change to `compile project('actionbarsherlock')`. Close Android Studio and do it again and always the same. Please share a simple project when possible, if you don't mind. Thanks for your help – ricardopereira May 28 '13 at 14:33
  • Added the builg.gradle files to the example provided – Matt Whetton May 31 '13 at 07:31
1

I had the same problem and solve it by adding

compile 'com.actionbarsherlock:actionbarsherlock:4.4.0@aar'

to the dependencies of the build.gradle of the slidingMunu library project.

here is my build.gradle

apply plugin: 'android-library'

dependencies {
    compile 'com.android.support:support-v4:18.0.+'
    compile 'com.actionbarsherlock:actionbarsherlock:4.4.0@aar'
}

android {
    compileSdkVersion 16
    buildToolsVersion '20.0.0'

    defaultConfig {
        minSdkVersion 16
        targetSdkVersion 21
    }

    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src']
            res.srcDirs = ['res']
      }
      }
}
smoothumut
  • 3,423
  • 1
  • 25
  • 35