nativescript-community / ui-label

Alternative to the built-in NativeScript Label but with better performance and additional features such as HTML rendering and more.
Apache License 2.0
19 stars 7 forks source link

JUSTIFICATION_MODE_NONE does not exist on Android API level 25 #11

Closed jarmani closed 9 months ago

jarmani commented 2 years ago

Which platform(s) does your issue occur on?

Android 7.1.X (API level 25)

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

JUSTIFICATION_MODE_INTER_WORD and JUSTIFICATION_MODE_NONE appeared in API level 26 but the code check for level >= 25 :

[textAlignmentProperty.setNative](value: CoreTypes.TextAlignmentType) {
        const view = this.nativeTextViewProtected;
        if (android.os.Build.VERSION.SDK_INT >= 25) {
            if ((value as any) === 'justify') {
                view.setJustificationMode(android.text.Layout.JUSTIFICATION_MODE_INTER_WORD);
            } else {
                view.setJustificationMode(android.text.Layout.JUSTIFICATION_MODE_NONE);
                view.setGravity(getHorizontalGravity(value) | getVerticalGravity(this.verticalTextAlignment));
            }
        } else {
            view.setGravity(getHorizontalGravity(value) | getVerticalGravity(this.verticalTextAlignment));
        }
    }

causing the following error :

com.tns.NativeScriptException: Calling js method onCreateView failed Error: java.lang.NoSuchFieldError: no "I" field "JUSTIFICATION_MODE_NONE" in class "Landroid/text/Layout;" or its superclasses

farfromrefug commented 2 years ago

@jarmani thanks for the report. fixed in 1.2.2