【问题标题】:Android 3.0.1 Error:Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve project :app2Android 3.0.1 错误:无法解析“:app@debug/compileClasspath”的依赖项:无法解析项目:app2
【发布时间】:2018-02-18 14:15:02
【问题描述】:

我将项目“forecastie-master-master”从 GitHub 导入到我自己的项目中。我按照导入项目的步骤进行操作。请帮我解决这个错误,我是导入项目的新手。

我自己项目的gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    defaultConfig {
        applicationId "com.example.bumbleshet.tourpinas3"
        minSdkVersion 21
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }

    }
    productFlavors {
    }
    buildToolsVersion '26.0.2'
}

dependencies {

    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.android.support:cardview-v7:26.1.0'
    // implementation 'com.android.support:design:26.0.0'
    //implementation 'com.android.support:design:26.0.0'
    //imlementation 'com.android.support:support-v4:26.0.0'
    implementation 'com.android.support:design:26.1.0'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    //implementatoin 'com.android.support.constraint:constraint-layout:1.0.2'
    // implementation 'com.google.android.gms.play-servies:11.8.0'
    implementation 'com.lapism:searchview:4.0'
    implementation 'com.google.firebase:firebase-core:11.8.0'
    implementation 'com.google.firebase:firebase-database:11.8.0'
    implementation 'com.google.firebase:firebase-auth:11.8.0'
    implementation 'com.google.android.gms:play-services-maps:11.8.0'
    implementation 'com.google.android.gms:play-services-location:11.8.0'
    implementation 'com.google.android.gms:play-services-places:11.8.0'

    //implementation project (':app2')//{
       // exclude group: 'com.android.support', module:'library'
    //}
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
    implementation project(':app2')
}
apply plugin: 'com.google.gms.google-services'



my imported project's gradle:
apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    defaultConfig {
        applicationId "cz.martykan.forecastie"
        minSdkVersion 21
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }

    lintOptions {
        checkReleaseBuilds true
        abortOnError false
        xmlReport true
        htmlReport true
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }

    }
    productFlavors {
    }
    buildToolsVersion '26.0.2'
}


dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    implementation 'com.google.android.apps.dashclock:dashclock-api:+'
    implementation 'com.roughike:bottom-bar:1.4.0.1'
    implementation 'com.diogobernardino:williamchart:2.2'
}

settings.gradle:

include ':app2',':app'

错误:

Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve project :app2. <a href="openFile:C:../build.gradle">Open File</a><br><a href="Unable to resolve dependency for ":app@debug/compileClasspath": Could not resolve project :app2.">

Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve project :app2. <a href="openFile:C:../build.gradle">Open File</a><br><a href="Unable to resolve dependency for ":app@debug/compileClasspath": Could not resolve project :app2.">

Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve project :app2. <a href="openFile:C:../build.gradle">Open File</a><br><a href="Unable to resolve dependency for ":app@debug/compileClasspath": Could not resolve project :app2.">

Unable to resolve dependency for ':app@release/compileClasspath': Could not resolve project :app2. <a href="openFile:C:../build.gradle">Open File</a><br><a href="Unable to resolve dependency for ":app@debug/compileClasspath": Could not resolve project :app2.">

Unable to resolve dependency for ':app@releaseUnitTest/compileClasspath': Could not resolve project :app2. <a href="openFile:C:../build.gradle">Open File</a><br><a href="Unable to resolve dependency for ":app@debug/compileClasspath": Could not resolve project :app2.">

详情:

Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve project :app2. Could not resolve project :app2.

要求:项目:app

