我有一个以前运行的项目,其中版本升级到最新版本.现在由于下面的构建错误,我无法构建项目.
Failed to resolve: monitor
Open File
“打开文件”链接指向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中创建新项目时,我就遇到过这个问题.
根本原因:当我尝试构建应用程序时,Android Studio会显示此错误
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"
} ]
}
我的假设是监视器依赖性已从jcenter repo中删除(可能是暂时的).结果,构建过程失败.所以我找出了2个解决方案:
解决方案1:转到build.gradle(Project)更改repos的顺序,因此gradle构建系统将首先在google repo中找到监视器依赖项.幸运的是,这种依赖关系在repo中可用(至少到目前为止).
allprojects {
repositories {
jcenter()
google()
}
}
至
allprojects {
repositories {
google()
jcenter()
}
}
解决方案2:转到build.gradle(模块:应用程序)注释掉或删除这些行.这意味着我们的应用程序不需要Android测试支持库,它提供了一个用于测试Android应用程序的广泛框架.
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'
}
然后点击立即同步.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。