Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/209.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 我的第一款安卓应用赢得了';无法在我的Android设备(手机)中正确运行_Java_Android - Fatal编程技术网

Java 我的第一款安卓应用赢得了';无法在我的Android设备(手机)中正确运行

Java 我的第一款安卓应用赢得了';无法在我的Android设备(手机)中正确运行,java,android,Java,Android,我的代码没有错误,我正在尝试使用三星安卓设备运行应用程序。我的设备似乎是在线的,Android版本号是4.2.2。当应用程序在手机上运行时,只有一条消息对话框告诉您,TestiHello已停止TestiHello是简单Hello World的项目名称-示例 我的Eclipse控制台代表下一代: 2014-05-07 22:18:32 - TestiHello] ------------------------------ [2014-05-07 22:18:32 - TestiHello] An

我的代码没有错误,我正在尝试使用三星安卓设备运行应用程序。我的设备似乎是在线的,Android版本号是
4.2.2
。当应用程序在手机上运行时,只有一条消息对话框告诉您,TestiHello已停止
TestiHello
是简单Hello World的项目名称-示例

我的Eclipse控制台代表下一代:

2014-05-07 22:18:32 - TestiHello] ------------------------------
[2014-05-07 22:18:32 - TestiHello] Android Launch!
[2014-05-07 22:18:32 - TestiHello] adb is running normally.
[2014-05-07 22:18:32 - TestiHello] Performing com.example.testihello.MainActivity activity launch
[2014-05-07 22:18:32 - TestiHello] Automatic Target Mode: Unable to detect device compatibility. Please select a target device.
[2014-05-07 22:18:38 - TestiHello] Application already deployed. No need to reinstall.
[2014-05-07 22:18:38 - TestiHello] Starting activity com.example.testihello.MainActivity on device 4203c169c8831100
[2014-05-07 22:18:38 - TestiHello] ActivityManager: Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.example.testihello/.MainActivity }
我正在32位Windows Vista上使用三星Galaxy Trend手机和Eclipse Indigo。我的手机是根,我是超级用户,并成功地打开了USB调试模式。有什么想法吗?我的假设是这个问题和Android版本号有关?我说得对吗

编辑:


您的LogCat记录您无法找到占位符片段的id为
container
(它是
activity\u main.xml
文件的默认id)的视图。如果代码位于MainActivity中,而不是占位符片段中,则可以尝试以下操作:

如果MainActivity的onCreate()方法中有此项,请将其删除:

if (savedInstanceState == null) {
        getSupportFragmentManager().beginTransaction()
                .add(R.id.container, new PlaceholderFragment()).commit();
    }
如果不需要占位符片段,也可以删除这部分代码:

public static class PlaceholderFragment extends Fragment {

    public PlaceholderFragment() {
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
        View rootView = inflater.inflate(R.layout.fragment_main, container,
                false);
        return rootView;
    }
}

您没有发布日志猫的相关部分。@zouzu这甚至不是日志猫,而是控制台输出。请将其替换为logcat中的错误。很抱歉。。。我上传了Logcat-log-txt文件到我的公共Onedrive文件夹(Logcat\u TestiHello\u log.txt),看起来你的布局没有包含放置片段的容器id。接下来我们需要看一些代码。你能发布活动课的代码吗?谢谢你的帮助!在删除你说的“如果”语句后,应用程序运行良好!
public static class PlaceholderFragment extends Fragment {

    public PlaceholderFragment() {
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
        View rootView = inflater.inflate(R.layout.fragment_main, container,
                false);
        return rootView;
    }
}