gpt4 book ai didi

java - 重命名主 Activity 后出错

转载 作者:行者123 更新时间:2023-11-30 04:03:10 24 4
gpt4 key购买 nike

将我的主类重命名为“Main”并将我的主 xml 重命名为“main”后,我可以启动我的应用程序。我一直收到这个 logcat:

08-28 21:46:27.563: D/AndroidRuntime(264): Shutting down VM
08-28 21:46:27.563: W/dalvikvm(264): threadid=3: thread exiting with uncaught exception (group=0x4001b188)
08-28 21:46:27.563: E/AndroidRuntime(264): Uncaught handler: thread main exiting due to uncaught exception
08-28 21:46:27.623: E/AndroidRuntime(264): java.lang.RuntimeException: Unable to start activity ComponentInfo{noc.support/noc.support.Main}: java.lang.NullPointerException
08-28 21:46:27.623: E/AndroidRuntime(264): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2496)
08-28 21:46:27.623: E/AndroidRuntime(264): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512)
08-28 21:46:27.623: E/AndroidRuntime(264): at android.app.ActivityThread.access$2200(ActivityThread.java:119)
08-28 21:46:27.623: E/AndroidRuntime(264): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863)
08-28 21:46:27.623: E/AndroidRuntime(264): at android.os.Handler.dispatchMessage(Handler.java:99)
08-28 21:46:27.623: E/AndroidRuntime(264): at android.os.Looper.loop(Looper.java:123)
08-28 21:46:27.623: E/AndroidRuntime(264): at android.app.ActivityThread.main(ActivityThread.java:4363)
08-28 21:46:27.623: E/AndroidRuntime(264): at java.lang.reflect.Method.invokeNative(Native Method)
08-28 21:46:27.623: E/AndroidRuntime(264): at java.lang.reflect.Method.invoke(Method.java:521)
08-28 21:46:27.623: E/AndroidRuntime(264): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
08-28 21:46:27.623: E/AndroidRuntime(264): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
08-28 21:46:27.623: E/AndroidRuntime(264): at dalvik.system.NativeStart.main(Native Method)
08-28 21:46:27.623: E/AndroidRuntime(264): Caused by: java.lang.NullPointerException
08-28 21:46:27.623: E/AndroidRuntime(264): at noc.support.Main.onCreate(Main.java:116)
08-28 21:46:27.623: E/AndroidRuntime(264): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
08-28 21:46:27.623: E/AndroidRuntime(264): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2459)
08-28 21:46:27.623: E/AndroidRuntime(264): ... 11 more
08-28 21:46:27.653: I/dalvikvm(264): threadid=7: reacting to signal 3
08-28 21:46:27.663: I/dalvikvm(264): Wrote stack trace to '/data/anr/traces.txt'
08-28 21:47:07.853: I/Process(264): Sending signal. PID: 264 SIG: 9

list :

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="noc.support"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk android:minSdkVersion="7" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />


<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" android:debuggable="true">

<service android:name=".BootListnerService" android:label="Boot Service">
<intent-filter>
<action android:name="noc.support.BootListnerService" />
</intent-filter>
</service>

<receiver
android:name=".BootListnerServiceReceiver"
android:enabled="true"
android:exported="true"
android:label="BootListnerServiceReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>


<activity
android:name=".Main"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

<activity android:name=".Register" android:label="Register"></activity>

<activity android:name=".Settings" android:label="Settings"></activity>

<activity android:name=".ServersStatus" android:label="Servers Status"></activity>

</application>

</manifest>

这是 main.xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="vertical" >

<TextView
android:id="@+id/emailLable"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/textView1"
android:layout_marginTop="40dp"
android:text="Email:"
android:textAppearance="?android:attr/textAppearanceMedium" android:layout_marginLeft="5dp"/>

<EditText
android:id="@+id/emailField"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:ems="10" android:layout_marginLeft="5dp" android:layout_marginRight="5dp"
android:inputType="textEmailAddress" />

<TextView
android:id="@+id/passwordLable"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/editText1"
android:layout_marginTop="36dp"
android:text="Password:"
android:textAppearance="?android:attr/textAppearanceMedium" android:layout_marginLeft="5dp"/>


<EditText
android:id="@+id/passwordField"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPassword"
android:layout_marginLeft="5dp" android:layout_marginRight="5dp"/>

<CheckBox
android:id="@+id/rememberEmailPasswordCheckBox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Remember my email &amp; password" />

<CheckBox
android:id="@+id/loginAutomaticallyCheckBox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Login automatically" />

<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content" android:paddingLeft="5dp" android:paddingRight="5dp" android:layout_marginTop="40dp">


<Button
android:id="@+id/addButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1.05"
android:text="Add" />




<Button
android:id="@+id/refreshButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.86"
android:text="Refresh" />

</LinearLayout>

</LinearLayout>

我做错了什么?

有没有人有什么想法。

我用谷歌搜索了它,但找不到修复程序。

当我改变“setContentView(R.layout.main);”对于任何其他布局,它都可以正常工作,但我需要此类以 main.xml 开头

最佳答案

它似乎仍在尝试启动 Activity “ComponentInfo”。如果您更改了所有文件,但没有更改包名称,那么您可能是在旧应用程序之上安装新应用程序,而旧启动器指向旧 Activity ,该 Activity 不再存在。

简而言之:尝试删除旧应用程序并重新安装。

关于java - 重命名主 Activity 后出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12167629/

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