Release app crash

What device do you run the application?
Also does you app work fine in release mode without backendless dependency?

Using Android 6, 7, 8, 8.1 and 9 … crashes.

Without backendless dependency … no crashes

Hi @Mohamed_Elgendy

I’ve just created the project from scratch, added backendless dependency, created release apk and successfully run it on my phone.
Can you specify the steps to reproduce or provide the sample project that reproduces your issue?
Also: does your app crashes with backendless dependency only in release mode or in debug too?

Best Regards,
Maksym

@Mohamed_Elgendy

Also try to update your flutter with

flutter upgrade

Hi Mohamed,

Were you able to resolve the problem?

Regards,
Mark

I have the same problem where when I include the backendless dependancy(1.0.0, 1.0.1,1.1.2) and release apk it crashes on start up. After reading this thread I did flutter upgrade and the release apk is still crashing. It works fine on the emulator tho.

Here’s where I do Backendless.initApp

Help please

1 Like

Hi @Andrew_Gadri-Akrong

As I understand, the app crushes only on real device and works fine on emulator?

Exactly

@Andrew_Gadri-Akrong , what version of Android does the device run?

Can you also provide the code that causes the app to crash? Is it Backendless initialization or any other operation?

Regards,
Maksym

Android version 7.0

Just backendless initialization.
Initially, I did the backendless initialization, sign up, login and logout using the documentation. It run fine on the emulator but crashes on release apk running on real device. I started debugging by commenting out the sign up, login and logout leaving the initialization. Worked on emulator and I did a release apk and run on a real device and still crashed.

Hi Andrew, could you please confirm that the crash occurs only when the Backendless dependency is added? Have you confirmed that without the dependency it runs fine?

Without the dependancy is runs fine

Hi @Mohamed_Rashed @Mohamed_Elgendy and @Andrew_Gadri-Akrong

I can reproduce the issue with release app crashing. I’ve created the internal ticket BKNDLSS-20713. Will update you with a progress.

Best Regards,
Maksym

Hi @Mohamed_Rashed, @Mohamed_Elgendy and @Andrew_Gadri-Akrong

The release application crash was caused by the Android code optimizer (ProGuard or R8). The Flutter enables the optimization and obfuscation by default.
There are two ways to solve this problem: disable optimizer or configure the optimizer config to don’t delete the necessary files.

  1. To disable the optimizer you can simply add the option minifyEnabled false to your android/app/build.gradle:

    android {
        buildTypes {
            release {
                ...
                minifyEnabled false
            }
        }
    }
    
  2. If you don’t want to disable the optimizer, you should add the following lines to your proguard config, due to the documentation:

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

Don’t forget to specify the proguard config in your android/app/build.gradle file:

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

Both methods work fine for me. Hope this instruction will help you.

Also don’t forget to add Internet permission to your release app. You should include

<uses-permission android:name="android.permission.INTERNET" />

in your android/app/src/main/AndroidManifest.xml file.

If you have any difficulties with building and releasing an Android app, please visit the official Flutter documentation: Build and release an Android app

Best Regards,
Maksym

2 Likes

I just had this problem as well. This should really be added to the documentation notes if they aren’t already. I certainly didn’t see them.

Hello @Carlton_Branch, the documentation contains this info https://backendless.com/docs/flutter/setup.html#proguard-configuration

how to add:
-dontwarn com.backendless.**
-dontwarn weborb.**
-keep class weborb.** {;}
-keep class com.backendless.** {
;}
in my proguard file?!

answered here: How to add backendless class to proguard? - #3 by peter_estafanos

1 Like