如何解决Android studio 无法识别旧版本的 gradle 文件
我正在尝试打开一个我很久以前使用 android studio 创建和开发的项目。但每次我尝试打开并运行该项目时,我都会收到以下错误。该项目正常运行,gradle 文件中没有任何错误。 请告诉我如何修复它
错误:
ERROR: Failed to resolve: com.android.support:appcompat-v7:26.0.1
Add Google Maven repository and sync project
Show in Project Structure dialog
Affected Modules: app
ERROR: Failed to resolve: com.android.support:recyclerview-v7:26.0.1
Add Google Maven repository and sync project
Show in Project Structure dialog
Affected Modules: app
ERROR: Failed to resolve: com.android.support:support-annotations:28.0.0
Add Google Maven repository and sync project
Show in Project Structure dialog
Affected Modules: app
WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html
Affected Modules: app
WARNING: Configuration 'testCompile' is obsolete and has been replaced with 'testImplementation'.
It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html
Affected Modules: app
WARNING: Configuration 'androidTestCompile' is obsolete and has been replaced with 'androidTestImplementation'.
It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html
Affected Modules: app
WARNING: The specified Android SDK Build Tools version (26.0.2) is ignored,as it is below the minimum supported version (28.0.3) for Android Gradle Plugin 3.3.2.
Android SDK Build Tools 28.0.3 will be used.
To suppress this warning,remove "buildToolsVersion '26.0.2'" from your build.gradle file,as each version of the Android Gradle Plugin now has a default version of the build tools.
Remove Build Tools version and sync project
Affected Modules: app
gradle 项目:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
maven {
url 'https://github.com/uPhyca/stetho-realm/raw/master/maven-repo'
}
maven {
url "https://jitpack.io"
}
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
gradle 应用:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion "26.0.2"
defaultConfig {
applicationId "com.example.pc_amr.retrofit_3"
minSdkVersion 15
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.0.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
compile 'com.squareup.okhttp3:logging-interceptor:3.4.0'
compile 'com.squareup.retrofit2:retrofit:2.3.0'
compile 'com.squareup.retrofit2:converter-gson:2.1.0'
compile 'com.squareup:otto:1.3.8'
compile 'com.google.code.gson:gson:2.6.2'
compile 'com.android.support:recyclerview-v7:26.0.1'
compile 'com.squareup.okhttp3:okhttp:3.9.0'
compile 'com.google.code.gson:gson:2.8.1'
compile 'com.solidfire.code.gson:gson:2.6.2'
compile 'com.google.code.gson:gson-parent:2.8.1'
compile 'com.solidfire.code.gson:gson-parent:2.6.2'
compile 'com.android.support:support-annotations:28.0.0'
}
解决方法
缺少 Maven 存储库,因此在项目级别 gradle
文件中执行以下操作
allprojects {
repositories {
// If you're using a version of Gradle lower than 4.1,you must instead use:
maven {
url 'https://maven.google.com'
}
// An alternative URL is 'https://dl.google.com/dl/android/maven2/'
jcenter()
}
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。