Android Studio 3.0: Unable to resolve module dependency

早过忘川 提交于 2020-01-13 20:21:07

问题


I have a one main project and second project (module).

After I import the module project as a module dependency into app project and try to sync everything, I get the following error:

Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve project :module.
Could not resolve project :module.
Required by: project :app
Unable to find a matching configuration of project :module:
 - Configuration 'debugApiElements':
     - Required com.android.build.api.attributes.BuildTypeAttr 'debug' and found compatible value 'debug'.
     - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found incompatible value 'Apk'.
     - Found com.android.build.gradle.internal.dependency.VariantAttr 'debug' but wasn't required.
     - Required org.gradle.api.attributes.Usage 'java-api' and found compatible value 'java-api'.
 - Configuration 'debugMetadataElements':
     - Required com.android.build.api.attributes.BuildTypeAttr 'debug' and found compatible value 'debug'.
     - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found incompatible value 'Metadata'.
     - Found com.android.build.gradle.internal.dependency.VariantAttr 'debug' but wasn't required.
     - Required org.gradle.api.attributes.Usage 'java-api' but no value provided.
 - Configuration 'debugRuntimeElements':
     - Required com.android.build.api.attributes.BuildTypeAttr 'debug' and found compatible value 'debug'.
     - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found incompatible value 'Apk'.
     - Found com.android.build.gradle.internal.dependency.VariantAttr 'debug' but wasn't required.
     - Required org.gradle.api.attributes.Usage 'java-api' and found incompatible value 'java-runtime'.
 - Configuration 'releaseApiElements':
     - Required com.android.build.api.attributes.BuildTypeAttr 'debug' and found incompatible value 'release'.
     - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found incompatible value 'Apk'.
     - Found com.android.build.gradle.internal.dependency.VariantAttr 'release' but wasn't required.
     - Required org.gradle.api.attributes.Usage 'java-api' and found compatible value 'java-api'.
 - Configuration 'releaseMetadataElements':
     - Required com.android.build.api.attributes.BuildTypeAttr 'debug' and found incompatible value 'release'.
     - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found incompatible value 'Metadata'.
     - Found com.android.build.gradle.internal.dependency.VariantAttr 'release' but wasn't required.
     - Required org.gradle.api.attributes.Usage 'java-api' but no value provided.
 - Configuration 'releaseRuntimeElements':
     - Required com.android.build.api.attributes.BuildTypeAttr 'debug' and found incompatible value 'release'.
     - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found incompatible value 'Apk'.
     - Found com.android.build.gradle.internal.dependency.VariantAttr 'release' but wasn't required.
     - Required org.gradle.api.attributes.Usage 'java-api' and found incompatible value 'java-runtime'.

My dependency in main app.gradle:

compile project(':module')

I found out that if I change it to the following:

compile project(path: ':module', configuration:'default')

Then the project synchronizes and builds.

However in main project class files I am unable to import any files from the module project.

Spent already couple hours searching for answers and nothing I've found so far helps. Went as far as to reinstalling Android Studio 3.0 but it didn't help.


回答1:


Solved my problem.

I created test module using apply plugin: 'com.android.application' when it should be using apply plugin: 'com.android.library'.

While you can have multiple application modules in a project, you cannot have application modules depend on other application modules.



来源:https://stackoverflow.com/questions/47251369/android-studio-3-0-unable-to-resolve-module-dependency

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!