Reputation: 43
I am making an app in Android Studio and I need to use GSON
library. I have downloaded gson-2.8.2-javadoc
. And then I followed this way
File->New->New Module->Import .JAR/.AAR Package->gson-2.8.2-javadoc->Finish
After that
File->Project Structure->app->Dependencies->Module Dependency->gson-2.8.2-javadoc->OK
but Android Studio did not recognize the Gson
. I googled and saw the this as solution :
dependencies {
implementation 'com.google.code.gson:gson:2.8.2'
}
but this is not working too.
My gradle version was 4.4 and I upgraded it 4.9 , again this is not working too. Here is my build.gradle file:
buildscript {
repositories {
mavenCentral()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.3'
}
}
allprojects {
repositories {
mavenCentral()
google()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
By the way, I tried same ways different versions of Gson Library, it did not work as well. So, what is the reason for this issue? And What is the exact solution?
Upvotes: 4
Views: 4637
Reputation: 75788
At first, Make sure you removed gson
MODULE from your Project.
Read How to delete a module in Android Studio ?
"File -> Project Structure" ->
Select gson
Module and then Click Red Mark Negative Sign
.
FYI
You should use latest version.
implementation 'com.google.code.gson:gson:2.8.5'
Then Clean-Rebuild-Run
.
Upvotes: 1
Reputation: 76
I think you may have to had
buildscript {
repositories {
mavenCentral()
}
}
allprojects {
repositories {
mavenCentral()
}
}
to your application build.gradle file. Then build and it will be good
Upvotes: 1