Ime*_*ene 146 android-studio android-gradle-plugin android-studio-3.0
我迁移到Android studio 3.0.因此,项目无法编译名为":animator"的模块,它会显示以下错误:
Error:Unable to resolve dependency for
':app@dexOptions/compileClasspath': Could not resolve project
:animators. <a
href="openFile:/home/mobilepowered/MobilePowered/MyInnovalee/trunk17-10-2017/app/build.gradle">Open
File</a><br><a href="Unable to resolve dependency for
':app@dexOptions/compileClasspath': Could not resolve project
:animators.">Show Details</a>
Run Code Online (Sandbox Code Playgroud)
并显示详细信息提供此日志:
Unable to resolve dependency for ':app@dexOptions/compileClasspath':
Could not resolve project :animators.
Could not resolve project :animators. Required by:
project :app
Unable to find a matching configuration of project :animators:
- Configuration 'debugApiElements':
- Required com.android.build.api.attributes.BuildTypeAttr 'dexOptions' 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 'dexOptions' 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 'dexOptions' 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 'dexOptions' 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'.
Run Code Online (Sandbox Code Playgroud)
Sac*_*ise 132
使用Android Studio 2.3(AS),该项目工作正常,我可以运行该应用程序.将AS更新到Android Studio 3.0后.对于库和构建类型,我也得到如下错误.
Unable to resolve dependency for ':app@dexOptions/compileClasspath': Could not resolve project : library_Name.
Unable to resolve dependency for ':app@release/compileClasspath': Could not resolve project : library_Name.
Run Code Online (Sandbox Code Playgroud)
简单地解决这个问题.
无论如何
buildTypes{
debug{ ... }
release{ ... }
}
Run Code Online (Sandbox Code Playgroud)
你有(app)build.gradle文件,你必须包含所有buildTypes{ }相同的名称
buildTypes{
debug{ ... }
release{ ... }
}
Run Code Online (Sandbox Code Playgroud)
在项目中包含build.gradle的所有库/模块的文件中.
清理并重建项目,问题将得到解决.
仍然没有修复问题,请将gradle-wrapper.properties更新为
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
Run Code Online (Sandbox Code Playgroud)
小智 119
如官方迁移指南中所述,在以下情况下会遇到此错误:
您的应用程序包含库依赖项不包含的构建类型
android {
buildTypes {
release {
...
}
dexOptions {
...
// release & debug is in project animators
matchingFallbacks = ['release', 'debug']
}
debug {
...
}
}
}
Run Code Online (Sandbox Code Playgroud)
设置匹配配置回退显然是解决这个问题的正确方法.
X S*_*ish 93
确保你在项目中
Offline work复选框.Anu*_*arg 68
我在这个问题上花了很多时间,以上解决方案都不适合我.应用程序和库项目中的构建类型的名称和数量也完全相同.
我唯一的错误是 - 在库项目的build.gradle中,我正在使用line
apply plugin:'com.android.application'
这条线应该是 -
apply plugin:'com.android.library'
进行此更改后,此错误已得到解决.
Duy*_*han 58
全部修改
compile project(':library:yourproject')
至
implementation project(path: ':library:yourproject', configuration:'default')
在你的app build.gradle中.注意带有配置的行.
Sha*_*chi 27
我尝试了从取消勾选离线工作到匹配的回复.但没有任何效果.
然后,在app.gradle的依赖项中,
代替
实施项目(':lib-name')
我用了,
实现项目(路径:':lib-name',配置:'默认')
例如: implementation project(path:':myService', configuration:
'default')
它就像一个魅力.:)
我正在添加一个带有服务的依赖模块,并没有将库作为AOSP项目的一部分.
以防万一,它可以帮助某人.
小智 16
解:
下载最终版Gradle
http://services.gradle.org/distributions/
gradle-4.x-rc-1-all.zip.sha256 09-Jan-2018 01:15 +0000 64.00B
解压缩发行版
转到Android Studio - >文件 - >设置 - > Gradle - >使用本地gradle分发搜索文件,然后单击确定
在gradle中:app写这个,实现(路径:':animators',配置:'默认')
gradle-4.x-rc-1-all.zip.sha256 09-Jan-2018 01:15 +0000 64.00B
Run Code Online (Sandbox Code Playgroud)
}
这是我如何解决我的问题.
代替
compile project(':library_name')
compile project(':library_name')
Run Code Online (Sandbox Code Playgroud)
在app gralde我用过
implementation project(':library_name')
implementation project(':library_name')
Run Code Online (Sandbox Code Playgroud)
在我的构建类型中,例如
demoTest {
.........
}
Run Code Online (Sandbox Code Playgroud)
我添加了这一行
demoTest {
matchingFallbacks = ['debug', 'release']
}
Run Code Online (Sandbox Code Playgroud)
我的问题如下
Unable to resolve dependency for ':app@debug/compileClasspath': Could not download rxjava.jar (io.reactivex.rxjava2:rxjava:2.2.2)
Run Code Online (Sandbox Code Playgroud)
通过检查解决 Enable embedded Maven Repository
小智 6
我遇到了同样的问题,并通过将'mavenCentral()'添加到build.gradle(项目)来解决它
allprojects {
repositories {
...
mavenCentral()
}
}
Run Code Online (Sandbox Code Playgroud)
即便如此,我也遇到了同样的问题.
我通过使用新的g radle-4.1引用上面的解决方案2来解决这个问题:
我做了以下gradle更改.似乎通过maven下载资源亚马逊帮助我解决了这个问题,appcompat库存在问题.检查并确保在系统中下载了appcompat兼容的支持库.我的感觉,它只是简单的资源没有通过maven下载,导致编译错误问题.确保在本地驱动器中找到资源以解决问题.
刚刚玩过
repositories {
maven {
url "https://s3.amazonaws.com/repo.commonsware.com"
}
jcenter()
}
Run Code Online (Sandbox Code Playgroud)
dependencies {
implementation fileTree(dir: 'libs', include: \['*.jar'\])
implementation 'com.android.support:appcompat-v7:26.0.0-alpha1'
implementation 'com.android.support:support-v4:26.0.0-alpha1'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
}
Run Code Online (Sandbox Code Playgroud)
apply plugin: 'com.android.application'
repositories {
maven {
url "https://s3.amazonaws.com/repo.commonsware.com"
}
jcenter()
}
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.cognizant.interviewquestions.cognizantiqpractice2"
minSdkVersion 18
targetSdkVersion 26
versionCode 1
versionName "1.0"
javaCompileOptions {
annotationProcessorOptions {
includeCompileClasspath false
}
}
dexOptions {
javaMaxHeapSize "4g"
preDexLibraries = false
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: \['*.jar'\])
implementation 'com.android.support:appcompat-v7:26.0.0-alpha1'
implementation 'com.android.support:support-v4:26.0.0-alpha1'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
}
---------------------------------------------------------------------------
Run Code Online (Sandbox Code Playgroud)
小智 5
在gradle中更改此代码:
compile project(':yourLibrary')
Run Code Online (Sandbox Code Playgroud)
至
implementation project(path: ': yourLibrary', configuration:'default')
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
233157 次 |
| 最近记录: |