The past two days i have tried to find a solution to this problem but with no luck.
I am trying to include GSON
lib. Into my android project.
Here is a picture of my folder structure:
Now in my build.gradle i have the following:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
dependencies {
compile files('libs/gson-2.2.4.jar')
}
i have also right clicked gson-2.2.4.jar and added it as a lib.
When i compile i get the following error:
Gradle: A problem occurred evaluating root project 'notebox-android'.
> Could not find method compile() for arguments [directory 'libs'] on root project 'notebox-android'.
Can anyone help me with this?
please tell me if you need more information!
You can fix this issue by replacing compile with implementation in node_modules/react-native-geocoder/android/build. gradle.
compileOnly: when we don't need any dependency at runtime, since compileOnly dependency won't become the part of the final build. we will get a smaller build size. runtimeOnly: when we want to change or swap the behaviour of the library at runtime (in final build).
This is because of slow internet connection or you haven't configure proxy settings correctly. Gradle needs to download some dependencies , if it cant access the repository it fires this error. All you have to do is check your internet connection and make sure gradle can access the maven repository.
CompileOnly ( deprecated version — provided) This is useful when you're creating an Android module and you need the dependency during compilation, but it's optional to have it present at runtime.
The answer to this question might help you to import your gson library correctly and avoid any compile/link issues: Android Studio - Importing external Library/Jar. Another related link: Android Studio: Add jar as library? with accepted answer. Both answers say the same thing. gradlew clean
after you add/import the jar file and edit the build.gradle file.
HTH.
Edit: There are two build.gradle files. You should be editing the build.gradle that's under your project folder and not the one under your project-root folder.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With