NativeScript / nativescript-angular

Integrating NativeScript with Angular
http://docs.nativescript.org/angular/tutorial/ng-chapter-0
Apache License 2.0
1.21k stars 241 forks source link

java.lang.NoSuchFieldError: no "I" field SYSTEM_UI_FLAG_LIGHT_STATUS_BAR on Android platform #1357

Closed francisrod01 closed 6 years ago

francisrod01 commented 6 years ago

I'm trying to modify status bar color on Android but the android.view.View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR doesn't exists.

This is mentioned on the NS Angular doc

https://docs.nativescript.org/angular/ui/theme#android

The tns doctor output:

    "dependencies": {
        "@angular/animations": "~5.2.0",
        "@angular/common": "~5.2.0",
        "@angular/compiler": "~5.2.0",
        "@angular/core": "~5.2.0",
        "@angular/forms": "~5.2.0",
        "@angular/http": "~5.2.0",
        "@angular/platform-browser": "~5.2.0",
        "@angular/platform-browser-dynamic": "~5.2.0",
        "@angular/router": "~5.2.0",
        "nativescript-angular": "^5.2.0",
        "nativescript-checkbox": "^3.0.3",
        "nativescript-theme-core": "~1.0.4",
        "reflect-metadata": "~0.1.8",
        "rxjs": "~5.5.2",
        "tns-core-modules": "^4.0.1",
        "zone.js": "~0.8.2"
    },
    "devDependencies": {
        "babel-traverse": "6.26.0",
        "babel-types": "6.26.0",
        "babylon": "6.18.0",
        "lazy": "1.0.11",
        "nativescript": "^4.0.2",
        "nativescript-dev-sass": "^1.5.0",
        "nativescript-dev-typescript": "~0.7.0",
        "typescript": "^2.6.2"
    }
✔ Getting environment information 

✔ Your ANDROID_HOME environment variable is set and points to correct directory.
✔ Your adb from the Android SDK is correctly installed.
✔ The Android SDK is installed.
✔ A compatible Android SDK for compilation is found.
✔ Javac is installed and is configured properly.
✔ The Java Development Kit (JDK) is installed and is configured properly.
✔ Local builds for iOS can be executed only on a macOS system. To build for iOS on a different operating system, you can use the NativeScript cloud infrastructure.
No issues were detected.
✔ Getting NativeScript components versions information...
⚠ Update available for component nativescript. Your current version is 4.0.2 and the latest available version is 4.1.0.
⚠ Update available for component tns-core-modules. Your current version is 4.0.1 and the latest available version is 4.1.0.
⚠ Update available for component tns-android. Your current version is 4.0.1 and the latest available version is 4.1.1.
✖ Component tns-ios is not installed.

Error output:

ns-renderer: ERROR BOOTSTRAPPING ANGULAR
JS: ns-renderer: java.lang.NoSuchFieldError: no "I" field "SYSTEM_UI_FLAG_LIGHT_STATUS_BAR" in class "Landroid/view/View;" or its superclasses
JS:     com.tns.Runtime.callJSMethodNative(Native Method)
JS:     com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1088)
JS:     com.tns.Runtime.callJSMethodImpl(Runtime.java:970)
JS:     com.tns.Runtime.callJSMethod(Runtime.java:957)
JS:     com.tns.Runtime.callJSMethod(Runtime.java:941)
JS:     com.tns.Runtime.callJSMethod(Runtime.java:933)
JS:     com.tns.gen.java.lang.Object_frame_29_36_AttachListener.onViewAttachedToWindow(Object_frame_29_36_AttachListener.java:12)
JS:     android.view.View.dispatchAttachedToWindow(View.java:13536)
JS:     android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2688)
JS:     android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2695)
JS:     android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2695)
JS:     android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2695)
JS:     android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1299)
JS:     android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1061)
JS:     android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5885)
JS:     android.view.Choreographer$CallbackRecord.run(Choreographer.java:767)
JS:     android.view.Choreographer.doCallbacks(Choreographer.java:580)
JS:     android.view.Choreographer.doFrame(Choreographer.java:550)
JS:     android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:753)
JS:     android.os.Handler.handleCallback(Handler.java:739)
JS:     android.os.Handler.dispatchMessage(Handler.java:95)
JS:     android.os.Looper.loop(Looper.java:135)
JS:     android.app.ActivityThread.main(ActivityThread.java:5254)
JS:     java.lang.reflect.Method.invoke(Native Method)
JS:     java.lang.reflect.Method.invoke(Method.java:372)
JS:     com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
JS:     com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
JS: 
tsonevn commented 6 years ago

Hi @francisrod01, In case you need to change the colour of the StatusBar, you can use the nativescript-statusbar. The plugin provides support for this type of functionality. You can also review its demo here.

francisrod01 commented 6 years ago

Thank's @tsonevn ! I solved using a following change to nativescript-angular: 5.3.0

https://github.com/NativeScript/nativescript-angular/blob/master/CHANGELOG.md

I solved it change using a window.setStatusBarColor() instead View flag as mentioned here:

NS discourse - java.lang.NoSuchFieldError about system UI light status bar on Android platform