ProgressNS / nativescript-ui-feedback

This repository is used for customer feedback regarding Telerik UI for NativeScript. The issues system here is used by customers who want to submit their feature requests or vote for existing ones.
Other
115 stars 21 forks source link

Android 'setForceDarkAllowed' error on RadCartesianChart #1435

Closed CatchABus closed 4 years ago

CatchABus commented 4 years ago

Tell us about the problem

RadCartesianChart throws the following exception when used with Android API 29 and higher.

System.err: An uncaught Exception occurred on "main" thread.
System.err: Calling js method onCreateView failed
System.err: TypeError: this._android.setForceDarkAllowed is not a function
System.err:
System.err: StackTrace:
System.err: push.../node_modules/nativescript-ui-chart/ui-chart.js.RadCartesianChart.initNativeView(file: node_modules\nativescript-ui-chart\ui-chart.android.js:345:0)
System.err:     at push.../node_modules/@nativescript/core/ui/core/view-base/view-base.js.ViewBase.setNativeView(file: node_modules\@nativescript\core\ui\core\view-base\view-base.js:567:0)
System.err:     at push.../node_modules/@nativescript/core/ui/core/view-base/view-base.js.ViewBase._setupUI(file: node_modules\@nativescript\core\ui\core\view-base\view-base.js:546:0)
System.err:     at (file: node_modules\@nativescript\core\ui\core\view-base\view-base.js:553:0)
System.err:     at push.../node_modules/@nativescript/core/ui/layouts/layout-base-common.js.LayoutBaseCommon.eachChildView(file: node_modules\@nativescript\core\ui\layouts\layout-base-common.js:125:0)
System.err:     at push.../node_modules/@nativescript/core/ui/core/view/view-common.js.ViewCommon.eachChild(file: node_modules\@nativescript\core\ui\core\view\view-common.js:925:0)
System.err:     at push.../node_modules/@nativescript/core/ui/core/view-base/view-base.js.ViewBase._setupUI(file: node_modules\@nativescript\core\ui\core\view-base\view-base.js:552:0)
System.err:     at push.../node_modules/@nativescript/core/ui/core/view-base/view-base.js.ViewBase._setupAsRootView(file: node_modules\@nativescript\core\ui\core\view-base\view-base.js:499:0)
System.err:     at push.../node_modules/@nativescript/core/ui/core/view/view-common.js.ViewCommon._setupAsRootView(file: node_modules\@nativescript\core\ui\core\view\view-common.js:170:0)
System.err:     at DialogFragmentImpl.onCreateView(file: node_modules\@nativescript\core\ui\core\view\view.android.js:130:0)
System.err:     at com.tns.Runtime.callJSMethodNative(Native Method)
System.err:     at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1286)
System.err:     at com.tns.Runtime.callJSMethodImpl(Runtime.java:1173)
System.err:     at com.tns.Runtime.callJSMethod(Runtime.java:1160)
System.err:     at com.tns.Runtime.callJSMethod(Runtime.java:1138)
System.err:     at com.tns.Runtime.callJSMethod(Runtime.java:1134)
System.err:     at com.tns.gen.androidx.fragment.app.DialogFragment_vendor_20079_32_DialogFragmentImpl.onCreateView(DialogFragment_vendor_20079_32_DialogFragmentImpl.java:42)
System.err:     at androidx.fragment.app.Fragment.performCreateView(Fragment.java:2439)
System.err:     at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManager.java:1460)
System.err:     at androidx.fragment.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1784)
System.err:     at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManager.java:1852)
System.err:     at androidx.fragment.app.BackStackRecord.executeOps(BackStackRecord.java:802)
System.err:     at androidx.fragment.app.FragmentManagerImpl.executeOps(FragmentManager.java:2625)
System.err:     at androidx.fragment.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2411)
System.err:     at androidx.fragment.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManager.java:2366)
System.err:     at androidx.fragment.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2273)
System.err:     at androidx.fragment.app.FragmentManagerImpl$1.run(FragmentManager.java:733)
System.err:     at android.os.Handler.handleCallback(Handler.java:883)
System.err:     at android.os.Handler.dispatchMessage(Handler.java:100)
System.err:     at android.os.Looper.loop(Looper.java:224)
System.err:     at android.app.ActivityThread.main(ActivityThread.java:7509)
System.err:     at java.lang.reflect.Method.invoke(Native Method)
System.err:     at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539)
System.err:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:995)

Which platform(s) does your issue occur on?

Android API 29

Please provide the following version numbers that your issue occurs with:

Please tell us how to recreate the issue in as much detail as possible.

  1. Start the application
  2. Navigate to a page that contains a chart
  3. Exception is thrown

Is there code involved? If so, please share the minimal amount of code needed to recreate the problem.

I found this code block inside ui-chart.android.js It looks like setForceDarkAllowed calls are invalid.

RadPieChart.prototype.initNativeView = function () {
        if (getSdkApiLevel() && getSdkApiLevel() >= 29) {
            this._android.setForceDarkAllowed(false);
            this.nativeViewProtected.setForceDarkAllowed(false);
        }
        if (applicationModule.systemAppearance() === enums_1.SystemAppearance.dark && this.legend) {
            this.legend.updateLegendTitle();
        }
    };
RadCartesianChart.prototype.initNativeView = function () {
        if (getSdkApiLevel() && getSdkApiLevel() >= 29) {
            this._android.setForceDarkAllowed(false);
            this.nativeViewProtected.setForceDarkAllowed(false);
        }
        if (applicationModule.systemAppearance() === enums_1.SystemAppearance.dark && this.legend) {
            this.legend.updateLegendTitle();
        }
    };

Our apps make a lot of use of RadCartesianCharts and this issue is preventing clients with new android phones to use them. Hope it's solved soon.

CatchABus commented 4 years ago

Okay, it seems that Android SDK 29 solved this issue. Still, older sdk versions should not be limited like this. Perhaps, checking if method exists would solve this problem.

rob4226 commented 3 years ago

I just ran into the same problem but easily fixed it by installing the latest Android SDK platform by running sdkmanager --install "build-tools;30.0.3" If you follow the NativeScript setup instructions it will have you install version 28 but you should always build with the latest platform to support the newest devices. Older devices will still run fine even with using the latest SDK to build the app. The above error results because you need at least SDK 29 to support the setForceDarkAllowed.