简体   繁体   English

当我尝试在Android模拟器上运行Titan App时出现错误

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

I have build an app in titanium studio and I have runned it both on iphone simulator and iphone device and it works perfectly. 我已经在Titanium Studio中构建了一个应用程序,并且已经在iphone模拟器和iphone设备上运行了该应用程序,并且运行良好。 But when I try to run it on android emulator or android device it crashes. 但是,当我尝试在android模拟器或android设备上运行它时,它崩溃了。

I get the following error: 我收到以下错误:

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)

Has anyone any idea about what is wrong? 有谁知道出什么问题了吗? I would post some code, but is too long and I don't know which part causes this problem. 我会发布一些代码,但是太长了,我不知道是哪个部分导致了此问题。

Wait for your answers, thank you! 等待您的答案,谢谢!

// 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.

相关问题 当我尝试在模拟器android studio上运行app时出错 - error when i try to run app on emulator android studio 当我尝试在 android 模拟器中模拟我的应用程序时,React Native npm 运行弹出错误 - React Native npm run eject error when i try to emulate my app in an android emulator 当我尝试在 android 上运行我的应用程序时出错 - Error when i try to run my app on android 当我尝试运行应用时出现Android Studio错误 - Appear an Android Studio error, when I try to run app 当我尝试在 android 上运行 React Native 应用程序时出错 - getting error when i try to run react native app on android 当我尝试运行时,我的 Flutter 应用程序没有出现在模拟器中 - My Flutter app doesnt appear in the emulator when I try to run it 当我尝试在Android模拟器上运行Junit测试用例时,为什么会发生此错误? - Why does this error occur when I try to run a Junit test-case on the Android emulator? 当我尝试在模拟器上运行时,Android Studio返回“转换异常”错误 - Android Studio returning Transform Exception error when I try to run on an emulator 当我尝试运行HelloAndroid时,Android模拟器崩溃 - Android emulator crashes when I try to run HelloAndroid 当我尝试在模拟器中加载 Android 应用程序时崩溃 - Android App Crashes when I try to load it in the Emulator
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM