These are my two classes and my manifest. I got a ClassNotFoundException. I have also included my log cat.
My first class:
package com.m.mech;
import com.parse.Parse;
import com.parse.ParseACL;
import com.parse.ParseUser;
import android.app.Application;
public class ParsePro extends Application {
@Override
public void onCreate() {
super.onCreate();
// Add your initialization code here
Parse.initialize(this,"tadjgdfghdfgdfdfcfgdfcr", "QlwkikEQCXZ8cW9ghjwbFpXjAaWEr5Js6H2Cud5");
PushService.setDefaultPushCallback(this, MainActivity.class);
ParseInstallation.getCurrentInstallation().saveInBackground();
ParseUser.enableAutomaticUser();
ParseACL defaultACL = new ParseACL();
// If you would like all objects to be private by default, remove this line.
defaultACL.setPublicReadAccess(true);
ParseACL.setDefaultACL(defaultACL, true);
}
}
My second class:
package com.m.mech;
import com.m.mech.R;
import android.app.Activity;
import android.os.Bundle;
import com.parse.ParseAnalytics;
public class MainActivity extends Activity {
/** Called when the activity is first created. */
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ParseAnalytics.trackAppOpened(getIntent());
}
}
My manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.m.mech"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="4"
android:targetSdkVersion="15" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.VIBRATE" />
<application
android:name="com.m.mech.ParsePro"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:name="com.parse.mech.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<service android:name="com.parse.PushService" />
<receiver android:name="com.parse.ParseBroadcastReceiver" >
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.USER_PRESENT" />
</intent-filter>
</receiver>
</application>
</manifest>
My LogCat:
10-15 14:59:36.168: E/AndroidRuntime(1114): FATAL EXCEPTION: main
10-15 14:59:36.168: E/AndroidRuntime(1114): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.m.mech/com.parse.mech.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "com.parse.mech.MainActivity" on path: /data/app/com.m.mech-2.apk
10-15 14:59:36.168: E/AndroidRuntime(1114): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2106)
10-15 14:59:36.168: E/AndroidRuntime(1114): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
10-15 14:59:36.168: E/AndroidRuntime(1114): at android.app.ActivityThread.access600ドル(ActivityThread.java:141)
10-15 14:59:36.168: E/AndroidRuntime(1114): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
10-15 14:59:36.168: E/AndroidRuntime(1114): at android.os.Handler.dispatchMessage(Handler.java:99)
10-15 14:59:36.168: E/AndroidRuntime(1114): at android.os.Looper.loop(Looper.java:137)
10-15 14:59:36.168: E/AndroidRuntime(1114): at android.app.ActivityThread.main(ActivityThread.java:5039)
10-15 14:59:36.168: E/AndroidRuntime(1114): at java.lang.reflect.Method.invokeNative(Native Method)
10-15 14:59:36.168: E/AndroidRuntime(1114): at java.lang.reflect.Method.invoke(Method.java:511)
10-15 14:59:36.168: E/AndroidRuntime(1114): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
10-15 14:59:36.168: E/AndroidRuntime(1114): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
10-15 14:59:36.168: E/AndroidRuntime(1114): at dalvik.system.NativeStart.main(Native Method)
10-15 14:59:36.168: E/AndroidRuntime(1114): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.parse.mech.MainActivity" on path: /data/app/com.m.mech-2.apk
10-15 14:59:36.168: E/AndroidRuntime(1114): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:65)
10-15 14:59:36.168: E/AndroidRuntime(1114): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
10-15 14:59:36.168: E/AndroidRuntime(1114): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
10-15 14:59:36.168: E/AndroidRuntime(1114): at android.app.Instrumentation.newActivity(Instrumentation.java:1054)
10-15 14:59:36.168: E/AndroidRuntime(1114): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2097)
10-15 14:59:36.168: E/AndroidRuntime(1114): ... 11 more
10-15 14:59:47.998: E/Trace(1137): error opening trace file: No such file or directory (2)
Why am I getting this ClassNotFoundException?
-
Have you tried cleaning and rebuilding?Bryan Herbst– Bryan Herbst2013年10月15日 15:11:38 +00:00Commented Oct 15, 2013 at 15:11
-
your package name is package com.m.mech;Raghunandan– Raghunandan2013年10月15日 15:12:23 +00:00Commented Oct 15, 2013 at 15:12
6 Answers 6
This line in your manifest does not match your package/classname of your main activity:
android:name="com.parse.mech.MainActivity"
Change it to
android:name="com.m.mech.MainActivity"
Comments
use right package name for registering service and Activities in AndroidManifest.xml because package name is com.m.mech but you are currently using com.parse for registering.
....
<activity
android:name="com.m.mech.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<service android:name="com.m.mech.PushService" />
<receiver android:name="com.m.mech.ParseBroadcastReceiver" >
....
Comments
your main activity is in package com.m.mech but in your manifest file you put com.parse.mech.MainActivity as start point
Comments
whow.. if your packagename is correct, just clean the project and export it again.. It's worked for me !
Comments
For Android Studio
Even if after changing the package name in the manifest file is not working for you, just try to invalidate cache and reload the project. It worked for me.
All the files were correct for me but still there was this error. I just created classes using default templates in Android Studio
File > Invalidate Caches/Restart > Invalidate Cache and Restart (DIalog box)
For Eclipse
Clean the project and reload it again.
1 Comment
In my case the problem was the Theme!