您的位置:首页 > 移动开发

升级AndroidStudio3.0 Unable to resolve dependency for ':app@betaUnitTest/compileClasspath': Could not

2017-11-02 17:56 507 查看
AndroidStudio3.0升级报了下面的错误:

Unable to resolve dependency for ':app@betaUnitTest/compileClasspath': Could not resolve project :ptr.

Could not resolve project :ptr.
Required by:
project :app
> Unable to find a matching configuration of project :ptr:
- Configuration 'debugApiElements':
- Required com.android.build.api.attributes.BuildTypeAttr 'beta' and found incompatible value 'debug'.
- Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
- 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 'debugRuntimeElements':
- Required com.android.build.api.attributes.BuildTypeAttr 'beta' and found incompatible value 'debug'.
- Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
- 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 'beta' and found incompatible value 'release'.
- Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
- 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 'releaseRuntimeElements':
- Required com.android.build.api.attributes.BuildTypeAttr 'beta' and found incompatible value 'release'.
- Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
- 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'.


分析了错误日志,和BuildType有关,“beta”、“debug”。

导入的library项目名为ptr,build.gradle的:

buildTypes {
release {
....//我自己项目中的配置
}
}


App的build.gradle是这样的:

buildTypes {
debug {
....//我自己项目中的配置
}
beta {
....//我自己项目中的配置
}
release {
....//我自己项目中的配置
}
}


对比发现确实是少了这两个,重新修改library的build.gradle,如下:

buildTypes {
debug {
...
}
beta {
...
//关键代码,release, debug为library中已有buildType
matchingFallbacks = ['release', 'debug']
}
release {
...
}
}


重新Build一下项目,就好了。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  app
相关文章推荐