initApp null pointer and crash app-Android. I use the lastest sdk version

My app crashed when run, the error is this:

FATAL EXCEPTION: main
Process: com.vuelo247.tutipic, PID: 4205
java.lang.ExceptionInInitializerError
at com.backendless.Backendless.<clinit>(Backendless.java:42)
at com.vuelo247.tutipic.vistas.Activity_Login.onCreate(Activity_Login.java:74)
at android.app.Activity.performCreate(Activity.java:5231)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2148)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233)
at android.app.ActivityThread.access$800(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5001)
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:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at weborb.types.Types.addClientClassMapping(Types.java:129)
at com.backendless.UserService.<init>(UserService.java:56)
at com.backendless.UserService.<clinit>(UserService.java:47)
at com.backendless.Backendless.<clinit>(Backendless.java:42)
at com.vuelo247.tutipic.vistas.Activity_Login.onCreate(Activity_Login.java:74)

I search in forum from Backendless but have not solution.

Thanks

How did you import the backendless library? Did you use maven or the SDK from our website?

Hi Mark, i import SDK from website, i save backendless.jar in libs folder and add to gradle the line, compile files(‘libs/backendless.jar’)

Thanks for you answer

What other dependencies do you have in the project?

dependencies {
compile fileTree(dir: ‘libs’, include: [’*.jar’])
compile ‘com.android.support:appcompat-v7:23.1.1’
compile ‘com.github.championswimmer:Android-SocialButtons:1.0’
compile ‘com.android.support:design:23.1.1’
compile ‘com.google.android.gms:play-services:8.3.0’
compile ‘com.mcxiaoke.volley:library:1.0.+’
compile ‘com.squareup.picasso:picasso:2.5.2’
compile files(‘libs/butterknife-7.0.1.jar’)
compile files(‘libs/backendless.jar’)
}

Is there anything in the /libs directory?

Only the libraries butterknife and backendless.

The service is working fine?

Yes, we’re not seeing any issues.

Hi Leandro,

Try adding this to your android closure in your build.gradle file:

dexOptions {
    javaMaxHeapSize "4g"
}

Let us know if it fixes the problem.

thank you very much the problem was solved!!!

I am having the same problem but the “dexOptions” solution didn’t work for me.

Here is my gradle, and i just have one .jar file , backendless.

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"
    dexOptions {
        javaMaxHeapSize "4g"
    }
    defaultConfig {
        applicationId "com.esprit.diasporafinder"
        minSdkVersion 15
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    packagingOptions {
        exclude 'META-INF/DEPENDENCIES.txt'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/notice.txt'
        exclude 'META-INF/license.txt'
        exclude 'META-INF/dependencies.txt'
        exclude 'META-INF/LGPL2.1'
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    testCompile 'junit:junit:4.12'
    compile files('libs/backendless.jar')
    compile 'com.android.support:appcompat-v7:23.2.1'
    compile 'com.android.support:design:23.2.1'
    compile 'com.android.support:support-v4:23.2.1'
    compile 'com.google.android.gms:play-services:8.4.0'
    compile 'com.android.support:cardview-v7:23.2.1'
    compile 'com.android.support:recyclerview-v7:23.2.1'
    compile 'com.github.siyamed:android-shape-imageview:0.9.+@aar'
 }

You have one jar in the libs folder, but you also have 7 other dependencies as well as junit on top of it. This error is entirely a function of available memory space. If you run it on an emulator, consider increasing available memory for the virtual machine.

and here is the error log:


03-28 02:17:33.668 15046-15046/? E/AndroidRuntime: FATAL EXCEPTION: main
                                                   Process: com.esprit.diasporafinder, PID: 15046
                                                   java.lang.ExceptionInInitializerError
                                                       at com.backendless.Backendless.&lt;clinit&gt;(Backendless.java:42)
                                                       at com.esprit.diasporafinder.activite.LoginActivity.onCreate(LoginActivity.java:36)
                                                       at android.app.Activity.performCreate(Activity.java:5322)
                                                       at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1093)
                                                       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2303)
                                                       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2391)
                                                       at android.app.ActivityThread.access$900(ActivityThread.java:166)
                                                       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1281)
                                                       at android.os.Handler.dispatchMessage(Handler.java:102)
                                                       at android.os.Looper.loop(Looper.java:146)
                                                       at android.app.ActivityThread.main(ActivityThread.java:5511)
                                                       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:1283)
                                                       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
                                                       at dalvik.system.NativeStart.main(Native Method)
                                                    Caused by: java.lang.NullPointerException
                                                       at weborb.types.Types.addClientClassMapping(Types.java:129)
                                                       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.esprit.diasporafinder.activite.LoginActivity.onCreate(LoginActivity.java:36) 
                                                       at android.app.Activity.performCreate(Activity.java:5322) 
                                                       at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1093) 
                                                       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2303) 
                                                       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2391) 
                                                       at android.app.ActivityThread.access$900(ActivityThread.java:166) 
                                                       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1281) 
                                                       at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                       at android.os.Looper.loop(Looper.java:146) 
                                                       at android.app.ActivityThread.main(ActivityThread.java:5511) 
                                                       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:1283) 
                                                       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099) 
                                                       at dalvik.system.NativeStart.main(Native Method) 
03-28 02:17:33.678 15046-15046/? I/Process: Sending signal. PID: 15046 SIG: 9

Please see my previous answer.

sorry i didn’t see your previous answer.

actually i’m running it on my phone but it still doesn’t work.
what do you think i should do ?

How much memory does the phone have?

Did you enable proguard?

No i didn’t, by memory you mean SD Card or Ram ? SD Card = 8Gb

RAM : 2Gb

i’ve just enabled proguard but still doesn’t work -_-

Try running it on an emulator. Make sure to set the heap size on the VP to 64.