无法在android studio中添加依赖项

时间:2015-02-08 10:20:12

标签: android eclipse android-studio gradle

我将项目从eclipse导出到genereate gradle构建文件,然后作为非android项目导入到android studio。我将actionbarsherlock依赖项添加到gradle文件并进行同步,它始终显示

错误:无法找到:com.actionbarsherlock:actionbarsherlock:4.4.0

的build.gradle

buildscript {
        repositories {
            mavenCentral()
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:1.0.0'
        }
    }


    apply plugin: 'com.android.application'

    dependencies {
        compile fileTree(dir: 'libs', include: '*.jar')
        compile 'com.android.support:support-v4:21.0.3'
        compile 'com.actionbarsherlock:actionbarsherlock:4.4.0@aar'
    }

    android {
        compileSdkVersion 21
        buildToolsVersion "21.1.2"

        compileOptions {
            sourceCompatibility JavaVersion.VERSION_1_7
            targetCompatibility JavaVersion.VERSION_1_7
        }

        sourceSets {
            main {
                manifest.srcFile 'AndroidManifest.xml'
                java.srcDirs = ['src']
                resources.srcDirs = ['src']
                aidl.srcDirs = ['src']
                renderscript.srcDirs = ['src']
                res.srcDirs = ['res']
                assets.srcDirs = ['assets']
            }

            // Move the tests to tests/java, tests/res, etc...
            instrumentTest.setRoot('tests')

            // Move the build types to build-types/<type>
            // For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
            // This moves them out of them default location under src/<type>/... which would
            // conflict with src/ being used by the main source set.
            // Adding new build types or product flavors should be accompanied
            // by a similar customization.
            debug.setRoot('build-types/debug')
            release.setRoot('build-types/release')
        }
    }

如果我运行该项目,我会收到此错误

错误日志

> Could not find com.actionbarsherlock:actionbarsherlock:4.4.0.
 Searched in the following locations:
     file:/Applications/ADT Bundle/sdk/extras/android/m2repository/com/actionbarsherlock/actionbarsherlock/4.4.0/actionbarsherlock-4.4.0.pom
     file:/Applications/ADT Bundle/sdk/extras/android/m2repository/com/actionbarsherlock/actionbarsherlock/4.4.0/actionbarsherlock-4.4.0.aar
     file:/Applications/ADT Bundle/sdk/extras/google/m2repository/com/actionbarsherlock/actionbarsherlock/4.4.0/actionbarsherlock-4.4.0.pom
     file:/Applications/ADT Bundle/sdk/extras/google/m2repository/com/actionbarsherlock/actionbarsherlock/4.4.0/actionbarsherlock-4.4.0.aar

我找不到任何可以帮助我解决这个问题的解决方案......

1 个答案:

答案 0 :(得分:0)

您是否在Android Studio中再次尝试导入ABS?我不确定您之前的eclipse项目导入是否会在Android Studio中生效。 您可以尝试File-&gt; Project Structure,然后点击添加按钮再次添加ABS。