Home Android Studio: Add jar as library?
Reply: 0

Android Studio: Add jar as library?

user7128 Published in September 20, 2018, 12:47 pm

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?

share|improve this question
  • Refer : stackoverflow.com/a/6859020/28557 – Vinayak Bevinakatti Aug 26 '16 at 18:50
  • Although this doesn't solve the problem, just wanna point that "compile" was deprecated in favor of "implementation". – Amir Rezazadeh Jun 17 at 14:32

34 Answers 34

active oldest votes
1 2 next
up vote 1477 down vote accepted
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.603237 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO