gpt4 book ai didi

java - 我的应用程序打开后立即关闭

转载 作者:行者123 更新时间:2023-12-01 13:16:18 24 4
gpt4 key购买 nike

我已经开发了自己的应用程序,并尝试在模拟器5556中打开它。它安装成功。然而,当我打开它时,它立即关闭。我希望有人能帮帮忙。这是我的 androidmainfest.xml

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.monkey"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-feature android:glEsVersion="0x20000" android:required="true" />

<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >


<meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="AIzaSyCi43x8rh1xwonf15SQ2faHLPKCJUkzAn8" />
<activity android:theme="@*android:style/Theme.NoTitleBar" android:label="@string/app_name" android:name="com.example.monkey.Home" android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

<activity android:name="com.example.monkey.SettingPreferences" android:screenOrientation="portrait" />
<activity android:name="com.example.monkey.CategoryList" android:screenOrientation="portrait" />
<activity android:name="com.example.monkey.MenuList" android:screenOrientation="portrait" />
<activity android:name="com.example.monkey.MenuDetail" android:screenOrientation="portrait" />
<activity android:name="com.example.monkey.ShareMenu" android:screenOrientation="portrait" />
<activity android:name="com.example.monkey.Contact" android:screenOrientation="portrait" />
<activity android:name="com.example.monkey.News" android:screenOrientation="portrait" />
<activity android:name="com.example.monkey.NewsDetail" android:screenOrientation="portrait" />
<activity android:name="com.example.monkey.YourOrder" android:screenOrientation="portrait" />
<activity android:name="com.example.monkey.Reservation" android:screenOrientation="portrait" />
</application>

03-16 13:01:14.249: D/AndroidRuntime(1138): Shutting down VM
03-16 13:01:14.249: W/dalvikvm(1138): threadid=1: thread exiting with uncaught exception (group=0xb3a3aba8)
03-16 13:01:14.419: E/AndroidRuntime(1138): FATAL EXCEPTION: main
03-16 13:01:14.419: E/AndroidRuntime(1138): Process: com.example.monkey, PID: 1138
03-16 13:01:14.419: E/AndroidRuntime(1138): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.monkey/com.example.monkey.Home}: java.lang.ClassNotFoundException: Didn't find class "com.example.monkey.Home" on path: DexPathList[[zip file "/data/app/com.example.monkey-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.monkey-2, /system/lib]]
03-16 13:01:14.419: E/AndroidRuntime(1138): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2121)
03-16 13:01:14.419: E/AndroidRuntime(1138): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
03-16 13:01:14.419: E/AndroidRuntime(1138): at android.app.ActivityThread.access$800(ActivityThread.java:135)
03-16 13:01:14.419: E/AndroidRuntime(1138): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
03-16 13:01:14.419: E/AndroidRuntime(1138): at android.os.Handler.dispatchMessage(Handler.java:102)
03-16 13:01:14.419: E/AndroidRuntime(1138): at android.os.Looper.loop(Looper.java:136)
03-16 13:01:14.419: E/AndroidRuntime(1138): at android.app.ActivityThread.main(ActivityThread.java:5017)
03-16 13:01:14.419: E/AndroidRuntime(1138): at java.lang.reflect.Method.invokeNative(Native Method)
03-16 13:01:14.419: E/AndroidRuntime(1138): at java.lang.reflect.Method.invoke(Method.java:515)
03-16 13:01:14.419: E/AndroidRuntime(1138): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
03-16 13:01:14.419: E/AndroidRuntime(1138): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
03-16 13:01:14.419: E/AndroidRuntime(1138): at dalvik.system.NativeStart.main(Native Method)
03-16 13:01:14.419: E/AndroidRuntime(1138): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.example.monkey.Home" on path: DexPathList[[zip file "/data/app/com.example.monkey-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.monkey-2, /system/lib]]
03-16 13:01:14.419: E/AndroidRuntime(1138): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
03-16 13:01:14.419: E/AndroidRuntime(1138): at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
03-16 13:01:14.419: E/AndroidRuntime(1138): at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
03-16 13:01:14.419: E/AndroidRuntime(1138): at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
03-16 13:01:14.419: E/AndroidRuntime(1138): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2112)
03-16 13:01:14.419: E/AndroidRuntime(1138): ... 11 more

最佳答案

嗯,根据错误日志,它没有找到您的 Activity 的 java 代码。您是否使用 IDE 来生成 Activity ?请确保您的 Activity 使用的类(class)具有相同的名称。就您而言,您的 src 文件夹中必须有一个名为 Home.java 的文件。您能确认它在那里吗?

更新:如果您在让 IDE 为您的 Activity 生成代码时遇到困难,请尝试创建您自己的名为 Home.java 的文件并尝试以下代码:

import android.os.Bundle;
import android.app.Activity;

public class Home extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.Home);
}

}

(请记住,最佳命名实践规定 Android 中的布局名称为:全部小写,通常以“activity”开头,并使用“_”作为单词之间的空格。这不是一个大问题,但这是很好的编码实践。最佳祝你好运!

关于java - 我的应用程序打开后立即关闭,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22439656/

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