【问题标题】:Cannot add dependency in android studio无法在 android studio 中添加依赖
【发布时间】:2015-02-08 10:20:12
【问题描述】:

我从 Eclipse 导出我的项目以生成 gradle 构建文件,然后作为非 android 项目导入到 android studio。我在 gradle 文件中添加了 actionbarsherlock 依赖项并进行了同步,它总是显示

错误:找不到: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

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

【问题讨论】:

标签: android eclipse android-studio gradle


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-08-26
    • 1970-01-01
    • 1970-01-01
    • 2018-11-21
    • 2015-03-13
    • 2015-07-22
    • 1970-01-01
    • 2019-08-09
    相关资源
    最近更新 更多