Android Studio: Add jar as library?

Mobile Technologies Mobile Computing 2 years ago

3 0 0 0 0 tuteeHUB earn credit +10 pts

5 Star Rating 1 Rating
_x000D_ _x000D_ I'm trying to use the new Android Studio but I can't seem to get it working correctly. I'm using the Gson library to serialize/deserialize JSON-objects. But the library somehow isn't included in the build. I had created a new project with just a MainActivity. Copied gson-2.2.3.jar in the /libs folder and added it as a library dependancy(right click->Add as library). This includes the jar in android studio so it can be referenced from the source files. When I try to run the project it cannot compile so I added: compile files('libs/gson-2.2.3.jar') to the dependencies in de .gradle file. After that it compiles correctly but when running the application I get a ClassDefNotFoundException. Does anyone know what I'm doing wrong?

Posted on 30 Aug 2022, this text provides information on Mobile Computing related to Mobile Technologies. Please note that while accuracy is prioritized, the data presented might not be entirely correct or up-to-date. This information is offered for general knowledge and informational purposes only, and should not be considered as a substitute for professional advice.

Take Quiz To Earn Credits!

Turn Your Knowledge into Earnings.

tuteehub_quiz

Answers (0)

Post Answer

No matter what stage you're at in your education or career, TuteeHub will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.

Important Mobile Technologies Links