Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ANDROID] [Alloy] Can't load Alloy views on Android. #21

Closed
atypical opened this issue Nov 7, 2013 · 2 comments
Closed

[ANDROID] [Alloy] Can't load Alloy views on Android. #21

atypical opened this issue Nov 7, 2013 · 2 comments

Comments

@atypical
Copy link

atypical commented Nov 7, 2013

To start, I believe this stems from issue #2 - but that thread is getting long and this is explicitly about Android. I've solved #2 in my app and posted my solution on #20.

I'm on the latest Ti / Alloy / Android builds.

On Android, the module doesn't seem to be able to load in Alloy views, below is how I'm calling the drawer with its options, the iOS implementation works brilliantly:

if(Titanium.Platform.name == 'android'){

    var NappDrawerModule = require('dk.napp.drawer');

    drawer = NappDrawerModule.createDrawer({
            fullscreen:false, 
            leftWindow: Alloy.createController("leftDrawer").getView(),
            centerWindow: Alloy.createController("centerView").getView(),
            fading: 0.2, // 0-1
            parallaxAmount: 0.2, //0-1
            shadowWidth:"40dp", 
            leftDrawerWidth: 240,
            animationMode: NappDrawerModule.ANIMATION_PARALLAX_FACTOR_7,
            closeDrawerGestureMode: NappDrawerModule.MODE_MARGIN,
            openDrawerGestureMode: NappDrawerModule.MODE_ALL
    });
    drawer.open();

};

I'm only using Views in my leftDrawer.xml and centerView.xml files, like so:

<Alloy>
    <View class="container" id="contID">
        <TableView id="tableID"></TableView>    
    </View>
</Alloy>

The error I get from ADB is as follows, the app just crashes on load, as soon as I try to load an Alloy view:

