簡體   English   中英

當我嘗試在Android模擬器上運行Titan App時出現錯誤

[英]error when I try to run titanium app on android emulator

我已經在Titanium Studio中構建了一個應用程序,並且已經在iphone模擬器和iphone設備上運行了該應用程序,並且運行良好。 但是,當我嘗試在android模擬器或android設備上運行它時,它崩潰了。

我收到以下錯誤:

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.smartcrew/org.appcelerator.titanium.TiActivity}: java.lang.IllegalStateException: call to getView on a Window
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
at android.app.ActivityThread.startActivityNow(ActivityThread.java:2503)
at android.app.LocalActivityManager.moveToState(LocalActivityManager.java:127)at android.app.LocalActivityManager.startActivity(LocalActivityManager.java:339)
at android.widget.TabHost$IntentContentStrategy.getContentView(TabHost.java:651)
at android.widget.TabHost.setCurrentTab(TabHost.java:323)
at android.widget.TabHost.addTab(TabHost.java:213)
at ti.modules.titanium.ui.widget.TiUITabGroup.addTab(TiUITabGroup.java:69)
at ti.modules.titanium.ui.TabGroupProxy.addTabToGroup(TabGroupProxy.java:192)
at ti.modules.titanium.ui.TabGroupProxy.handlePostOpen(TabGroupProxy.java:275)
at ti.modules.titanium.ui.TabGroupProxy.handleMessage(TabGroupProxy.java:91)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:4627)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
at dalvik.system.NativeStart.main(Native Method)

Caused by: java.lang.IllegalStateException: call to getView on a Window
at ti.modules.titanium.ui.WindowProxy.getView(WindowProxy.java:63)
at org.appcelerator.titanium.proxy.TiViewProxy.realizeViews(TiViewProxy.java:384)
at ti.modules.titanium.ui.WindowProxy$1.windowCreated(WindowProxy.java:117)
at org.appcelerator.titanium.TiActivityWindows.windowCreated(TiActivityWindows.java:31)
at org.appcelerator.titanium.TiBaseActivity.windowCreated(TiBaseActivity.java:271)
at org.appcelerator.titanium.TiBaseActivity.onCreate(TiBaseActivity.java:298)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)

E/AndroidRuntime(  246): FATAL EXCEPTION: main
E/AndroidRuntime(  246): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.smartcrew/org.appcelerator.titanium.TiActivity}: java.lang.IllegalStateException: call to getView on a Window
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
at android.app.ActivityThread.startActivityNow(ActivityThread.java:2503)
at android.app.LocalActivityManager.moveToState(LocalActivityManager.java:127)
at android.app.LocalActivityManager.startActivity(LocalActivityManager.java:339)
at android.widget.TabHost$IntentContentStrategy.getContentView(TabHost.java:651)
at android.widget.TabHost.setCurrentTab(TabHost.java:323)
at android.widget.TabHost.addTab(TabHost.java:213)
at ti.modules.titanium.ui.widget.TiUITabGroup.addTab(TiUITabGroup.java:69)
at ti.modules.titanium.ui.TabGroupProxy.addTabToGroup(TabGroupProxy.java:192)
at ti.modules.titanium.ui.TabGroupProxy.handlePostOpen(TabGroupProxy.java:275)
at ti.modules.titanium.ui.TabGroupProxy.handleMessage(TabGroupProxy.java:91)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:4627)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
at dalvik.system.NativeStart.main(Native Method)

Caused by: java.lang.IllegalStateException: call to getView on a Window
at ti.modules.titanium.ui.WindowProxy.getView(WindowProxy.java:63)
at org.appcelerator.titanium.proxy.TiViewProxy.realizeViews(TiViewProxy.java:384)
at ti.modules.titanium.ui.WindowProxy$1.windowCreated(WindowProxy.java:117)
at org.appcelerator.titanium.TiActivityWindows.windowCreated(TiActivityWindows.java:31)
at org.appcelerator.titanium.TiBaseActivity.windowCreated(TiBaseActivity.java:271)
at org.appcelerator.titanium.TiBaseActivity.onCreate(TiBaseActivity.java:298)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)

有誰知道出什么問題了嗎? 我會發布一些代碼,但是太長了,我不知道是哪個部分導致了此問題。

等待您的答案,謝謝!

// this sets the background color of the master UIView (when there are no windows/tab groups on it)


//Ti.include('Window1.js');
Titanium.UI.setBackgroundColor('#000');

// create tab group


var placeHolders = [{left:10, top:10, width:20, height:20, bgColor:"#FFF", bgAlpha:0.5, img:""},
                    {left:30, top:20, width:50, height:50, bgColor:Math.random * 0xFFFFFF, bgAlpha:0.5, img:""},
                    {left:60, top:60, width:20, height:20, bgColor:Math.random * 0xFFFFFF, bgAlpha:0.5, img:""},
                    {left:100, top:20, width:20, height:20, bgColor:Math.random * 0xFFFFFF, bgAlpha:0.5, img:""},
                    {left:50, top:100, width:20, height:20, bgColor:Math.random * 0xFFFFFF, bgAlpha:0.5, img:""}
                    ];


var tabGroup = Titanium.UI.createTabGroup();





var parentWindow = Titanium.UI.createWindow({  
    title:'Tab 1',
    backgroundImage:"assets/background.png",
    backgroundColor:'#fff',
    navBarHidden:true,
    tabBarHidden:true
});
addPlaceHolders();

function addPlaceHolders()
{
    for(i = 0; i < placeHolders.length; i++)
    {
        var placeHolder = placeHolders[i];
        var placeHolderView = Titanium.UI.createView({
            top:placeHolder.top,
            left:placeHolder.left,
            height:placeHolder.height,
            width:placeHolder.width,
            backgroundColor:placeHolder.bgColor,
            opacity:placeHolder.bgAlpha

        });
        placeHolderView.name = i;
        parentWindow.add(placeHolderView);
        placeHolderView.addEventListener("click", onPlaceHolderClick);
    }
}


var main = Titanium.UI.createTab({  
    title:'Tab 1',
    window:parentWindow
});
//  add tabs
tabGroup.addTab(main);  

// open tab group
tabGroup.open();

function onPlaceHolderClick(e)
{
    //tell me wot to do here
    alert("tell me wo to do here");
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM