简体   繁体   English

我无法在Android Studio中通过Gradle导入库

[英]I can't import libs by gradle in android studio

I am trying to import libraries using gradle. 我正在尝试使用gradle导入库。 This is my build.gradle file: 这是我的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 get errors like these: 我收到如下错误:

    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

I have run gradlew clean and build command. 我已经运行gradlew clean和build命令。 But it doesn't help. 但这没有帮助。 Do you have any idea what is wrong ? 你有什么主意吗?

There are my logs for gradlew build command: 我的gradlew build命令日志:

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

This is my gradle.build file from project directory: 这是我来自项目目录的gradle.build文件:

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

allprojects {
    repositories {
        mavenCentral()
    }
}

Maybe support-v4 dependencies mismatch ? 也许support-v4依赖项不匹配? Try to add this into build.gradle: 尝试将其添加到build.gradle中:

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

dependencies {
.... 

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

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