I’ve changed text in the app_name string (just wanted to fix the spelling).
When I ran the project it returned a disaster:
11-15 18:20:13.181: W/dalvikvm(926): threadid=1: thread exiting with uncaught exception (group=0x40015560)
11-15 18:20:13.211: E/AndroidRuntime(926): FATAL EXCEPTION: main
11-15 18:20:13.211: E/AndroidRuntime(926): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.dreamoholic.android.smartshoppinglist/com.dreamoholic.android.smartshoppinglist.Main}: java.lang.NullPointerException
11-15 18:20:13.211: E/AndroidRuntime(926): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
11-15 18:20:13.211: E/AndroidRuntime(926): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
11-15 18:20:13.211: E/AndroidRuntime(926): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
11-15 18:20:13.211: E/AndroidRuntime(926): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
11-15 18:20:13.211: E/AndroidRuntime(926): at android.os.Handler.dispatchMessage(Handler.java:99)
11-15 18:20:13.211: E/AndroidRuntime(926): at android.os.Looper.loop(Looper.java:123)
11-15 18:20:13.211: E/AndroidRuntime(926): at android.app.ActivityThread.main(ActivityThread.java:3683)
11-15 18:20:13.211: E/AndroidRuntime(926): at java.lang.reflect.Method.invokeNative(Native Method)
11-15 18:20:13.211: E/AndroidRuntime(926): at java.lang.reflect.Method.invoke(Method.java:507)
11-15 18:20:13.211: E/AndroidRuntime(926): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
11-15 18:20:13.211: E/AndroidRuntime(926): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
11-15 18:20:13.211: E/AndroidRuntime(926): at dalvik.system.NativeStart.main(Native Method)
11-15 18:20:13.211: E/AndroidRuntime(926): Caused by: java.lang.NullPointerException
11-15 18:20:13.211: E/AndroidRuntime(926): at com.dreamoholic.android.smartshoppinglist.Main.onCreate(Main.java:127)
11-15 18:20:13.211: E/AndroidRuntime(926): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
11-15 18:20:13.211: E/AndroidRuntime(926): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
11-15 18:20:13.211: E/AndroidRuntime(926): ... 11 more
I have tried to undo the spelling but couldn’t fix the problem anymore.
I’ve done this once, but it worked when I changed back the text.
I’ve looked at the 127. line in Main.java and commented out that onClickListener, but than it just goes to another line and gives an error there.
This is my Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.dreamoholic.android.smartshoppinglist"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="7" />
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="android.permission.DISABLE_KEYGUARD"/>
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:label="@string/app_name"
android:name=".Main"
android:configChanges="keyboardHidden|orientation">
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".Saved"
android:configChanges="keyboardHidden|orientation">
</activity>
<activity android:name=".List"
android:configChanges="keyboardHidden|orientation">
</activity>
</application>
</manifest>
and this is my strings.xml :
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="hello">Hello World, Main!</string>
<string name="app_name">Smart Shopping List</string>
<!-- strings for Main top row -->
<string name="main_new">New</string>
<string name="main_popular">Popular</string>
<string name="main_saved">Saved</string>
<string name="main_send">Send</string>
</resources>
I don’t know how to resolve this problem.
I’ve tried to copy the project, clean it and copy it by hand into another new project.
I have messed up my package names on creating a new project.
Now I’ve checked all package names and they are consistent.
First I get an error on my 127. line that is:
tv3.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(Main.this, theme, Toast.LENGTH_SHORT).show();
}
});
have you used your appname or packege name hardcoded in your project – folders, databases, content providers, custom controlos etc. What I would do in your case is to search the old value in the whole project (Ctrl + H, FileSearch tab) and look is there something wrong.
Edit: uninstalling the application from the device/emulator is required too (or clear the user data, but I prefer the complete uninstall).