Force link classes in order for class instantiation via reflection using JSON in libgdx?

Hi all,

Basically when using the JSON class within libGDX I need a way to force link classes into the build as I am getting errors;

Caused by: java.lang.NoClassDefFoundError

I don’t know if my terminology is correct, but the problem was outlined here when libGDX was using roboVM, there was a way to force link classes into the build like below.


I have also asked this question on libGDX forum and StackOverflow so please check if anything there helps in finding an answer to this question.

My game levels are defined in JSON and built at runtime via reflection, I am sure it is just because the classes are not used directly in the code they are getting stripped out of being compiled.

Greatly appreciate any help on this.

Dear squareorbit,

I think you need to configure ProGuard in MOE.

Cheers liliomk,

Although that wasn’t the solution, it did lead me to the correct answer.

For anyone else in the future, I had to create the file proguard.append.cfg, which allows you to define java packages which must be kept in the build; an example:

-keep class com.mypackage.** { *; }

Dear squareorbit,

The link Kristóf gave you pointed to the ProGuard configuration documentation, where you had the link For further configuration see ProGuard Task., which included the information that you copied here.

It is true that these 2 sections could be merged in the docs, but it is not like we sent you on a treasure hunt, like your reply made it look. :slight_smile:

Best Regards,

Hi kisg,

Apologies if it came across that way! It could very well have been what Kristóf was suggesting as I understand that proguard can trim the build to suit, which I did not know about.

If I had have known about that it would have been the first thing I would have tried just as Kristóf suggested!

All the best,