Android Question JavaObject should be initialized

Discussion in 'Android Questions' started by Dianzoa, Jun 1, 2019.

  1. Dianzoa

    Dianzoa Active Member Licensed User

    I got this error after trying to use SpaceNavigation lib and add appcompatActivity, also the SDK manager install some things after adding those libs. But now I got this error when calling this code, before it worked well. Maybe the actionbar can not be used with the SpaceNavigation bar?

    Code:
    Sub SetActionBarColor(Color As Int)
        
    Dim jo As JavaObject
        
        jo.InitializeContext
        
    Dim cd As ColorDrawable
        cd.Initialize(Color, 
    0)
        jo.RunMethodJO(
    "getActionBar"Null).RunMethod("setBackgroundDrawable"Array(cd))
    This is the LOG
    Registo conectado a: HUAWEI DRA-LX3
    --------- beginning of crash
    --------- beginning of main
    *** Service (starter) Create ***
    ** Service (starter) Start **
    ** Activity (main) Create, isFirst = true **
    25
    %
    A
    Santa Clara Catholic College,asuncion
    ** Activity (main) Resume **
    ** Activity (main) Pause, UserClosed = true **
    ** Activity (menu_principal) Create, isFirst = true **
    Error occurred on line: 0 (menu_principal)
    java.lang.RuntimeException: Object should first be initialized (JavaObject).
    at anywheresoftware.b4a.AbsObjectWrapper.getObject(AbsObjectWrapper.java:50)
    at anywheresoftware.b4j.object.JavaObject.getCurrentClass(JavaObject.java:258)
    at anywheresoftware.b4j.object.JavaObject.RunMethod(JavaObject.java:118)
    at com.anzoategui.enviapycliente.menu_principal._setactionbarcolor(menu_principal.java:397)
    at com.anzoategui.enviapycliente.menu_principal._activity_create(menu_principal.java:370)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:738)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:360)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:260)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
    at com.anzoategui.enviapycliente.menu_principal.afterFirstLayout(menu_principal.java:104)
    at com.anzoategui.enviapycliente.menu_principal.access$000(menu_principal.java:17)
    at com.anzoategui.enviapycliente.menu_principal$WaitForLayout.run(menu_principal.java:82)
    at android.os.Handler.handleCallback(Handler.java:795)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:166)
    at android.app.ActivityThread.main(ActivityThread.java:6861)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:450)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)
    ** Activity (menu_principal) Resume **
     
  2. DonManfred

    DonManfred Expert Licensed User

    does not seem to be related to SpaceNavigation
    SpaceNavigation is not a replacement for an ActionBar.
     
  3. Dianzoa

    Dianzoa Active Member Licensed User

    I think that too, but if I add the javaobject to the simplest example of space navigation, it gives the same error. I use the example that comes with the lib

    Edit: Using 8.50v
     
    Last edited: Jun 1, 2019
  4. DonManfred

    DonManfred Expert Licensed User

    sure. You can not get a ActionBar from an Object where there is no actionbar inside.
     
  5. Dianzoa

    Dianzoa Active Member Licensed User

    Ohh yeah, sure, but the error I think has nothing to do with the bar itself, but the javaobject instantiation or something, cause in my app I have the action bar, and the error is in the same line of code in both project
    Edit: Maybe the appcompat makes a difference? I didn't use that before trying space lib. I don't have the code right here. It's 4:10am here, I will make more tests after some sleep. Cheers.
     
    Last edited: Jun 1, 2019
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice