简体   繁体   English

在android studio 0.4.2中设置actionbar sherlock

[英]setup actionbar sherlock in android studio 0.4.2

I am developing an android project by using actionbrsherlock library. 我正在使用actionbrsherlock库开发一个android项目。 after adding the actionbarsherlock library in android studio , my directory structure is 在android studio中添加actionbarsherlock库后,我的目录结构是

MYAPPLICATION 我的应用程序
- app - 应用程序
- gradle - gradle
- libraries - 图书馆
- actionbarsherlock (library project) - actionbarsherlock(图书馆项目)
build.gradle 的build.gradle
setting.gradle setting.gradle

build.gradle 的build.gradle

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.7.+'
        compile project(":libraries:actionbarsherlock")
        }
}

allprojects {
    repositories {
        mavenCentral()
    }
}

setting.build setting.build

include ':app' 包括':app'
include ':libraries:actionbarsherlock' include':libraries:actionbarsherlock'

after running following error occured, 运行后发生以下错误,

A problem occurred evaluating root project 'MyApplication'. 评估根项目“MyApplication”时出现问题。 > No signature of method: org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.compile() is applicable for argument types: (org.gradle.api.internal.project.DefaultProject_Decorated) values: [project ':libraries:actionbarsherlock'] Possible solutions: module(java.lang.Object) >没有方法签名:org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.compile()适用于参数类型:(org.gradle.api.internal.project.DefaultProject_Decorated)值:[project': libraries:actionbarsherlock']可能的解决方案:module(java.lang.Object)

UPDATE: 更新:

I upgraded my android studio to 0.4.4. 我将我的android工作室升级到0.4.4。 and change the build.gradle file. 并更改build.gradle文件。 one can find the whole setup on github https://github.com/manishpathak99/AndroidStudio . 你可以在github上找到整个设置https://github.com/manishpathak99/AndroidStudio

First I will strongly recommend you to upgrade your studio to version 0.4.3 because there were some dependencies related issues in 0.4.2 release . 首先,我强烈建议您将工作室升级到版本0.4.3,因为0.4.2版本中存在一些与依赖项相关的问题。

Answer : 答案:

You are adding module dependencies at wrong place in build.gradle file . 您正在build.gradle文件中的错误位置添加模块依赖项。 Your module's build.gradle file should look like this : 您的模块的build.gradle文件应如下所示:

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.7.+'
    }
}
apply plugin: 'android'

repositories {
    mavenCentral()
}

android {
    compileSdkVersion 19
    buildToolsVersion "19.0.0"

    defaultConfig {
        minSdkVersion 10
        targetSdkVersion 19
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            runProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }

        debug {
            runProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
}

dependencies {
    // Your all module dependencies should be defined here
    compile project(":libraries:actionbarsherlock")

}

Recommended Solution : 推荐方案:

ActionbarSherlock library has its maven dependency, In such cases no need to download the whole library and add it as as module in your project, instead add the maven gradle dependency in your module's build.gradle file like ActionbarSherlock库具有maven依赖性,在这种情况下,无需下载整个库并将其作为模块添加到项目中,而是在模块的build.gradle文件中添加maven gradle依赖项,如

dependencies {
       compile 'com.actionbarsherlock:actionbarsherlock-i18n:4.4.0@aar'
}

That's it. 而已。

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

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