简体   繁体   English

Android Studio上的ActionBarSherlock(库)

[英]ActionBarSherlock (library) on Android Studio

I had the problem like wired00 on Problems importing project into Android Studio regarding ActionBarSherlock 我遇到了关于如何将有关ActionBarSherlock的项目导入Android Studio的问题

I do exactly the solution (Edit2) but when I run I get 我完全解决了问题(Edit2)但是当我跑步时我得到了

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: 更新1:

build.gradle: 的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: 我认为您需要在gradle文件中添加以下依赖项:

compile project(':StoKit:actionbarsherlock') 编译项目(':StoKit:actionbarsherlock')

(within the dependency section) (在依赖部分内)

EDIT 25/05/2013 编辑25/05/2013

Ok, so this is my project structure which is currently compiling fine in android studio and via gradle command line: 好的,所以这是我的项目结构,目前在android studio和gradle命令行编译正常:

项目结构

EDIT 31/05/2013 编辑31/05/2013

Ok, so my build.gradle file within DecisionBuddy-DecisionBuddy module is: 好的,所以我在DecisionBuddy-DecisionBuddy模块中的build.gradle文件是:

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: actionbarsherlock模块中的那个是:

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. 到slidingMunu库项目的build.gradle的依赖项。

here is my build.gradle 这是我的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']
      }
      }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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