找不到项目的匹配配置:app2: - 配置'debugApiElements': - 需要 com.android.build.api.attributes.BuildTypeAttr 'debug' 并找到兼容值 'debug'。 - 需要 com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' 并发现不兼容的值 'Apk'。 - 找到 com.android.build.gradle.internal.dependency.VariantAttr 'debug' 但不是必需的。 - 需要 org.gradle.api.attributes.Usage 'java-api' 并找到兼容值 'java-api'。 - 配置“调试元数据元素”: - 需要 com.android.build.api.attributes.BuildTypeAttr 'debug' 并找到兼容值 'debug'。 - 需要 com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' 并发现不兼容的值 'Metadata'。 - 找到 com.android.build.gradle.internal.dependency.VariantAttr 'debug' 但不是必需的。 - 需要 org.gradle.api.attributes.Usage 'java-api' 但未提供值。 - 配置“调试运行时间元素”: - 需要 com.android.build.api.attributes.BuildTypeAttr 'debug' 并找到兼容值 'debug'。 - 需要 com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' 并发现不兼容的值 'Apk'。 - 找到 com.android.build.gradle.internal.dependency.VariantAttr 'debug' 但不是必需的。 - 需要 org.gradle.api.attributes.Usage 'java-api' 并发现不兼容的值 'java-runtime'。 - 配置“profileApiElements”: - 需要 com.android.build.api.attributes.BuildTypeAttr 'debug' 并发现不兼容的值 'profile'。 - 需要 com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' 并发现不兼容的值 'Apk'。 - 找到 com.android.build.gradle.internal.dependency.VariantAttr 'profile' 但不是必需的。 - 需要 org.gradle.api.attributes.Usage 'java-api' 并找到兼容值 'java-api'。 - 配置“profileMetadataElements”: - 需要 com.android.build.api.attributes.BuildTypeAttr 'debug' 并发现不兼容的值 'profile'。 - 需要 com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' 并发现不兼容的值 'Metadata'。 - 找到 com.android.build.gradle.internal.dependency.VariantAttr 'profile' 但不是必需的。 - 需要 org.gradle.api.attributes.Usage 'java-api' 但未提供值。 - 配置“profileRuntimeElements”: - 需要 com.android.build.api.attributes.BuildTypeAttr 'debug' 并发现不兼容的值 'profile'。 - 需要 com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' 并发现不兼容的值 'Apk'。 - 找到 com.android.build.gradle.internal.dependency.VariantAttr 'profile' 但不是必需的。 - 需要 org.gradle.api.attributes.Usage 'java-api' 并发现不兼容的值 'java-runtime'。 - 配置“releaseApiElements”: - 需要 com.android.build.api.attributes.BuildTypeAttr 'debug' 并发现不兼容的值 'release'。 - 需要 com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' 并发现不兼容的值 'Apk'。 - 找到 com.android.build.gradle.internal.dependency.VariantAttr 'release' 但不是必需的。 - 需要 org.gradle.api.attributes.Usage 'java-api' 并找到兼容值 'java-api'。 - 配置“releaseMetadataElements”: - 需要 com.android.build.api.attributes.BuildTypeAttr 'debug' 并发现不兼容的值 'release'。 - 需要 com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' 并发现不兼容的值 'Metadata'。 - 找到 com.android.build.gradle.internal.dependency.VariantAttr 'release' 但不是必需的。 - 需要 org.gradle.api.attributes.Usage 'java-api' 但未提供值。 - 配置“releaseRuntimeElements”: - 需要 com.android.build.api.attributes.BuildTypeAttr 'debug' 并发现不兼容的值 'release'。 - 需要 com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' 并发现不兼容的值 'Apk'。 - 找到 com.android.build.gradle.internal.dependency.VariantAttr 'release' 但不是必需的。 - 需要 org.gradle.api.attributes.Usage 'java-api' 并发现不兼容的值 'java-runtime'。

【问题讨论】:

    标签: android gradle import migrate


    【解决方案1】:

    您不能将“Apk”作为模块导入应用程序。它必须是“Aar”。

    错误:

    Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found incompatible value 'Apk'
    

    通常意味着您需要更改模块的 build.gradle 来自

    apply plugin: 'com.android.application'
    

    apply plugin: 'com.android.library'
    

    【讨论】:

      猜你喜欢
      • 2018-05-09
      • 2018-06-26
      • 2019-04-07
      • 1970-01-01
      • 2018-12-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多