Reputation: 1
I'm trying to just create a basic android app, and when I load it onto a phone and try to run the app it just crashes. Can someone take a look at it for me?
My manifest
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.workexp1"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="21" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity android:label="@string/app_name"
android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
What logcat says
07-02 15:19:24.091: D/AndroidRuntime(3213): Shutting down VM
07-02 15:19:24.091: W/dalvikvm(3213): threadid=1: thread exiting with uncaught exception (group=0x4001d5a0)
07-02 15:19:24.101: E/AndroidRuntime(3213): FATAL EXCEPTION: main
07-02 15:19:24.101: E/AndroidRuntime(3213): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.workexp1/com.example.workexp1.MainActivity}: java.lang.ClassNotFoundException: com.example.workexp1.MainActivity in loader dalvik.system.PathClassLoader[/data/app/com.example.workexp1-1.apk]
07-02 15:19:24.101: E/AndroidRuntime(3213): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1785)
07-02 15:19:24.101: E/AndroidRuntime(3213): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1893)
07-02 15:19:24.101: E/AndroidRuntime(3213): at android.app.ActivityThread.access$1500(ActivityThread.java:135)
07-02 15:19:24.101: E/AndroidRuntime(3213): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1054)
07-02 15:19:24.101: E/AndroidRuntime(3213): at android.os.Handler.dispatchMessage(Handler.java:99)
07-02 15:19:24.101: E/AndroidRuntime(3213): at android.os.Looper.loop(Looper.java:150)
07-02 15:19:24.101: E/AndroidRuntime(3213): at android.app.ActivityThread.main(ActivityThread.java:4385)
07-02 15:19:24.101: E/AndroidRuntime(3213): at java.lang.reflect.Method.invokeNative(Native Method)
07-02 15:19:24.101: E/AndroidRuntime(3213): at java.lang.reflect.Method.invoke(Method.java:507)
07-02 15:19:24.101: E/AndroidRuntime(3213): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:849)
07-02 15:19:24.101: E/AndroidRuntime(3213): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:607)
07-02 15:19:24.101: E/AndroidRuntime(3213): at dalvik.system.NativeStart.main(Native Method)
07-02 15:19:24.101: E/AndroidRuntime(3213): Caused by: java.lang.ClassNotFoundException: com.example.workexp1.MainActivity in loader dalvik.system.PathClassLoader[/data/app/com.example.workexp1-1.apk]
07-02 15:19:24.101: E/AndroidRuntime(3213): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
07-02 15:19:24.101: E/AndroidRuntime(3213): at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
07-02 15:19:24.101: E/AndroidRuntime(3213): at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
07-02 15:19:24.101: E/AndroidRuntime(3213): at android.app.Instrumentation.newActivity(Instrumentation.java:1040)
07-02 15:19:24.101: E/AndroidRuntime(3213): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1777)
07-02 15:19:24.101: E/AndroidRuntime(3213): ... 11 more
07-02 15:19:31.869: D/Process(3213): killProcess, pid=3213
Request any other files you'd need to check.
Upvotes: 0
Views: 88
Reputation: 8651
If you MainActivity does not live in the same package as the one specified in the manifest (in this case com.example.workexp1) then the dot notation won't work.
change this line
android:name=".MainActivity">
to
android:name="com.yourfullpackage.MainActivity">
Upvotes: 0
Reputation: 22
java.lang.ClassNotFoundException: com.example.workexp1.MainActivity in loader dalvik.system.PathClassLoader[/data/app/com.example.workexp1-1.apk]
This exception means that there is no such class named MainActivity
in your project. So check your project and see what's going on.
Upvotes: 1