Error:Failed to resolve: common in android studio
Error:Failed to resolve: common in android studio
我重新安装了 android 工作室,再次打开我的旧项目时显示以下错误:
Error:Failed to resolve: firebase-messaging
<a href="openFile:D:/Android projects/Porject_name/app/build.gradle">Open File</a>
Error:Failed to resolve: common
<a href="openFile:D:/Android projects/Porject_name/app/build.gradle">Open File</a>
build.gradle(项目)文件:
// Top-level build file where you can add configuration options common to
all sub-projects/modules.
buildscript {
repositories {
jcenter()
maven {
url 'https://maven.google.com/'
name 'Google'
}
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.3'
classpath 'com.google.gms:google-services:3.1.0'
}
}
allprojects {
repositories {
jcenter()
mavenCentral()
google()
maven {
url "https://jitpack.io"
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
build.gradle(应用程序)文件:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion '27.0.3'
useLibrary 'org.apache.http.legacy'
defaultConfig {
applicationId "com.example.abc"
minSdkVersion 16
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:26.1.0'
testCompile 'junit:junit:4.12'
compile 'com.android.support:design:26.1.0'
compile 'com.android.support:support-v4:26.1.0'
compile 'com.github.traex.rippleeffect:library:1.3'
compile 'com.mcxiaoke.volley:library-aar:1.0.0'
compile 'com.google.firebase:firebase-messaging:12.0.0'
compile 'com.baoyz.swipemenulistview:library:1.3.0'
compile 'se.emilsjolander:stickylistheaders:2.1.5'
compile 'com.applandeo:material-calendar-view:1.4.0'
compile 'com.github.michaelye.easydialog:easydialog:1.4'
implementation 'de.hdodenhof:circleimageview:2.2.0'
compile 'com.squareup.picasso:picasso:2.5.2'
}
apply plugin: 'com.google.gms.google-services'
我已经添加了所有必需的插件和 sdk,但仍然无法正常工作。
安装的 Firebase plugins.even google 也可以播放服务。在我卸载工作室之前它工作正常。请帮忙。
Add/Move 这个 maven {url "https://maven.google.com"} 到顶部使我的工作在 build.gradle
这对我有用。我只是像这样重新排序
repositories {
mavenCentral()
mavenLocal()
google()
jcenter()
}
当我在 Android Studio preview(Android Studio 3.2 Canary 18) 版本中有 运行 项目时,我也遇到了这个问题这改变了
gradle-wrapper.properties分配url到distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
并且它还影响了 build.gradle(项目级别)中的类路径
classpath 'com.android.tools.build:gradle:3.2.0-alpha16'
因此 android studio 预览版所做的上述更改导致我的项目出现 Error:Failed to resolve: common <a href..>
错误,所以我通过将它们改回稳定
简单地解决了这个问题
解决方案
在gradle-wrapper.properties中将url更改为distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
将类路径更改为 classpath 'com.android.tools.build:gradle:3.1.2'
我重新安装了 android 工作室,再次打开我的旧项目时显示以下错误:
Error:Failed to resolve: firebase-messaging
<a href="openFile:D:/Android projects/Porject_name/app/build.gradle">Open File</a>
Error:Failed to resolve: common
<a href="openFile:D:/Android projects/Porject_name/app/build.gradle">Open File</a>
build.gradle(项目)文件:
// Top-level build file where you can add configuration options common to
all sub-projects/modules.
buildscript {
repositories {
jcenter()
maven {
url 'https://maven.google.com/'
name 'Google'
}
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.3'
classpath 'com.google.gms:google-services:3.1.0'
}
}
allprojects {
repositories {
jcenter()
mavenCentral()
google()
maven {
url "https://jitpack.io"
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
build.gradle(应用程序)文件:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion '27.0.3'
useLibrary 'org.apache.http.legacy'
defaultConfig {
applicationId "com.example.abc"
minSdkVersion 16
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:26.1.0'
testCompile 'junit:junit:4.12'
compile 'com.android.support:design:26.1.0'
compile 'com.android.support:support-v4:26.1.0'
compile 'com.github.traex.rippleeffect:library:1.3'
compile 'com.mcxiaoke.volley:library-aar:1.0.0'
compile 'com.google.firebase:firebase-messaging:12.0.0'
compile 'com.baoyz.swipemenulistview:library:1.3.0'
compile 'se.emilsjolander:stickylistheaders:2.1.5'
compile 'com.applandeo:material-calendar-view:1.4.0'
compile 'com.github.michaelye.easydialog:easydialog:1.4'
implementation 'de.hdodenhof:circleimageview:2.2.0'
compile 'com.squareup.picasso:picasso:2.5.2'
}
apply plugin: 'com.google.gms.google-services'
我已经添加了所有必需的插件和 sdk,但仍然无法正常工作。 安装的 Firebase plugins.even google 也可以播放服务。在我卸载工作室之前它工作正常。请帮忙。
Add/Move 这个 maven {url "https://maven.google.com"} 到顶部使我的工作在 build.gradle
这对我有用。我只是像这样重新排序
repositories {
mavenCentral()
mavenLocal()
google()
jcenter()
}
当我在 Android Studio preview(Android Studio 3.2 Canary 18) 版本中有 运行 项目时,我也遇到了这个问题这改变了
gradle-wrapper.properties分配url到
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
并且它还影响了 build.gradle(项目级别)中的类路径
classpath 'com.android.tools.build:gradle:3.2.0-alpha16'
因此 android studio 预览版所做的上述更改导致我的项目出现 Error:Failed to resolve: common <a href..>
错误,所以我通过将它们改回稳定
解决方案
在gradle-wrapper.properties中将url更改为distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
将类路径更改为 classpath 'com.android.tools.build:gradle:3.1.2'