如何解决AndroidStudio中的依赖问题?

时间:2017-10-15 09:28:05

标签: android

我只是从我的本地仓库克隆一个android项目,我很难“构建”它。也许它错过了一些外部库,但我不知道。

在开始成绩构建后,我收到以下消息:

Error:A problem occurred configuring project ':app'.
> Could not resolve all dependencies for configuration ':app:_debugApk'.
   > Configuration with name 'default' not found.

我试图检查'Manifest'文件,但我找不到它。我完全迷失了......

我很确定这是一个配置错误,因此我可以在这里找到所有的配置文件:

build.gradle (project)

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.2.3'
        classpath 'com.google.gms:google-services:3.0.0'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
    }
}


task clean(type: Delete) {
    delete rootProject.buildDir
}

build.gradle (app)

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.1"

    defaultConfig {
        applicationId "com.impyiablue.myapp"
        minSdkVersion 16
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    dexOptions {
        preDexLibraries = false
    }
}

repositories {
    mavenCentral()
}
dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.4.0'
    compile 'com.android.support:design:23.1.0'
    compile 'com.mcxiaoke.volley:library:1.0.19'
    compile 'com.google.firebase:firebase-ads:9.0.0'
    compile 'in.srain.cube:grid-view-with-header-footer:1.0.12'
    compile 'com.github.paolorotolo:appintro:4.1.0'
    compile project(path: ':LibraryModule')
}

apply plugin: 'com.google.gms.google-services'

cradle-wrapper.properties

#Wed Sep 07 20:03:05 CEST 2016
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip

settings.gradle:

include ':app'
include ':libraries:volley'
include ':LibraryModule'
project(':LibraryModule').projectDir = new File('/Users/adietz/AndroidStudioProjects/LIBS')

local.properties:

## This file is automatically generated by Android Studio.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must *NOT* be checked into Version Control Systems,
# as it contains information specific to your local configuration.
#
# Location of the SDK. This is only used by Gradle.
# For customization when using a Version Control System, please read the
# header note.
#Sun Oct 15 11:07:25 CEST 2017
sdk.dir=/Users/adietz/Library/Android/sdk

./gradlew build的输出(来自项目文件夹内部)如下:

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.gradle.internal.reflect.JavaMethod (file:/Users/adietz/.gradle/wrapper/dists/gradle-2.14.1-all/4cj8p00t3e5ni9e8iofg8ghvk7/gradle-2.14.1/lib/gradle-base-services-2.14.1.jar) to method java.lang.ClassLoader.getPackages()
WARNING: Please consider reporting this to the maintainers of org.gradle.internal.reflect.JavaMethod
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':app'.
> Failed to notify project evaluation listener.
   > javax/xml/bind/annotation/XmlSchema

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 7.217 secs

1 个答案:

答案 0 :(得分:0)

解决方案的一部分似乎是文件build.gradle的更改(对于Module:app)。如果你替换这一行

compile project(path: ':LibraryModule')

这一行:

compile project(':libraries:volley')

再做'清理项目',可能会发生不同的事情:

  • AndroidStudio开始下载内容
  • 其他gradle文件在您的Gradle Scripts文件夹
  • 中显得神秘
  • 出现其他错误(您可以谷歌并实际找到一些有用的答案)

但它可能会解决实际问题......

相关问题