Backendless.initApp crash (NoClassDefFoundError)

I know this post exists (http://support.backendless.com/t/java-lang-noclassdeffounderror-weborb-types-types), but it didn’t help me, so here we go.
I have a working app using Backendless and now I would like to add functionalities of the Facebook SDK. The only changes I’ve made are the following:

//MainActivity
protected void onCreate( Bundle savedInstanceState ){ ...
 FacebookSdk.sdkInitialize(getApplicationContext()); <--ADDED THIS
...}

//Login Activity
protected void onCreate( Bundle savedInstanceState ){...
fb_callbackManager = CallbackManager.Factory.create(); <--ADDED THIS
...}

//Build.gradle 
dependencies {
 compile fileTree(dir: 'libs', include: ['*.jar'])
 testCompile 'junit:junit:4.12'
 compile files('libs/backendless.jar')
 compile 'com.android.support:appcompat-v7:23.1.1'
 compile 'com.android.support:design:23.1.1'
 compile 'com.android.support:cardview-v7:23.0.+'
 compile 'com.android.support:recyclerview-v7:23.1.1'
 compile 'com.google.android.gms:play-services:8.4.0'
 compile 'com.facebook.android:facebook-android-sdk:[4,5)' <--ADDED THIS
}

It builds OK, but when I run the the app…

E/AndroidRuntime: FATAL EXCEPTION: main
 Process: com.app.jgc.findamate, PID: 7876
 java.lang.NoClassDefFoundError: weborb.types.Types
 at com.backendless.UserService.&lt;init&gt;(UserService.java:56)
 at com.backendless.UserService.&lt;clinit&gt;(UserService.java:47)
 at com.backendless.Backendless.&lt;clinit&gt;(Backendless.java:42)
 at com.app.jgc.findamate.activity.ListActivitiesActivity.onCreate(ListActivitiesActivity.java:82) <--this is Backendless.initApp
 at android.app.Activity.performCreate(Activity.java:5248)
 at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
 at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2164)
 at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2249)
 at android.app.ActivityThread.access$800(ActivityThread.java:141)
 at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1212)
 at android.os.Handler.dispatchMessage(Handler.java:102)
 at android.os.Looper.loop(Looper.java:136)
 at android.app.ActivityThread.main(ActivityThread.java:5113)
 at java.lang.reflect.Method.invokeNative(Native Method)
 at java.lang.reflect.Method.invoke(Method.java:515)
 at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:609)
 at dalvik.system.NativeStart.main(Native Method)

There were already several dependencies working fine before I got the crash, so I doubt it is a matter of memory. Could it be a problem related with FB SDK? I attach my build.gradle in .txt
Thank you in advance

build.gradle.txt (1.2kB)

Hi Jorge,

Private posts are reserved for developers who have a paid support plan. I can make the topic public. Otherwise, please consider purchasing a support plan: https://backendless.com/support

Regards,
Mark

I was only editing properly the post, it is public now

The class it complains about “weborb.types.Types” is a part of backendless.jar. Based on what we found out from other similar posts, it seems to be a problem with the heap size - Android runs out of “space” for all imported classes. Do you think this could be the case here?

Thanks Mark.

I have just tried running the app commenting

import com.facebook.FacebookSdk;

, which is the only thing I have imported after the last time it worked fine. I am having the same “weborb.types.Types” problem, so I doubt this is the case.

Does it work if you exclude the facebook dependency?

Yes, it definitely works

Hi Jorge,

This is quite puzzling. We had a few users who were able to solve this by increasing the heap size. I feel like we’re fixing facebook’s problem here…

Would it be possible for you to attach your logcat output (with the DEBUG) mode turned on?

Regards,
Mark

Here it is. Thanks

jorgesLog.txt (29.26kB)

Thanks, Jorge. Do you have proguard enabled by any chance?

Yes, in the build.gradle I attached on the post there are this lines:


buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    productFlavors {
    }

Sorry, I missed that in the gradle file. Could you please make sure you proguard rules include the following:

-dontwarn com.backendless.**
-dontwarn weborb.**
-keep class weborb.** {*;}
-keep class com.backendless.** {*;}

How could I do that? Do I paste that lines in proguard-proyect.txt or proguard-rules.pro?

Try proguard-rules.pro

Well, now I have got the same error but pointing the line:

Backendless.setUrl(Defaults.SERVER_URL);

Maybe I added the rules in a wrong way, I attach proguard-rules.pro

proguard-rules.pro.txt (776B)

Could you show the error you’re getting now?

E/AndroidRuntime: FATAL EXCEPTION: main
 Process: com.app.jgc.findamate, PID: 6411
 java.lang.NoClassDefFoundError: weborb.types.Types
 at com.backendless.UserService.&lt;init&gt;(UserService.java:56)
 at com.backendless.UserService.&lt;clinit&gt;(UserService.java:47)
 at com.backendless.Backendless.&lt;clinit&gt;(Backendless.java:42)
 at com.app.jgc.findamate.activity.ListActivitiesActivity.onCreate(ListActivitiesActivity.java:77) <--Now this is Backendless.setUrl
 at android.app.Activity.performCreate(Activity.java:5248)
 at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
 at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2164)
 at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2249)
 at android.app.ActivityThread.access$800(ActivityThread.java:141)
 at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1212)
 at android.os.Handler.dispatchMessage(Handler.java:102)
 at android.os.Looper.loop(Looper.java:136)
 at android.app.ActivityThread.main(ActivityThread.java:5113)
 at java.lang.reflect.Method.invokeNative(Native Method)
 at java.lang.reflect.Method.invoke(Method.java:515)
 at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:609)
 at dalvik.system.NativeStart.main(Native Method)

Would it be possible for you to zip up the project, upload to google drive or dropbox and email the link to support@backendless.com?

Absolutely. It is sent in 10 minutes or so. Thank you

Jorge,

I was able to compile and run the app without any problems. I registered a user - you should see (me) in the Users table.
https://monosnap.com/file/C5U4GXrSL7eSqecPn9flPK3NQpSYMH

I am using Android Studio 1.5.1, same project without a single change.

Mark