我想在我的android中添加改造,但是当我想添加该库时,我的android出现错误,这是我的错误:
Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.squareup.retrofit2:retrofit:2.5.0.
和我的应用模块代码如下:
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.mahdi.chatapp"
minSdkVersion 16
targetSdkVersion 28
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(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.google.firebase:firebase-auth:16.1.0'
implementation 'com.google.firebase:firebase-config:16.3.0'
implementation 'com.google.firebase:firebase-storage:16.1.0'
implementation 'com.google.firebase:firebase-firestore:11.8.0'
implementation 'com.google.firebase:firebase-messaging:11.8.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.android.support:support-v4:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.google.firebase:firebase-core:16.0.7'
implementation 'com.google.firebase:firebase-database:16.1.0'
implementation 'com.android.support:cardview-v7:28.0.0'
implementation 'com.rengwuxian.materialedittext:library:2.1.4'
implementation 'de.hdodenhof:circleimageview:3.0.0'
implementation 'com.github.bumptech.glide:glide:4.9.0'
implementation 'com.squareup.retrofit2:retrofit:2.5.0'
}
应用插件:“ com.google.gms.google-services”
并且我的构建项目代码在以下
:buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
classpath 'com.google.gms:google-services:4.0.1'
}
}
allprojects {
repositories {
mavenCentral()
google()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
答案 0 :(得分:2)
转到文件⇒新建项目。当它提示您选择默认活动时,选择“清空活动”并继续。
在(模块find({ userId: ObjectId("54759eb3c090d83494e2d804") })
中打开build.gradle
,并添加:app
,Retrofit
,Picasso
,RecyclerView
依赖项。
Gson
答案 1 :(得分:1)
您收到的错误是因为2.5.0
版本未签名。如果在jcenter http://jcenter.bintray.com/com/squareup/retrofit2/retrofit/2.5.0/中看到文件未签名.asc
扩展名。如果您检查版本2.4.0
尝试一下:
implementation 'com.squareup.retrofit2:retrofit:2.4.0'
implementation 'com.squareup.retrofit2:converter-gson:2.4.0'
implementation 'com.google.code.gson:gson:2.8.2'
如果您还希望使用rxJava转换器:
implementation 'com.squareup.retrofit2:adapter-rxjava2:2.4.0'
implementation 'io.reactivex.rxjava2:rxjava:2.1.13'
implementation 'io.reactivex.rxjava2:rxandroid:2.0.2'
希望有帮助!
答案 2 :(得分:1)
在应用程序级别的build.gradle文件中添加此依赖项:
implementation 'com.squareup.retrofit2:retrofit:2.5.0'
有关更多详细信息,您可以访问此link。