从Android Studio 3.0(Canary 5)迁移到Android Studio 3.0(Beta 1)后,移动到最新的gradle,即'com.android.tools.build:gradle:3.0.0-beta1'
当我尝试gradle sync时,它会在下面显示错误。
Failed to resolve: com.android.support:multidex:1.0.2
Failed to resolve: com.android.support:multidex-instrumentation:1.0.2
我检查Android Studio 3.0 Canary 9 - Failed to resolve packages,它没有解决我的问题,因为我已经有了这个
maven {
url 'https://maven.google.com'
}
我很惊讶它甚至要求multidex 1.0.2,因为我只在build.gradle中
compile 'com.android.support:multidex:1.0.1'
我检查使用./gradlew app:dependencies | grep multidex
,它显示如下的故障(各种口味等)
+--- com.android.support:multidex-instrumentation:1.0.2 FAILED
+--- com.android.support:multidex:1.0.1
+--- com.android.support:multidex:1.0.2 FAILED
+--- com.android.support:multidex:1.0.1 -> 1.0.2 FAILED
multidex:1.0.2
和multidex-instrumentation:1.0.2
的依赖关系来自哪里?我怎么能解决这个问题?
显然我的问题是我应该发布这个:
maven {
url 'https://maven.google.com'
}
在allprojects
,而不是在buildscript
(微妙的不同使我在问题所在的地方蒙蔽了眼睛),然后看起来像这样:
allprojects {
repositories {
maven {
url 'https://maven.google.com'
}
}
}
感谢M D指针!
将所有gradle依赖项更新为最新版本..就是这样
我的问题是网络连接。我需要连接到vpn服务器才能连接到jcenter
对我来说,解决方案是将google()项目向上移动以确保它在jcenter()之前。实际上,我会将google()放在所有存储库的第一位。
还需要添加以下内容:
编译'com.android.support:multidex:1.0.3'
添加上述内容后,除上述答案外,它对我有用
首先,您需要清理项目,然后重建它。
建立---->清洁项目
建立---->重建项目
allprojects {
repositories {
google()
}
}
为我工作而不是
allprojects {
repositories {
maven {
url 'https://maven.google.com'
}
}
}
如果你在中国,请使用
allprojects {
respositories {
google()
}
}
相反
allprojects {
respositories {
maven {
url 'https://maven.google.com'
}
}
}
不要问我为什么,我不想告诉你....可能是'https://maven.google.com'被GFW选中了?
在我的allprojects中添加google()解决了我的问题...
allprojects {
repositories {
jcenter()
google()
}
}
如果以上解决方案均无法正常工作,请添加mavenLocal()
:
allprojects {
repositories {
jcenter()
maven {
url 'https://maven.google.com'
}
mavenLocal()
google()
}
}
向上移动google()项目以确保它在jcenter()之前。
repositories {
jcenter()
google()
}