Issue
I have a project with several modules. Some modules depends on the same jar. Right now each of the modules have their own "libs" folder containing 2 jars of the same library. Updating a jar file can be problematic since I will now have to change all the jars from all of the modules. Also, I encounter a compilation problem saying that there are duplicate classes. One workaround is to remove the jar files from all of the modules except for one. Is this the only way to do it or is there a better way?
Solution
I have been able to fix this issue. This reading about Gradle helped me a lot. Here is what I have done:
Instead of putting the JAR file in moduleA/libs folder, I have imported the JAR file in Android Studio by clicking on the project then right click -> new -> module. I then clicked on Import .JAR/.AAR package. This created a module containing the JAR file + a gradle script.
Then, in moduleA’s gradle script, I have added this in the dependencies: compile project(path: ':name_of_the_jar_file')
I rebuilt all and it works. The JAR file is now present in the APK and there is no more crash at runtime.
Answered By - Ashwin Khadgi
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.