Backendless 4.0: NoClassDefFoundError

Hello,

I’m testing Backendless 4 in my own server and I’m getting this error when I’m trying to retrieve a list of items.
The problem happen for this line:

List<Contact> data = Backendless.Persistence.of( Contact.class ).find();

I tried this too:

List<Contact> data = Backendless.Data.of( Contact.class ).find();

same issue,
the error in console is:


FATAL EXCEPTION: AsyncTask #1
java.lang.RuntimeException: An error occured while executing doInBackground()
    at android.os.AsyncTask$3.done(AsyncTask.java:299)
    at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:352)
    at java.util.concurrent.FutureTask.setException(FutureTask.java:219)
    at java.util.concurrent.FutureTask.run(FutureTask.java:239)
    at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
    at java.lang.Thread.run(Thread.java:841)
 Caused by: java.lang.NoClassDefFoundError: java.util.Objects
    at com.backendless.Persistence.find(Persistence.java:556)
    at com.backendless.DataStoreFactory$1.find(DataStoreFactory.java:170)
    at com.nextlevel.bel4t2.MainActivity$BackgroundTask.doInBackground(MainActivity.java:69)
    at com.nextlevel.bel4t2.MainActivity$BackgroundTask.doInBackground(MainActivity.java:41)
    at android.os.AsyncTask$2.call(AsyncTask.java:287)
    at java.util.concurrent.FutureTask.run(FutureTask.java:234)

in Backendless 3 everything fine, also getting single item is fine.

Thank you.

Hi Mohammed,

please make sure you are using 4 version of SDK for you Backendless 4.0 instance.

Hello Grin,

I’m using this in my Gradle file

 compile 'com.backendless:backendless:4.0.0+'

That’s correct. Thank you for reporting this issue, we will investigate it and fix as soon as possible.

You can reference to internal ticket by it’s ID: BKNDLSS-14034

Our developer can’t reproduce this issue. Could you generate project template and try to reproduce your issue there?

Hello Grin,

In the attachment sample project that have the issue, it only contain a button to run the above line of code.

I tried to generate template but it gives me the same error.
to make it clear, I can get items by id with out issue but when I try to get them as a list from Backendless I get the error.

Thank you.

BEL4T2.zip (27.2MB)

Mohammed, by “project template”, Stanislaw meant this feature: https://youtu.be/x7IiCEzFbiw?t=1m29s

Hello Mark,

Yes I used the generated project from Backendless and I get the same error.

  • attachment below is Backendless template with call to the above code producing the error.

Thank you.

Z2T.zip (18.29MB)

Mohammed,

what if you change the following line in build.gradle (Module:app):

minSdkVersion 16

change to:

minSdkVersion 19

The reason for the change is the class the exception complains about (java.util.Objects) was added in API 19.

Regards,
Mark

Hello Mark,

Yes that fix the problem, is there a way to make it compatible with 16?

Thank you.

Hi Mohammed,

API 16 is Android 4.1, which according to the source below has only 5.6% market share:

We would not be able to allocate resources to make it compatible, however, the SDK is open source and you are welcome to fork it and make the changes yourself.

Regards,
Mark

Thank you Mark.