我无法在android studio中通过gradle导入libs

时间:2014-04-25 15:44:00

标签: android gradle android-studio android-support-library

我正在尝试使用gradle导入库。这是我的build.gradle文件:

apply plugin: 'android'

dependencies {
    compile 'com.google.code.gson:gson:2.2.+'
    compile 'com.android.support:support-v4:19.1.0'
    compile 'com.android.support:appcompat-v7:19.1.0'
    compile 'com.squareup.okhttp:okhttp:1.3.0'
    compile 'com.squareup.retrofit:retrofit:1.4.1'
    compile 'net.hockeyapp.android:HockeySDK:3.0.1'

    compile files('libs/activeandroid-3.1-SNAPSHOT.jar')
}

android {
    compileSdkVersion 19
    buildToolsVersion "19.0.3"

    defaultConfig {
        minSdkVersion 14
        targetSdkVersion 19
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            runProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
    // TODO: Fix the warnings and removed this section!
    lintOptions {
        abortOnError false
    }
}

我收到这样的错误:

    I/dalvikvm﹕ Failed resolving Landroid/support/v4/media/TransportMediatorJellybeanMR2$1; interface 964 'Landroid/view/ViewTreeObserver$OnWindowAttachListener;'
    W/dalvikvm﹕ Link of class 'Landroid/support/v4/media/TransportMediatorJellybeanMR2$1;' failed
    W/dalvikvm﹕ Unable to resolve superclass of Landroid/support/v4/print/PrintHelperKitkat$1; (155)
    W/dalvikvm﹕ Link of class 'Landroid/support/v4/print/PrintHelperKitkat$1;' failed
    I/dalvikvm﹕ Failed resolving Lretrofit/RestAdapter$RxSupport$1; interface 1942 'Lrx/Observable$OnSubscribeFunc;'
    W/dalvikvm﹕ Link of class 'Lretrofit/RestAdapter$RxSupport$1;' failed

我已经运行了gradlew clean和build命令。但它没有帮助。你知道出了什么问题吗?

有我的gradlew构建命令日志:

Relying on packaging to define the extension of the main artifact has been deprecated and is scheduled to be removed in Gradle 2.0
:app:compileDebugNdk
:app:preBuild
:app:preDebugBuild
:app:checkDebugManifest
:app:preReleaseBuild
:app:prepareComAndroidSupportAppcompatV71910Library
:app:prepareDebugDependencies
:app:compileDebugAidl
:app:compileDebugRenderscript
:app:generateDebugBuildConfig
:app:mergeDebugAssets
:app:generateDebugResValues UP-TO-DATE
:app:generateDebugResources
:app:mergeDebugResources
:app:processDebugManifest
:app:processDebugResources
:app:generateDebugSources
:app:compileDebugJava
:app:preDexDebug
:app:dexDebug
:app:processDebugJavaRes UP-TO-DATE
:app:validateDebugSigning
:app:packageDebug
:app:assembleDebug
:app:checkReleaseManifest
:app:prepareReleaseDependencies
:app:compileReleaseAidl
:app:compileReleaseRenderscript
:app:generateReleaseBuildConfig
:app:mergeReleaseAssets
:app:generateReleaseResValues UP-TO-DATE
:app:generateReleaseResources
:app:mergeReleaseResources
:app:processReleaseManifest
:app:processReleaseResources
:app:generateReleaseSources
:app:compileReleaseJava
:app:lintVitalRelease SKIPPED
:app:compileReleaseNdk
:app:preDexRelease
:app:dexRelease
:app:processReleaseJavaRes UP-TO-DATE
:app:packageRelease
:app:assembleRelease
:app:assemble
:app:compileLint
:app:lint
Ran lint on variant release: 25 issues found
Ran lint on variant debug: 25 issues found
Wrote HTML report to file:.../lint-results.html
Wrote XML report to .../lint-results.xml
:app:check
:app:build

BUILD SUCCESSFUL

这是项目目录中的gradle.build文件:

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

allprojects {
    repositories {
        mavenCentral()
    }
}

1 个答案:

答案 0 :(得分:0)

也许support-v4依赖项不匹配? 尝试将其添加到build.gradle:

configurations {
    all*.exclude group: 'com.google.android', module: 'support-v4'
}

dependencies {
....