Backendless Support
 
Solved

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:

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

I tried this too:

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

same issue,

the error in console is:

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

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

Thank you.

Best Answer
photo

Mohammed,

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

  1. minSdkVersion 16

change to:

  1. minSdkVersion 19

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

Regards,

Mark

Leave a Comment

Comments (11)

photo
1

Hi Mohammed,

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

photo
1

Hello Grin,

I'm using this in my Gradle file

  1. compile 'com.backendless:backendless:4.0.0+'

photo
1

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`

photo
1

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

photo
1

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.

photo
1

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

photo
1

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.

Files: Z2T.zip
photo
1

Mohammed,

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

  1. minSdkVersion 16

change to:

  1. minSdkVersion 19

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

Regards,

Mark

photo
1

Hello Mark,

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

Thank you.

photo
1

Hi Mohammed,

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

https://www.statista.com/statistics/271774/share-of-android-platforms-on-mobile-devices-with-android-os/

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

photo
1

Thank you Mark.