0

I made an App. and since I just wanted to test some functions before adding them to the App,

I decided to copy my project into a new Project. When I tried to run the new project, the app crashes and the log-cat output is as follows.

Manifest file:

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

<uses-sdk android:minSdkVersion="10" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.CAMERA"/>

<application
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name" android:debuggable="true">
    <activity
        android:name=".MPActivity"
        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="AddLocationActivity"></activity>
    <activity android:name="MPData"></activity>
    <activity android:name="MyLocations"></activity>
    <activity android:name="MPInfo"></activity>
    <activity android:name="Navigation"></activity>
</application>

LogCat:

    05-21 15:30:03.710: E/AndroidRuntime(11294): FATAL EXCEPTION: main
    05-21 15:30:03.710: E/AndroidRuntime(11294): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.androidbook.MP/com.androidbook.MP.MPActivity}:  
   java.lang.ClassNotFoundException: com.androidbook.MP.MPActivity in loader 
   dalvik.system.PathClassLoader[/data/app/com.androidbook.MP-1.apk]
05-21 15:30:03.710: E/AndroidRuntime(11294):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1573)
05-21 15:30:03.710: E/AndroidRuntime(11294):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667)
05-21 15:30:03.710: E/AndroidRuntime(11294):    at android.app.ActivityThread.access$1500(ActivityThread.java:117)
05-21 15:30:03.710: E/AndroidRuntime(11294):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935)
05-21 15:30:03.710: E/AndroidRuntime(11294):    at android.os.Handler.dispatchMessage(Handler.java:99)
05-21 15:30:03.710: E/AndroidRuntime(11294):    at android.os.Looper.loop(Looper.java:130)
05-21 15:30:03.710: E/AndroidRuntime(11294):    at android.app.ActivityThread.main(ActivityThread.java:3691)
05-21 15:30:03.710: E/AndroidRuntime(11294):    at java.lang.reflect.Method.invokeNative(Native Method)
05-21 15:30:03.710: E/AndroidRuntime(11294):    at java.lang.reflect.Method.invoke(Method.java:507)
05-21 15:30:03.710: E/AndroidRuntime(11294):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:907)
05-21 15:30:03.710: E/AndroidRuntime(11294):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:665)
05-21 15:30:03.710: E/AndroidRuntime(11294):    at dalvik.system.NativeStart.main(Native Method)
05-21 15:30:03.710: E/AndroidRuntime(11294): Caused by: java.lang.ClassNotFoundException: com.androidbook.MP.MPActivity in loader dalvik.system.PathClassLoader[/data/app/com.androidbook.MP-1.apk]
05-21 15:30:03.710: E/AndroidRuntime(11294):    at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
05-21 15:30:03.710: E/AndroidRuntime(11294):    at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
05-21 15:30:03.710: E/AndroidRuntime(11294):    at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
05-21 15:30:03.710: E/AndroidRuntime(11294):    at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
05-21 15:30:03.710: E/AndroidRuntime(11294):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1565)
05-21 15:30:03.710: E/AndroidRuntime(11294):    ... 11 more
Amr
  • 187
  • 1
  • 4
  • 11

3 Answers3

1

Check your Manifest file, if the activity is to be declared.

for Ex:

<application>

    <activity android:name=".MyActivity" android:label="@string/app_name">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>
Aerrow
  • 12,086
  • 10
  • 56
  • 90
  • please check the manifest file...i've just posted..it's same as recommended..but still the app crashs – Amr May 21 '12 at 13:56
  • 1
    I think I found the solution, i should have hecked that, the package name of the new project is mentioned in the manifest file "package="com.androidbook.MPTest" ..my mistake is the i used the package name of the old project as a package name of the new project....Now, Can use this comment as answer to my question??? – Amr May 21 '12 at 14:06
  • Sure, declare the activities like this (you miss the .(dot) in every activity declaration) – Aerrow May 21 '12 at 14:11
  • You can accept this answer, or you can make your own answer and accept it in a couple of days. – Sparky May 21 '12 at 14:15
  • @Aerrow: I think only the activity name included in the firest activity tag must be preceeded by a dot, but other activity names must not. I tried it and it worked. – Amr May 21 '12 at 14:29
0

Look through all the files in your new project and make sure they aren't referencing classes from the old project.

Sparky
  • 8,437
  • 1
  • 29
  • 41
0

I think I found the solution, i should have checked that, the package name of the new project is included in the manifest file as for an example

"package="com.androidbook.MPTest" ..

my mistake is the i used the package name of the old project as a package name of the new project.

Amr
  • 187
  • 1
  • 4
  • 11