[WARN][dalvikvm(  719)] threadid=1: thread exiting with uncaught exception (group=0x40a71930)
[ERROR][TiApplication(  719)] (main) [3894,5135] Sending event: exception on thread: main msg:java.lang.RuntimeException: Unable to start activity ComponentInfo{com.atypical.enfold/org.appcelerator.titanium.TiActivity}: java.lang.NumberFormatException: Unable to convert null; Titanium 3.1.3,2013/09/18 12:01,222f4d1
[ERROR][TiApplication(  719)] java.lang.RuntimeException: Unable to start activity ComponentInfo{com.atypical.enfold/org.appcelerator.titanium.TiActivity}: java.lang.NumberFormatException: Unable to convert null
[ERROR][TiApplication(  719)]   at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
[ERROR][TiApplication(  719)]   at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
[ERROR][TiApplication(  719)]   at android.app.ActivityThread.access$600(ActivityThread.java:141)
[ERROR][TiApplication(  719)]   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
[ERROR][TiApplication(  719)]   at android.os.Handler.dispatchMessage(Handler.java:99)
[ERROR][TiApplication(  719)]   at android.os.Looper.loop(Looper.java:137)
[ERROR][TiApplication(  719)]   at android.app.ActivityThread.main(ActivityThread.java:5041)
[ERROR][TiApplication(  719)]   at java.lang.reflect.Method.invokeNative(Native Method)
[ERROR][TiApplication(  719)]   at java.lang.reflect.Method.invoke(Method.java:511)
[ERROR][TiApplication(  719)]   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
[ERROR][TiApplication(  719)]   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
[ERROR][TiApplication(  719)]   at dalvik.system.NativeStart.main(Native Method)
[ERROR][TiApplication(  719)] Caused by: java.lang.NumberFormatException: Unable to convert null
[ERROR][TiApplication(  719)]   at org.appcelerator.titanium.util.TiConvert.toInt(TiConvert.java:407)
[ERROR][TiApplication(  719)]   at dk.napp.drawer.Drawer.processProperties(Drawer.java:344)
[ERROR][TiApplication(  719)]   at org.appcelerator.kroll.KrollProxy.setModelListener(KrollProxy.java:1162)
[ERROR][TiApplication(  719)]   at dk.napp.drawer.DrawerProxy.windowCreated(DrawerProxy.java:145)
[ERROR][TiApplication(  719)]   at org.appcelerator.titanium.TiActivityWindows.windowCreated(TiActivityWindows.java:32)
[ERROR][TiApplication(  719)]   at org.appcelerator.titanium.TiBaseActivity.windowCreated(TiBaseActivity.java:437)
[ERROR][TiApplication(  719)]   at org.appcelerator.titanium.TiBaseActivity.onCreate(TiBaseActivity.java:512)
[ERROR][TiApplication(  719)]   at org.appcelerator.titanium.TiActivity.onCreate(TiActivity.java:18)
[ERROR][TiApplication(  719)]   at android.app.Activity.performCreate(Activity.java:5104)
[ERROR][TiApplication(  719)]   at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
[ERROR][TiApplication(  719)]   at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
[ERROR][TiApplication(  719)]   ... 11 more
[ERROR][AndroidRuntime(  719)] FATAL EXCEPTION: main
[ERROR][AndroidRuntime(  719)] java.lang.RuntimeException: Unable to start activity ComponentInfo{com.atypical.enfold/org.appcelerator.titanium.TiActivity}: java.lang.NumberFormatException: Unable to convert null
[ERROR][AndroidRuntime(  719)]  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
[ERROR][AndroidRuntime(  719)]  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
[ERROR][AndroidRuntime(  719)]  at android.app.ActivityThread.access$600(ActivityThread.java:141)
[ERROR][AndroidRuntime(  719)]  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
[ERROR][AndroidRuntime(  719)]  at android.os.Handler.dispatchMessage(Handler.java:99)
[ERROR][AndroidRuntime(  719)]  at android.os.Looper.loop(Looper.java:137)
[ERROR][AndroidRuntime(  719)]  at android.app.ActivityThread.main(ActivityThread.java:5041)
[ERROR][AndroidRuntime(  719)]  at java.lang.reflect.Method.invokeNative(Native Method)
[ERROR][AndroidRuntime(  719)]  at java.lang.reflect.Method.invoke(Method.java:511)
[ERROR][AndroidRuntime(  719)]  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
[ERROR][AndroidRuntime(  719)]  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
[ERROR][AndroidRuntime(  719)]  at dalvik.system.NativeStart.main(Native Method)
[ERROR][AndroidRuntime(  719)] Caused by: java.lang.NumberFormatException: Unable to convert null
[ERROR][AndroidRuntime(  719)]  at org.appcelerator.titanium.util.TiConvert.toInt(TiConvert.java:407)
[ERROR][AndroidRuntime(  719)]  at dk.napp.drawer.Drawer.processProperties(Drawer.java:344)
[ERROR][AndroidRuntime(  719)]  at org.appcelerator.kroll.KrollProxy.setModelListener(KrollProxy.java:1162)
[ERROR][AndroidRuntime(  719)]  at dk.napp.drawer.DrawerProxy.windowCreated(DrawerProxy.java:145)
[ERROR][AndroidRuntime(  719)]  at org.appcelerator.titanium.TiActivityWindows.windowCreated(TiActivityWindows.java:32)
[ERROR][AndroidRuntime(  719)]  at org.appcelerator.titanium.TiBaseActivity.windowCreated(TiBaseActivity.java:437)
[ERROR][AndroidRuntime(  719)]  at org.appcelerator.titanium.TiBaseActivity.onCreate(TiBaseActivity.java:512)
[ERROR][AndroidRuntime(  719)]  at org.appcelerator.titanium.TiActivity.onCreate(TiActivity.java:18)
[ERROR][AndroidRuntime(  719)]  at android.app.Activity.performCreate(Activity.java:5104)
[ERROR][AndroidRuntime(  719)]  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
[ERROR][AndroidRuntime(  719)]  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
[ERROR][AndroidRuntime(  719)]  ... 11 more

Am I just being daft or missing something vital? I've poured over the Android example with no luck and would really appreciate any guidance as I know Obj-C much better then Java.

Thanks for the badass module @viezel !

Cheers,
//MD

@atypical
Copy link
Author

atypical commented Nov 8, 2013

Facepalm

Apparently I'm an idiot and had a bad option in my set up, should be:

if(Titanium.Platform.name == 'android'){

    var NappDrawerModule = require('dk.napp.drawer');

    drawer = NappDrawerModule.createDrawer({
            fullscreen:false, 
            leftWindow: Alloy.createController("leftDrawer").getView(),
            centerWindow: Alloy.createController("centerView").getView(),
            fading: 0.2, // 0-1
            parallaxAmount: 0.2, //0-1
            shadowWidth:"40dp", 
            leftDrawerWidth: 240,
                animationMode: NappDrawerModule.ANIMATION_NONE,
                closeDrawerGestureMode: NappDrawerModule.MODE_MARGIN,
                openDrawerGestureMode: NappDrawerModule.MODE_ALL
    });
    drawer.open();

};

And then we're good to go. Closing. Apologies for the dumb issue.

@atypical atypical closed this as completed Nov 8, 2013
@jayeshIT
Copy link

SDK 3.3.0 add NavigationBar means ActionBar in android case event i provide TSS in drawer with navBarHidden: true, . it was not added in case of 3.2.3.
How to resolve?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants