Java Protobuf on Android - NoClassDefFoundError

I am creating an Android application in ADT v21.0.0. This application should use the protobuf library that I put together in a jar.

By placing this jar, as well as protobuf-java-2.4.1.jar in my libs / folder, Eclipse recognizes it during build, however whenever I try to run the application in my Android emulator, I get a NoClassDefFoundError exception when trying to create an instance one of my auto-generated custom classes created by protobuf compiler.

I saw a lot of advice on naming libs / folder (apparently the previous ADT update violated this by requiring the / lib folder to be / libs) and also adding .jars explicitly from the "Java Build Path" (and checking banks in the " Order and Export ").

None of this helped, however, and I wonder if there is something more fundamental that prevents protobuf classes from being recognized at runtime.

Note. If I create a standard Java application in Eclipse, I can use my proto classes just fine. This is a problem only when running the Android application.

+6
source share
1 answer

It seems that your project is importing some library, which depends on your autogenerator. And not on a device or emulator.

0
source

All Articles