问题描述
我有一个以前运行的项目,该版本已升级到最新版本.现在由于下面的构建错误,我无法构建项目.
I had a previously running project, where the versions were upgraded to the latest. Now I cannot build the project due to below build error.
打开文件"链接指向build.gradle(模块)文件.我尝试了无效并重新启动",但没有帮助.
The "Open File" link is to the build.gradle (Module) file. I tried "Invalidate and Restart" which does not help.
在无法解决:监视器"或无法解决:"下进行搜索没有任何解决办法.
Searching under "Failed to resolve: monitor" or "Failed to resolve:" did not result in any solutions.
在这一点上,我完全陷入了困境.
I am completely stumped at this point.
模块:build.gradle
Module: build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
buildToolsVersion '28.0.3'
defaultConfig {
applicationId "com.example.android.sunshine"
minSdkVersion 14
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
}
}
productFlavors {
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:recyclerview-v7:28.0.0'
implementation 'com.android.support:preference-v7:28.0.0'
androidTestImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support:support-annotations:28.0.0'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test:rules:1.0.2'
}
推荐答案
昨天,每当我从Git存储库中签出新分支或在Android Studio中创建新项目时,我都遇到了这个问题.
I had encountered this problem yesterday whenever I checkout a new branch from a Git repo or create a new project in Android Studio.
根本原因::当我尝试构建应用程序时,Android Studio显示此错误
Root cause: When I try to build application, the Android Studio show this error
Could not find monitor.jar (com.android.support.test:monitor:1.0.2).
Searched in the following locations:
https://jcenter.bintray.com/com/android/support/test/monitor/1.0.2/monitor-1.0.2.jar
打开 https:/在浏览器上/jcenter.bintray.com/com/android/support/test/monitor/1.0.2/monitor-1.0.2.jar 出现此错误.
{
"errors" : [ {
"status" : 404,
"message" : "Could not find resource"
} ]
}
我的假设是monitor
依赖项已从jcenter
存储库中删除(可能是暂时的).结果,构建过程失败.所以我想出了两种解决方案:
My assumption is the monitor
dependency has been removed (might be temporarily) from jcenter
repo. As a result the build process failed. So I figure out 2 solutions:
解决方案1 :转到build.gradle (Project)
更改存储库的顺序,因此gradle构建系统将首先在google
存储库中找到monitor
依赖项.幸运的是,这种依赖关系可以在仓库中使用(至少到目前为止).
Solution 1: Go to build.gradle (Project)
change the order of repos, so gradle build system will find monitor
dependency in google
repo first. Fortunately, this dependency is available in the repo (at least so far).
allprojects {
repositories {
jcenter()
google()
}
}
到
allprojects {
repositories {
google()
jcenter()
}
}
解决方案2 :转到build.gradle (Module:App)
注释或删除这些行.这意味着我们的应用程序不需要Android测试支持库,该库提供了用于测试Android应用程序的广泛框架.
Solution 2: Go to build.gradle (Module:App)
comment-out or delete these lines. It mean our app do not need the Android Testing Support Library which provides an extensive framework for testing Android apps.
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:recyclerview-v7:28.0.0'
implementation 'com.android.support:preference-v7:28.0.0'
androidTestImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support:support-annotations:28.0.0'
// Comment-out or delete these lines
// androidTestImplementation 'com.android.support.test:runner:1.0.2'
// androidTestImplementation 'com.android.support.test:rules:1.0.2'
}
然后点击立即同步.
这篇关于Android Studio构建错误-“无法解决:监控"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!