Flutter release build getting counter value crashes Android app on device

Flutter release build on an Android device then getting the value of a counter with getValue() call, this works fine in the simulator and in a Fultter run build, I can also upload an IPA to the app store and there is no problem getting the counter value.

In Flutter run --release build the following code crashes at the int? count = await counter.getValue(); call then error is as follows and the full log is below, the app runs fine with all the other Backendless calls, it is only the counter that is crashing in release mode on an Android device.

I have properly set up all the extensive changes Backendless requires for doing a release build from this excellent link Release Crash in Android - #16 by Nikita_Fedorishchev

CRASH LINE:

java.lang.RuntimeException: unsupported data type. Cannot adapt counter value to type - class java.lang.Object

CODE:

Future updateCountSupport(IAtomic counter, EThumbTypes selection) async {
//print(“###### updateCountSupport: $counter”);
int? count = await counter.getValue();
//print(“###### updateCountSupport: $count”);
if (count != null) {
thumbsCount += 1;
appRepository.saveCount(guideEntry, selection, count);
if (thumbsCount == 3) {
await saveCounter(save: true);
}
}
}

CRAH OUPUT:

E/AndroidRuntime(26839): FATAL EXCEPTION: main
E/AndroidRuntime(26839): Process: com.codefab.ph.alona_beach_guide, PID: 26839
E/AndroidRuntime(26839): java.lang.RuntimeException: unsupported data type. Cannot adapt counter value to type - class java.lang.Object
E/AndroidRuntime(26839): at com.backendless.Counters.convertToType(Unknown Source:97)
E/AndroidRuntime(26839): at com.backendless.atomic.AtomicCallback.handleResponse(Unknown Source:31)
E/AndroidRuntime(26839): at com.backendless.async.message.AsyncMessage$ResponseHandler.handle(Unknown Source:6)
E/AndroidRuntime(26839): at com.backendless.async.message.AsyncMessage.handleCallback(Unknown Source:2)
E/AndroidRuntime(26839): at com.backendless.core.AndroidCarrier$1.handleMessage(Unknown Source:4)
E/AndroidRuntime(26839): at android.os.Handler.dispatchMessage(Handler.java:102)
E/AndroidRuntime(26839): at android.os.Looper.loopOnce(Looper.java:226)
E/AndroidRuntime(26839): at android.os.Looper.loop(Looper.java:313)
E/AndroidRuntime(26839): at android.app.ActivityThread.main(ActivityThread.java:8762)
E/AndroidRuntime(26839): at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(26839): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:604)
E/AndroidRuntime(26839): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1067)

Hello, @Alan_Cook.

Which version of backendless-sdk are you using?
Error appears only in release version?

Regards, Nikita.

Which version of backendless-sdk are you using?

backendless_sdk: ^7.3.7

Error appears only in release version?

Yes

So I tried you alpha version with a lot of dependency_overrides

dependencies:
flutter:
sdk: flutter
…

#backendless_sdk: ^7.3.7
backendless_sdk: ^8.0.0-alpha.23

dependency_overrides:
http: ‘0.13.4’
uuid: ‘3.0.6’
logger: ‘1.1.0’
connectivity_plus: ‘2.0.2’

This kicked off a whole list of Dart Analysis warnings

