0
votes

So I am sort of a noob to java and programming at that. I am picking it up however. Recently I have tried to run my app on an emulator but it force closes. It is probably my fault but i can't find any errors. So i decided to turn to you guys since you seem experienced. Any help would be appreciated.

This is the manifest file:

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


    <application android:icon="@drawable/icon"  android:label="@string/app_name" 
                 android:debuggable="true">
        <activity android:name=".Mr.NomActivity"
                  android:label="@string/app_name" android:screenOrientation="landscape"      android:configChanges="keyboard|keyboardHidden|orientation">
            <intent-filter>

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


    </application>


<uses-sdk android:minSdkVersion="3" android:targetSdkVersion="8"/>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.WAKE_LOCK"/>
</manifest>

This is the XML:

 <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:weightSum="1">
    <TextView android:layout_width="fill_parent" android:textSize="30dp" android:text="Mr. Nom"    android:layout_weight="0.05" android:gravity="center" android:layout_height="wrap_content" android:textStyle="bold"></TextView>
    <Button android:layout_width="160dp" android:text="Play" android:id="@+id/Button02" android:clickable="true" android:layout_weight="0.06" android:layout_height="wrap_content" android:layout_gravity="center" android:textSize="25dp"></Button>
    <Button android:layout_width="160dp" android:text="Settings" android:id="@+id/Button03" android:clickable="true" android:layout_height="wrap_content" android:textSize="25dp" android:layout_gravity="center" android:layout_weight="0.06"></Button>
    <Button android:layout_width="160dp" android:text="Help" android:id="@+id/Button01" android:clickable="true" android:layout_weight="0.06" android:layout_height="wrap_content" android:layout_gravity="center" android:textSize="25dp"></Button>
    <Button android:layout_width="160dp" android:id="@+id/button1" android:clickable="true" android:layout_weight="0.06" android:layout_height="wrap_content" android:textSize="25dp" android:layout_gravity="center" android:text="High Scores"></Button></LinearLayout>

So once again I'm new to this but I thought you guys might need this code. Just let me know if you need anything else.

Heres the activity code:

package Mr;

import com.MrNom.R;
import android.app.Activity;
import android.os.Bundle;

public class NomActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    }

}

When I tried to run the app this was red in logcat.

07-29 18:30:29.347: ERROR/AndroidRuntime(333): FATAL EXCEPTION: main 07-29 18:30:29.347: ERROR/AndroidRuntime(333): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.MrNom/com.MrNom.Mr.NomActivity}: java.lang.ClassNotFoundException: com.MrNom.Mr.NomActivity in loader dalvik.system.PathClassLoader[/data/app/com.MrNom-1.apk] 07-29 18:30:29.347: ERROR/AndroidRuntime(333): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2585) 07-29 18:30:29.347: ERROR/AndroidRuntime(333): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679) 07-29 18:30:29.347: ERROR/AndroidRuntime(333): at android.app.ActivityThread.access$2300(ActivityThread.java:125) 07-29 18:30:29.347: ERROR/AndroidRuntime(333): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033) 07-29 18:30:29.347: ERROR/AndroidRuntime(333): at android.os.Handler.dispatchMessage(Handler.java:99) 07-29 18:30:29.347: ERROR/AndroidRuntime(333): at android.os.Looper.loop(Looper.java:123) 07-29 18:30:29.347: ERROR/AndroidRuntime(333): at android.app.ActivityThread.main(ActivityThread.java:4627) 07-29 18:30:29.347: ERROR/AndroidRuntime(333): at java.lang.reflect.Method.invokeNative(Native Method) 07-29 18:30:29.347: ERROR/AndroidRuntime(333): at java.lang.reflect.Method.invoke(Method.java:521) 07-29 18:30:29.347: ERROR/AndroidRuntime(333): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868) 07-29 18:30:29.347: ERROR/AndroidRuntime(333): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626) 07-29 18:30:29.347: ERROR/AndroidRuntime(333): at dalvik.system.NativeStart.main(Native Method) 07-29 18:30:29.347: ERROR/AndroidRuntime(333): Caused by: java.lang.ClassNotFoundException: com.MrNom.Mr.NomActivity in loader dalvik.system.PathClassLoader[/data/app/com.MrNom-1.apk] 07-29 18:30:29.347: ERROR/AndroidRuntime(333): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243) 07-29 18:30:29.347: ERROR/AndroidRuntime(333): at java.lang.ClassLoader.loadClass(ClassLoader.java:573) 07-29 18:30:29.347: ERROR/AndroidRuntime(333): at java.lang.ClassLoader.loadClass(ClassLoader.java:532) 07-29 18:30:29.347: ERROR/AndroidRuntime(333): at android.app.Instrumentation.newActivity(Instrumentation.java:1021) 07-29 18:30:29.347: ERROR/AndroidRuntime(333): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2577) 07-29 18:30:29.347: ERROR/AndroidRuntime(333): ... 11 more

So to clarify it should look like this:

package com.MrNom;

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

public class NomActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    }

}
1
Can you post your Activity code? Are you setting the layout in the onCreate method? - Eugene S
what is your activity name is it "Mr.NomActivity" or "NomActivity"... think first once is not currect one... - Dinash
So, just to be clear, nothing shows up in LogCat? - Krylez
remove the .Mr. in the activity definition in manifest file.. - Dinash

1 Answers

1
votes

This line:

import com.MrNom.R;

should be

package com.MrNom

And remove the package Mr;

Also in the manifest xml file this line: activity android:name=".Mr.NomActivity" Should be: activity android:name="Mr.NomActivity"