Backendless Support
 
Answered

Error with the quick start guide android

I made the simplest example indicated in the quick start guide and I'm having problems to execute it:

This is the code added in Main_activity.java:

  1. String appVersion = "v1";
  2. String application_id = "*****************";
  3. String secret_key = "*****************";
  4. Backendless.initApp(this, application_id, secret_key, appVersion);
  5. BackendlessUser user = new BackendlessUser();
  6. user.setEmail("*********@***.***");
  7. user.setPassword("*********");
  8. Backendless.UserService.register(user, new BackendlessCallback<BackendlessUser>() {
  9. @Override
  10. public void handleResponse(BackendlessUser backendlessUser) {
  11. Log.i("Registration", backendlessUser.getEmail() + " successfully registered");
  12. }
  13. @Override
  14. public void handleFault(BackendlessFault fault) {
  15. Log.d(TAG, fault.toString());
  16. }
  17. });

When using Backendless 3.0.6:

compile 'com.backendless:android:3.0.6'

I get this error:

FATAL EXCEPTION: main

, PID: 28400

java.lang.NoClassDefFoundError: Failed resolution of: Lcom/backendless/BackendlessCollection;

at com.backendless.Persistence.<init>(Persistence.java:72)

at com.backendless.Persistence.<clinit>(Persistence.java:62)

at com.backendless.Persistence.getInstance(Persistence.java:66)

at com.backendless.Backendless.<clinit>(Backendless.java:43)

at com.backendless.Backendless.initApp(Backendless.java:111)

at es.quizit.activities.Main_activity.onCreate(Main_activity.java:80)

at android.app.Activity.performCreate(Activity.java:6664)

at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)

at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2599)

at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2707)

at android.app.ActivityThread.-wrap12(ActivityThread.java)

at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1460)

at android.os.Handler.dispatchMessage(Handler.java:102)

at android.os.Looper.loop(Looper.java:154)

at android.app.ActivityThread.main(ActivityThread.java:6077)

at java.lang.reflect.Method.invoke(Native Method)

at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)

at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)

Caused by: java.lang.ClassNotFoundException: com.backendless.BackendlessCollection

at java.lang.VMClassLoader.findLoadedClass(Native Method)

at java.lang.ClassLoader.findLoadedClass(ClassLoader.java:742)

at java.lang.ClassLoader.loadClass(ClassLoader.java:362)

at java.lang.ClassLoader.loadClass(ClassLoader.java:312)

at com.backendless.Persistence.<init>(Persistence.java:72)

at com.backendless.Persistence.<clinit>(Persistence.java:62)

at com.backendless.Persistence.getInstance(Persistence.java:66)

at com.backendless.Backendless.<clinit>(Backendless.java:43)

at com.backendless.Backendless.initApp(Backendless.java:111)

at es.quizit.activities.Main_activity.onCreate(Main_activity.java:80)

at android.app.Activity.performCreate(Activity.java:6664)

at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)

at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2599)

at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2707)

at android.app.ActivityThread.-wrap12(ActivityThread.java)

at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1460)

at android.os.Handler.dispatchMessage(Handler.java:102)

at android.os.Looper.loop(Looper.java:154)

at android.app.ActivityThread.main(ActivityThread.java:6077)

at java.lang.reflect.Method.invoke(Native Method)

at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)

at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)

Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/backendless/commons/AbstractBackendlessCollection;

at com.backendless.Persistence.<init>(Persistence.java:72)

at com.backendless.Persistence.<clinit>(Persistence.java:62)

at com.backendless.Persistence.getInstance(Persistence.java:66)

at com.backendless.Backendless.<clinit>(Backendless.java:43)

at com.backendless.Backendless.initApp(Backendless.java:111)

at es.quizit.activities.Main_activity.onCreate(Main_activity.java:80)

at android.app.Activity.performCreate(Activity.java:6664)

at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)

at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2599)

at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2707)

at android.app.ActivityThread.-wrap12(ActivityThread.java)

at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1460)

at android.os.Handler.dispatchMessage(Handler.java:102)

at android.os.Looper.loop(Looper.java:154)

at android.app.ActivityThread.main(ActivityThread.java:6077)

at java.lang.reflect.Method.invoke(Native Method)

at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)

at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)

Caused by: java.lang.ClassNotFoundException: Didn't find class "com.backendless.commons.AbstractBackendlessCollection" on path: DexPathList[[zip file "/data/app/com.**********-2/base.apk"],nativeLibraryDirectories=[/data/app/com.*********-2/lib/x86, /data/app/com.**********-2/base.apk!/lib/x86, /system/lib, /vendor/lib]]

at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)