error: The expression doesn’t evaluate to a function, so it can’t be invoked. (invocation_of_non_function_expression at [alona_beach_guide] lib/common_code/app/app_initializer.dart:73)
error: The method ‘setUrl’ isn’t defined for the type ‘Backendless’. (undefined_method at [alona_beach_guide] lib/common_code/app/app_initializer.dart:74)
error: Too many positional arguments: 0 expected, but 1 found. (extra_positional_arguments_could_be_named at [alona_beach_guide] lib/common_code/support/instances/guide_data_instance.dart:389)
error: The getter ‘counters’ isn’t defined for the type ‘Backendless’. (undefined_getter at [alona_beach_guide] lib/common_code/support/instances/guide_data_instance.dart:485)
error: Undefined class ‘IAtomic’. (undefined_class at [alona_beach_guide] lib/common_code/support/instances/guide_data_instance.dart:490)
error: Too many positional arguments: 0 expected, but 1 found. (extra_positional_arguments_could_be_named at [alona_beach_guide] lib/common_code/support/instances/guide_data_instance.dart:514)
error: Too many positional arguments: 0 expected, but 1 found. (extra_positional_arguments_could_be_named at [alona_beach_guide] lib/common_code/support/instances/guide_data_instance.dart:590)
error: The getter ‘counters’ isn’t defined for the type ‘Backendless’. (undefined_getter at [alona_beach_guide] lib/common_code/ui/views/support_views/guide_entry_view/main/guide_entry_view_model.dart:93)
error: Undefined class ‘IAtomic’. (undefined_class at [alona_beach_guide] lib/common_code/ui/views/support_views/guide_entry_view/main/guide_entry_view_model.dart:99)
warning: The operand can’t be null, so the condition is always ‘true’. (unnecessary_null_comparison at [alona_beach_guide] lib/common_code/ui/views/support_views/guide_entry_view/main/guide_entry_view_model.dart:101)

Hello, @Alan_Cook.

I recommend you using the newer version of backendless-sdk. 8.0.0-alpha.23.
Because the older version of sdk will not be supported soon.

I will check into this issue.

Regards, Nikita.

We that is not good when do you plan on supporting counters in 8.0? Look at all the functions I am, currently using that are not supported, do yo plan on supporting counters in 8.0? How are is 8.0 form being a actual release?

error: The expression doesn’t evaluate to a function, so it can’t be invoked. (invocation_of_non_function_expression at [alona_beach_guide] lib/common_code/app/app_initializer.dart:73)
error: The method ‘setUrl’ isn’t defined for the type ‘Backendless’. (undefined_method at [alona_beach_guide] lib/common_code/app/app_initializer.dart:74)
error: Too many positional arguments: 0 expected, but 1 found. (extra_positional_arguments_could_be_named at [alona_beach_guide] lib/common_code/support/instances/guide_data_instance.dart:389)
error: The getter ‘counters’ isn’t defined for the type ‘Backendless’. (undefined_getter at [alona_beach_guide] lib/common_code/support/instances/guide_data_instance.dart:485)
error: Undefined class ‘IAtomic’. (undefined_class at [alona_beach_guide] lib/common_code/support/instances/guide_data_instance.dart:490)
error: Too many positional arguments: 0 expected, but 1 found. (extra_positional_arguments_could_be_named at [alona_beach_guide] lib/common_code/support/instances/guide_data_instance.dart:514)
error: Too many positional arguments: 0 expected, but 1 found. (extra_positional_arguments_could_be_named at [alona_beach_guide] lib/common_code/support/instances/guide_data_instance.dart:590)
error: The getter ‘counters’ isn’t defined for the type ‘Backendless’. (undefined_getter at [alona_beach_guide] lib/common_code/ui/views/support_views/guide_entry_view/main/guide_entry_view_model.dart:93)
error: Undefined class ‘IAtomic’. (undefined_class at [alona_beach_guide] lib/common_code/ui/views/support_views/guide_entry_view/main/guide_entry_view_model.dart:99)
warning: The operand can’t be null, so the condition is always ‘true’. (unnecessary_null_comparison at [alona_beach_guide] lib/common_code/ui/views/support_views/guide_entry_view/main/guide_entry_view_model.dart:101)

@Alan_Cook I will add counters to SDK as soon as possible. It was my mistake, I missed the counters in the new version of the SDK.
Many features in 8.0.0 can be called slightly differently. For example, the Backendless.setUrl(value) function is replaced with property:
Backendless.url = value.

Ok, that is good to hear, as counters are a main part of our application since the issue is only on. release build I will keep developing with the 7.3.7, if you can let me know when the beta has counters. working and I will retest everything, we are at least a month away from needing a release build.

Ok, @Alan_Cook.

Hello, @Alan_Cook.

This feature added to 8.0.0-alpha.24 version.

Regards, Nikita.

I am still testing but at the moment it look like it is all working.

1 Like