android - App crashes when trying to add a new CyborgController using createNewLayerBuilder() -
this i'm doing in application class:
@override public void oncreate() { super.oncreate(); cyborgbuilder.startcyborg(new cyborgconfiguration(this, r.layout.cyborgview__auto_reply, basicmodulepack.class)); }
this how cyborgview__auto_reply.xml looks like:
<?xml version="1.0" encoding="utf-8"?> <com.nu.art.cyborg.core.cyborgview xmlns:android="http://schemas.android.com/apk/res/android" xmlns:cyborg="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" cyborg:controller="com.hedshafran.autoreply.controllers.controller_permissionscreen" cyborg:tag="controller_permission"/>
and i'm doing in controller_permissionscreen class causes crash:
createnewlayerbuilder().setcontrollertype(controller_mainscreen.class).setlayoutid(r.layout.controller__main_screen).build();
that causes crash, looks this:
e/androidruntime: fatal exception: main process: com.hedshafran.autoreply, pid: 17910 java.lang.runtimeexception: unable resume activity {com.hedshafran.autoreply/com.nu.art.cyborg.core.cyborgactivity}: java.lang.nullpointerexception: attempt invoke virtual method 'com.nu.art.cyborg.core.cyborgstackcontroller$stacklayerbuilder com.nu.art.cyborg.core.cyborgstackcontroller.createlayerbuilder()' on null object reference @ android.app.activitythread.performresumeactivity(activitythread.java:3791) @ android.app.activitythread.handleresumeactivity(activitythread.java:3832) @ android.app.activitythread$h.handlemessage(activitythread.java:1681) @ android.os.handler.dispatchmessage(handler.java:102) @ android.os.looper.loop(looper.java:154) @ android.app.activitythread.main(activitythread.java:6682) @ java.lang.reflect.method.invoke(native method) @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:1520) @ com.android.internal.os.zygoteinit.main(zygoteinit.java:1410) caused by: java.lang.nullpointerexception: attempt invoke virtual method 'com.nu.art.cyborg.core.cyborgstackcontroller$stacklayerbuilder com.nu.art.cyborg.core.cyborgstackcontroller.createlayerbuilder()' on null object reference @ com.nu.art.cyborg.core.cyborgcontroller.createnewlayerbuilder(cyborgcontroller.java:506) @ com.hedshafran.autoreply.controllers.controller_permissionscreen.onresume(controller_permissionscreen.java:35) @ com.nu.art.cyborg.core.cyborgcontroller.dispatchlifecycleevent(cyborgcontroller.java:270) @ com.nu.art.cyborg.core.cyborgactivitybridgeimpl.dispatchlifecycleevent(cyborgactivitybridgeimpl.java:476) @ com.nu.art.cyborg.core.cyborgactivitybridgeimpl.onresume(cyborgactivitybridgeimpl.java:213) @ com.nu.art.cyborg.core.cyborgactivity.onresume(cyborgactivity.java:155) @ android.app.instrumentation.callactivityonresume(instrumentation.java:1277) @ android.app.activity.performresume(activity.java:7088) @ android.app.activitythread.performresumeactivity(activitythread.java:3768) @ android.app.activitythread.handleresumeactivity(activitythread.java:3832) @ android.app.activitythread$h.handlemessage(activitythread.java:1681) @ android.os.handler.dispatchmessage(handler.java:102) @ android.os.looper.loop(looper.java:154) @ android.app.activitythread.main(activitythread.java:6682) @ java.lang.reflect.method.invoke(native method) @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:1520) @ com.android.internal.os.zygoteinit.main(zygoteinit.java:1410)
how can avoid crash , open new cyborgcontroller proper way?
your cyborgview__auto_reply.xml should utilize cyborgstackconroller contain controller_permissionscreen, so:
<?xml version="1.0" encoding="utf-8"?> <com.nu.art.cyborg.core.cyborgview xmlns:android="http://schemas.android.com/apk/res/android" xmlns:cyborg="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/cv_rootstack" cyborg:controller="com.nu.art.cyborg.core.cyborgstackcontroller" cyborg:rootcontroller="com.hedshafran.autoreply.controllers.controller_permissionscreen" cyborg:roottag="controller_permission" cyborg:tag="rootstack" />
point can use createnewlayerbuilder api if controller calls method in stack. otherwise use getcontrollerbyid(r.id.cv_rootstack) , create new layer builder.
wiki
Comments
Post a Comment