at java.lang.ClassLoader.loadClass(ClassLoader.java:380)

at java.lang.ClassLoader.loadClass(ClassLoader.java:312)

at com.backendless.Persistence.<init>(Persistence.java:72)

at com.backendless.Persistence.<clinit>(Persistence.java:62)

at com.backendless.Persistence.getInstance(Persistence.java:66)

at com.backendless.Backendless.<clinit>(Backendless.java:43)

at com.backendless.Backendless.initApp(Backendless.java:111)

at es.quizit.activities.Main_activity.onCreate(Main_activity.java:80)

at android.app.Activity.performCreate(Activity.java:6664)

at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)

at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2599)

at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2707)

at android.app.ActivityThread.-wrap12(ActivityThread.java)

at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1460)

at android.os.Handler.dispatchMessage(Handler.java:102)

at android.os.Looper.loop(Looper.java:154)

at android.app.ActivityThread.main(ActivityThread.java:6077)

at java.lang.reflect.Method.invoke(Native Method)

at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)

at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)

And if I try to use compile 'com.backendless:backendless:4.0.0-beta1'

I get this other error in logcat:

D/Main_activity: BackendlessFault{ code: 'Internal client exception', message: 'https://api.backendless.com/MY-APPLICATION-ID/MY-SECRET-KEY/binary' }

03-23 14:40:45.148 509-514/com.**********

I have obviously changed my two keys in the previous error for words that mean the values throwns by the error.

If I don't handle the error, I get this stack error:

FATAL EXCEPTION: main

Process: com.********, PID: 3346

java.lang.RuntimeException: https://api.backendless.com/MY-APPLICATION-ID/MY-SECRET-KEY/binary

at com.backendless.async.callback.BackendlessCallback.handleFault(BackendlessCallback.java:28)

at com.backendless.UserService$1.handleFault(UserService.java:116)

at com.backendless.async.message.AsyncMessage$FaultHandler.handle(AsyncMessage.java:83)

at com.backendless.async.message.AsyncMessage.handleCallback(AsyncMessage.java:41)

at com.backendless.core.AndroidCarrier$1.handleMessage(AndroidCarrier.java:37)

at android.os.Handler.dispatchMessage(Handler.java:98)

at android.os.Looper.loop(Looper.java:154)

at android.app.ActivityThread.main(ActivityThread.java:6077)

at java.lang.reflect.Method.invoke(Native Method)

at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)

at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)

Any help would be appreciated. Probably the Android samples need to be updated to Android Studio and Gradle so we could leverage them. Thank you

My apologies for the formatting of the question. I had problems with the editor.

Best Answer
Leave a Comment

Comments (11)

photo
1

Hi Jose Luis,

You are using a rather old version of Backendless SDK. Please see the following blog post which will help you resolve the issue:

https://backendless.com/backendless-sdk-for-android-make-sure-to-pick-the-right-version/

Regards,

Mark

photo
1

Thank you Mark,

I have used in my gradle file: compile 'com.backendless:backendless:4.0.0-beta1'

It's not this the last version mentioned in the blog post? or is the way (using gradle) the problem?

photo
1

The 4.0.0-beta1 must be used with Backendless 4. if you are working with Backendless Cloud (which is still version 3.x, you should use version 3.0.25 of the SDK for Android.

photo
1

I have tried to use 3.0.25 but I can't find it, the last version available is 3.0.6 as mentioned in the blog post and in Maven Central.

Sadly, I've used that version (3.0.6) and I got the first error mentionen in my question.

Any thoughts?

photo
1

Ok, I see there is a plethora of versions in different places:

https://backendless.com/downloads/ you can find 3.0.21

In the Github repository the last commit in master points to "'3.0.24-snapshot'"

In Maven 3.0.6

I still can't find 3.0.25 . From the user perspective this is kind of messy. I can see there is a lot of effort building this but is kind of discouraging. I will give it a try though if I am able to eventually find the 3.0.25 :)

photo
1

Ok, there it is!

Thank you Oleg and Mark. Android Studio didn't find that version and looking in Maven I didn't detect it because it looks the same thing (please look the attached file).

photo
2

Yes, we know it. We change a package naming in maven repository a year ago.

Feel free to ask us, if you faced with troubles.

photo
1

Thank you Oleg, the doc is kind of messy but your support is remarkable.

photo
1

Error:(28, 13) Failed to resolve: com.backendless:backendless:3.0.25

<a href="openFile:D:/FCIH/Third Year/Second Term/DSS/Andorid/BackendSample/app/build.gradle">Show in File</a><br><a href="open.dependency.in.project.structure">Show in Project Structure dialog</a>

photo
1
photo