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

Android Studio: Add jar as library?

user880
1#
user880 Published in June 23, 2018, 7:57 am

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?

You need to login account before you can post.

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

© 2016 Powered by mzan.com design MATCHINFO