简体   繁体   中英

ActionBarSherlock (library) on Android Studio

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:

主项目的模块设置

Structure:

结构项目

Error:

编译错误

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:

项目结构

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.

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']
      }
      }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM