gpt4 book ai didi

java - 我的第一个 Android 应用无法在我的 Android 设备(手机)中正常运行

转载 作者:行者123 更新时间:2023-11-30 02:54:28 25 4
gpt4 key购买 nike

我的代码没有错误,我正在尝试使用 Samsung Android 设备运行该应用程序。我的设备似乎在线,Android 版本号是 4.2.2。当应用程序在手机上运行时,只有消息对话框告诉 The TestiHello is stoppedTestiHello 是我的简单 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 上使用 Samsung Galaxy Trend 手机和 Eclipse Indigo。我的手机已经 root 了,我是 super 用户,并且成功打开了 USB Debug模式。有任何想法吗?我的假设是这个问题与 Android 版本号有关?我说得对吗?

编辑:

01-02 06:24:16.830: D/dalvikvm(5212): Late-enabling CheckJNI
01-02 06:24:17.030: E/FragmentManager(5212): No view found for id 0x7f05003c (com.example.testihello:id/container) for fragment PlaceholderFragment{415f01b8 #0 id=0x7f05003c}
01-02 06:24:17.030: E/FragmentManager(5212): Activity state:
01-02 06:24:17.030: D/FragmentManager(5212): Local FragmentActivity 415cc888 State:
01-02 06:24:17.030: D/FragmentManager(5212): mCreated=truemResumed=false mStopped=false mReallyStopped=false
01-02 06:24:17.030: D/FragmentManager(5212): mLoadersStarted=false
01-02 06:24:17.030: D/FragmentManager(5212): Active Fragments in 415cd978:
01-02 06:24:17.030: D/FragmentManager(5212): #0: PlaceholderFragment{415f01b8 #0 id=0x7f05003c}
01-02 06:24:17.030: D/FragmentManager(5212): mFragmentId=#7f05003c mContainerId=#7f05003c mTag=null
01-02 06:24:17.030: D/FragmentManager(5212): mState=0 mIndex=0 mWho=android:fragment:0 mBackStackNesting=0
01-02 06:24:17.030: D/FragmentManager(5212): mAdded=true mRemoving=false mResumed=false mFromLayout=false mInLayout=false
01-02 06:24:17.030: D/FragmentManager(5212): mHidden=false mDetached=false mMenuVisible=true mHasMenu=false
01-02 06:24:17.030: D/FragmentManager(5212): mRetainInstance=false mRetaining=false mUserVisibleHint=true
01-02 06:24:17.030: D/FragmentManager(5212): mFragmentManager=FragmentManager{415cd978 in MainActivity{415cc888}}
01-02 06:24:17.030: D/FragmentManager(5212): mActivity=com.example.testihello.MainActivity@415cc888
01-02 06:24:17.030: D/FragmentManager(5212): Added Fragments:
01-02 06:24:17.030: D/FragmentManager(5212): #0: PlaceholderFragment{415f01b8 #0 id=0x7f05003c}
01-02 06:24:17.030: D/FragmentManager(5212): FragmentManager misc state:
01-02 06:24:17.030: D/FragmentManager(5212): mActivity=com.example.testihello.MainActivity@415cc888
01-02 06:24:17.030: D/FragmentManager(5212): mContainer=android.support.v4.app.FragmentActivity$2@415ce2a0
01-02 06:24:17.030: D/FragmentManager(5212): mCurState=2 mStateSaved=false mDestroyed=false
01-02 06:24:17.030: D/FragmentManager(5212): View Hierarchy:
01-02 06:24:17.030: D/FragmentManager(5212): com.android.internal.policy.impl.PhoneWindow$DecorView{415d42d0 V.E..... ... 0,0-0,0}
01-02 06:24:17.030: D/FragmentManager(5212): android.widget.LinearLayout{415d5ea8 V.E..... ... 0,0-0,0}
01-02 06:24:17.030: D/FragmentManager(5212): com.android.internal.widget.ActionBarContainer{415d6b78 V.ED.... ... 0,0-0,0 #1020446 android:id/action_bar_container}
01-02 06:24:17.030: D/FragmentManager(5212): com.android.internal.widget.ActionBarView{415d7330 V.E..... ... 0,0-0,0 #1020447 android:id/action_bar}
01-02 06:24:17.030: D/FragmentManager(5212): android.widget.LinearLayout{415df6a0 V.....C. ... 0,0-0,0}
01-02 06:24:17.030: D/FragmentManager(5212): com.android.internal.widget.ActionBarView$HomeView{415e0fa0 V.E..... ... 0,0-0,0}
01-02 06:24:17.030: D/FragmentManager(5212): android.widget.ImageView{415e1768 G.ED.... ... 0,0-0,0 #102028a android:id/up}
01-02 06:24:17.030: D/FragmentManager(5212): android.widget.ImageView{415e2738 V.ED.... ... 0,0-0,0 #102002c android:id/home}
01-02 06:24:17.030: D/FragmentManager(5212): android.widget.LinearLayout{415e4330 G.E..... ... 0,0-0,0}
01-02 06:24:17.030: D/FragmentManager(5212): android.widget.ImageView{415e4778 G.ED.... ... 0,0-0,0 #102028a android:id/up}
01-02 06:24:17.030: D/FragmentManager(5212): android.widget.LinearLayout{415e4b60 V.E..... ... 0,0-0,0}
01-02 06:24:17.030: D/FragmentManager(5212): android.widget.TextView{415e50d8 V.ED.... ... 0,0-0,0 #102029f android:id/action_bar_title}
01-02 06:24:17.030: D/FragmentManager(5212): android.widget.TextView{415e7680 G.ED.... ... 0,0-0,0 #10202a0 android:id/action_bar_subtitle}
01-02 06:24:17.030: D/FragmentManager(5212): com.android.internal.widget.ActionBarContextView{415ea320 G.E..... ... 0,0-0,0 #1020448 android:id/action_context_bar}
01-02 06:24:17.030: D/FragmentManager(5212): android.widget.FrameLayout{415eaaf0 V.ED.... ... 0,0-0,0 #1020002 android:id/content}
01-02 06:24:17.030: D/FragmentManager(5212): android.widget.TextView{415f0668 V.ED.... ... 0,0-0,0}
01-02 06:24:17.030: D/FragmentManager(5212): com.android.internal.widget.ActionBarContainer{415eafe8 G.ED.... ... 0,0-0,0 #1020449 android:id/split_action_bar}
01-02 06:24:17.030: D/AndroidRuntime(5212): Shutting down VM
01-02 06:24:17.030: W/dalvikvm(5212): threadid=1: thread exiting with uncaught exception (group=0x40c8b930)
01-02 06:24:17.040: E/AndroidRuntime(5212): FATAL EXCEPTION: main
01-02 06:24:17.040: E/AndroidRuntime(5212): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.testihello/com.example.testihello.MainActivity}: java.lang.IllegalArgumentException: No view found for id 0x7f05003c (com.example.testihello:id/container) for fragment PlaceholderFragment{415f01b8 #0 id=0x7f05003c}
01-02 06:24:17.040: E/AndroidRuntime(5212): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2255)
01-02 06:24:17.040: E/AndroidRuntime(5212): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2309)
01-02 06:24:17.040: E/AndroidRuntime(5212): at android.app.ActivityThread.access$700(ActivityThread.java:157)
01-02 06:24:17.040: E/AndroidRuntime(5212): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1289)
01-02 06:24:17.040: E/AndroidRuntime(5212): at android.os.Handler.dispatchMessage(Handler.java:99)
01-02 06:24:17.040: E/AndroidRuntime(5212): at android.os.Looper.loop(Looper.java:176)
01-02 06:24:17.040: E/AndroidRuntime(5212): at android.app.ActivityThread.main(ActivityThread.java:5317)
01-02 06:24:17.040: E/AndroidRuntime(5212): at java.lang.reflect.Method.invokeNative(Native Method)
01-02 06:24:17.040: E/AndroidRuntime(5212): at java.lang.reflect.Method.invoke(Method.java:511)
01-02 06:24:17.040: E/AndroidRuntime(5212): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102)
01-02 06:24:17.040: E/AndroidRuntime(5212): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
01-02 06:24:17.040: E/AndroidRuntime(5212): at dalvik.system.NativeStart.main(Native Method)
01-02 06:24:17.040: E/AndroidRuntime(5212): Caused by: java.lang.IllegalArgumentException: No view found for id 0x7f05003c (com.example.testihello:id/container) for fragment PlaceholderFragment{415f01b8 #0 id=0x7f05003c}
01-02 06:24:17.040: E/AndroidRuntime(5212): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:930)
01-02 06:24:17.040: E/AndroidRuntime(5212): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1115)
01-02 06:24:17.040: E/AndroidRuntime(5212): at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:682)
01-02 06:24:17.040: E/AndroidRuntime(5212): at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1478)
01-02 06:24:17.040: E/AndroidRuntime(5212): at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:570)
01-02 06:24:17.040: E/AndroidRuntime(5212): at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1181)
01-02 06:24:17.040: E/AndroidRuntime(5212): at android.app.Activity.performStart(Activity.java:5336)
01-02 06:24:17.040: E/AndroidRuntime(5212): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2227)
01-02 06:24:17.040: E/AndroidRuntime(5212): ... 11 more

最佳答案

您的 LogCat 记录您无法为 PlaceHolderFragment 找到 ID 为 container(它是 activity_main.xml 文件的默认 ID)的 View 。如果您的代码在您的 MainActivity 中,而不是在 PlaceHolderFragment 中,那么您可以试试这个:

如果您在 MainActivity 的 onCreate() 方法中有此内容,请将其删除:

if (savedInstanceState == null) {
getSupportFragmentManager().beginTransaction()
.add(R.id.container, new PlaceholderFragment()).commit();
}

如果您不需要 PlaceHolderFragment,您也可以删除这部分代码:

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;
}
}

关于java - 我的第一个 Android 应用无法在我的 Android 设备(手机)中正常运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23526734/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com