android - 无法解决改造的依赖关系2
问题描述
我尝试将改造库导入到我的 gradle 文件中,但不幸的是,我遇到了太多错误。
Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.squareup.retrofit2:retrofit:2.4.0.
Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve com.squareup.retrofit2:retrofit:2.4.0.
Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve com.squareup.retrofit2:retrofit:2.4.0.
Unable to resolve dependency for ':app@release/compileClasspath': Could not resolve com.squareup.retrofit2:retrofit:2.4.0.
Unable to resolve dependency for ':app@releaseUnitTest/compileClasspath': Could not resolve com.squareup.retrofit2:retrofit:2.4.0.
编辑 这是我的应用程序 build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.example.practice"
minSdkVersion 19
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'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:design:27.1.1'
implementation 'com.dinuscxj:recyclerrefreshlayout:2.0.5'
implementation 'com.makeramen:roundedimageview:2.3.0'
implementation 'com.android.support:cardview-v7:27.1.1'
implementation 'com.aurelhubert:ahbottomnavigation:2.1.0'
implementation 'com.android.support:support-v4:27.1.1'
implementation 'com.google.firebase:firebase-database:16.0.1'
implementation 'com.google.firebase:firebase-auth:16.0.3'
implementation 'com.google.firebase:firebase-storage:16.0.1'
implementation 'com.google.firebase:firebase-core:16.0.1'
implementation 'com.firebaseui:firebase-ui-database:4.1.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'
implementation 'com.jakewharton:butterknife:8.8.1'
implementation 'com.jakewharton.timber:timber:4.7.1'
implementation 'com.squareup.picasso:picasso:2.71828'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
implementation 'id.zelory:compressor:2.1.0'
implementation 'com.vanniktech:emoji-one:0.5.1'
implementation 'net.danlew:android.joda:2.9.9.3'
implementation 'com.squareup.retrofit2:retrofit:2.4.0'
}
apply plugin: 'com.google.gms.google-services'
这是我的项目 build.gradle
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.4'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.google.gms:google-services:4.0.1'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
我添加了最新版本的 retrofit2,但仍然出现这些错误。我已经寻找可能的解决方案,但我找不到任何东西。有人可以帮我解决这个问题吗?
解决方案
你可以添加这个插件是你的应用程序 build.gradle 文件
implementation 'com.squareup.retrofit2:retrofit:2.4.0'
implementation 'com.google.code.gson:gson:2.8.2'
implementation 'com.squareup.retrofit2:converter-gson:2.4.0'
implementation 'com.squareup.okhttp3:logging-interceptor:3.4.1'
implementation 'com.squareup.okhttp3:okhttp:3.10.0'
你可以在所有项目中像下面的代码一样更改项目 build.gradle 文件吗
allprojects {
repositories {
google()
maven { url "https://jitpack.io" }
jcenter()
} }
推荐阅读
- ios - SwiftUI 将滚动位置向上传递到视图层次结构
- postgresql - PostgreSQL:排除按另一个键排序的重复项
- javascript - 我怎样才能让这段代码更 React - 比如
- sql - SQL 多重连接
- javascript - 为什么打字稿中允许任何类型?在编译时难以捕获错误的地方
- spring - 如何判断请求URL中是否存在@PathVariable?
- c# - 查找日期范围之间的差距
- r - 我有两列的数据框,“PID7”和“ideo5”。我想找到两列之间的单个组合的计数
- javascript - 角度 11 中 FormControlName 的动态绑定
- dart - Dart - Java buildUpon 等价物