gpt4 book ai didi

android - 使用 Gradle 插件 3.1.2 改造 2.4.0

转载 作者:太空狗 更新时间:2023-10-29 13:48:27 25 4
gpt4 key购买 nike

我有一个非常简单的问题。我是一名 Android 开发人员,在休假 6 个月后重返开发岗位,和往常一样,一切都发生了明显的变化。这是我的问题:

  • 在 Android Studio 3.1.2 上开始一个新的 Android 项目
  • 默认的 Gradle 插件是 3.1.2
  • 在应用的 build.gradle 中添加了 retrofit2 依赖

实现 'com.squareup.retrofit2:retrofit:2.4.0'

  • 开始gradle同步

Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.squareup.retrofit2:retrofit:2.4.0. Open File Show Details

Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve com.squareup.retrofit2:retrofit:2.4.0. Open File Show Details

Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve com.squareup.retrofit2:retrofit:2.4.0. Open File Show Details

Unable to resolve dependency for ':app@release/compileClasspath': Could not resolve com.squareup.retrofit2:retrofit:2.4.0. Open File Show Details

Unable to resolve dependency for ':app@releaseUnitTest/compileClasspath': Could not resolve com.squareup.retrofit2:retrofit:2.4.0. Open File Show Details

我阅读了整篇关于 Gradle 插件 3 迁移的文章。这没有帮助。

项目build.gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {

repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}

allprojects {
repositories {
google()
jcenter()
}
}

task clean(type: Delete) {
delete rootProject.buildDir
}

应用级build.gradle

apply plugin: 'com.android.application'

android {
compileSdkVersion 27
buildToolsVersion "27.0.3"
defaultConfig {
applicationId "com.xyz.xyz"
minSdkVersion 15
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}

}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
implementation 'com.squareup.retrofit2:retrofit:2.4.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}

最佳答案

如果您的 PC 在某些代理上运行,请在 android studio 中添加代理或检查您的互联网连接。对于代理,请按照以下步骤操作:文件 -> 设置 -> 外观和行为 -> 系统设置 -> HTTP 代理添加您的代理

否则请检查您的互联网连接

关于android - 使用 Gradle 插件 3.1.2 改造 2.4.0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50530346/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com