I create new project and Wants to Use Retrofit
library in my Project.
I implemented this library for Gson
and Retrofit
but still I can't import it to my Project.
implementation 'com.google.code.gson:gson:2.9.0'
implementation 'com.squareup.picasso:picasso:2.8'
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
implementation 'com.squareup.retrofit2:converter-gson:2.7.2'
CodePudding user response:
Here there is something to check weather it's all set or not.
1 - First implement the library in builde.gradle
like below.
implementation 'com.google.code.gson:gson:2.9.0'
implementation 'com.squareup.picasso:picasso:2.8'
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
implementation 'com.squareup.retrofit2:converter-gson:2.7.2'
2 - Add this properties to your gradle.properties
android.useAndroidX=true
android.nonTransitiveRClass=true
3 - Then Add Google() and mavenCentral in your settings.gradle
like Below
pluginManagement {
repositories {
gradlePluginPortal()
google()
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
4 - check compileOptions in your build-gradle file
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
After all this steps you can import your retrofit and gson library.
CodePudding user response:
Did you sync your project with the gradle files? If not, the IDE (I suppose you use Android Studio?) will not be able to recognize/import the required library.
Check out the Android Studio documentation to learn how to do this.