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.access$600(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?
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"
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" >
....
your main activity is in package com.m.mech but in your manifest file you put com.parse.mech.MainActivity as start point
whow..
if your packagename is correct, just clean the project and export it again..
It's worked for me !
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.
In my case the problem was the Theme!
Related
please my app crashes whenever i click the navigation item to start activity. i Have tried all the solutions from similar questions in the last 6 hours to no avail. that includes registering the activity in manifest, changing intent (this,menu_profile.class); to (mainactivity.this, menu_profile.class); to `(getApplicationContext(), menu_profile.class);. googling permission (13) error to brought no solution.
snippet
else if (itemId == R.id.third) {
Intent intent = new Intent(getApplicationContext(), Menu_Profile.class);
startActivity(intent);
}
manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.majesty.adesanmi.viewpager_nav">
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:theme="#style/AppTheme">
<activity
android:name=".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>
<activity android:name=".Menu_Profile"
android:label="DestinationActivity"/>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</application>
</manifest>
Logcat error
06-16 09:46:56.913 2889-2889/? E/Trace: error opening trace file: Permission denied (13)
06-16 09:46:56.983 2889-2889/com.majesty.adesanmi.viewpager_nav E/dalvikvm: Could not find class 'android.graphics.drawable.RippleDrawable', referenced from method android.support.v7.widget.AppCompatImageHelper.hasOverlappingRendering
06-16 09:47:41.673 2889-2889/com.majesty.adesanmi.viewpager_nav E/AndroidRuntime: FATAL EXCEPTION: main
android.content.ActivityNotFoundException: Unable to find explicit activity class {com.majesty.adesanmi.viewpager_nav/com.majesty.adesanmi.viewpager_nav.Menu_About}; have you declared this activity in your AndroidManifest.xml?
at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1541)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1416)
at android.app.Activity.startActivityForResult(Activity.java:3351)
at android.support.v4.app.BaseFragmentActivityJB.startActivityForResult(BaseFragmentActivityJB.java:50)
at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:79)
at android.app.Activity.startActivityForResult(Activity.java:3312)
at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:859)
at android.app.Activity.startActivity(Activity.java:3522)
at android.app.Activity.startActivity(Activity.java:3490)
at com.majesty.adesanmi.viewpager_nav.MainActivity$2.onNavigationItemSelected(MainActivity.java:157)
at android.support.design.widget.NavigationView$1.onMenuItemSelected(NavigationView.java:156)
at android.support.v7.view.menu.MenuBuilder.dispatchMenuItemSelected(MenuBuilder.java:822)
at android.support.v7.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:156)
at android.support.v7.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:969)
at android.support.design.internal.NavigationMenuPresenter$1.onClick(NavigationMenuPresenter.java:342)
at android.view.View.performClick(View.java:4084)
at android.view.View$PerformClick.run(View.java:16966)
at android.os.Handler.handleCallback(Handler.java:615)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4745)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
just remove intent filter from your menu profilr activity this from your Manifist file or replace this
<?xml version="1.0" encoding="utf-8"?>
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:theme="#style/AppTheme">
<activity
android:name=".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>
<activity android:name=".Menu_Profile"
android:label="DestinationActivity"/>
</application>
My app crashes when run on AVD.
1)Did all the prescribed things by pushbots.
2)The jar file addition.
3)The extended class but no use.
my app crashes
THE ERROR LOG IS:
07-04 22:25:05.994: E/Trace(628): error opening trace file: No such file or directory (2)
07-04 22:25:06.152: D/AndroidRuntime(628): Shutting down VM
07-04 22:25:06.152: W/dalvikvm(628): threadid=1: thread exiting with uncaught exception (group=0x40a13300)
07-04 22:25:06.172: E/AndroidRuntime(628): FATAL EXCEPTION: main
07-04 22:25:06.172: E/AndroidRuntime(628): java.lang.RuntimeException: Unable to instantiate application com.csconnect: java.lang.ClassNotFoundException: com.csconnect
07-04 22:25:06.172: E/AndroidRuntime(628): at android.app.LoadedApk.makeApplication(LoadedApk.java:501)
07-04 22:25:06.172: E/AndroidRuntime(628): at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4124)
07-04 22:25:06.172: E/AndroidRuntime(628): at android.app.ActivityThread.access$1300(ActivityThread.java:130)
07-04 22:25:06.172: E/AndroidRuntime(628): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1255)
07-04 22:25:06.172: E/AndroidRuntime(628): at android.os.Handler.dispatchMessage(Handler.java:99)
07-04 22:25:06.172: E/AndroidRuntime(628): at android.os.Looper.loop(Looper.java:137)
07-04 22:25:06.172: E/AndroidRuntime(628): at android.app.ActivityThread.main(ActivityThread.java:4745)
07-04 22:25:06.172: E/AndroidRuntime(628): at java.lang.reflect.Method.invokeNative(Native Method)
07-04 22:25:06.172: E/AndroidRuntime(628): at java.lang.reflect.Method.invoke(Method.java:511)
07-04 22:25:06.172: E/AndroidRuntime(628): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
07-04 22:25:06.172: E/AndroidRuntime(628): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
07-04 22:25:06.172: E/AndroidRuntime(628): at dalvik.system.NativeStart.main(Native Method)
07-04 22:25:06.172: E/AndroidRuntime(628): Caused by: java.lang.ClassNotFoundException: com.csconnect
07-04 22:25:06.172: E/AndroidRuntime(628): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
07-04 22:25:06.172: E/AndroidRuntime(628): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
07-04 22:25:06.172: E/AndroidRuntime(628): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
07-04 22:25:06.172: E/AndroidRuntime(628): at android.app.Instrumentation.newApplication(Instrumentation.java:967)
07-04 22:25:06.172: E/AndroidRuntime(628): at android.app.LoadedApk.makeApplication(LoadedApk.java:496)
07-04 22:25:06.172: E/AndroidRuntime(628): ... 11 more
THE MANIFEST FILE IS:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.csconnect"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="20" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<!-- GCM requires a Google account. -->
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.DISABLE_KEYGUARD"/>
<permission android:name="com.csconnect.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="com.csconnect.permission.C2D_MESSAGE" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:name="com.csconnect"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.csconnect.MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="com.csconnect.MESSAGE" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity android:name="com.pushbots.push.PBMsg"/>
<activity android:name="com.pushbots.push.PBListener"/>
<receiver
android:name="com.google.android.gcm.GCMBroadcastReceiver"
android:permission="com.google.android.c2dm.permission.SEND" >
<intent-filter>
<!-- Receives the actual messages. -->
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<!-- Receives the registration id. -->
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<category android:name="com.csconnect" />
</intent-filter>
</receiver>
<receiver android:name="com.pushbots.push.MsgReceiver" />
<service android:name="com.pushbots.push.GCMIntentService" />
<service android:name="org.openudid.OpenUDID_service" >
<intent-filter>
<action android:name="org.openudid.GETUDID" />
</intent-filter>
</service>
<activity
android:name="com.csconnect.SecondActivity"
android:label="#string/title_activity_second" >
</activity>
<!-- GCM connects to Google Services. -->
</application>
</manifest>
THE MAINACTIVITY FILE IS:
package com.csconnect;
import com.pushbots.push.Pushbots;
import android.app.Activity;
public class MainActivity extends Activity {
public String PUSHBOTS_APPLICATION_ID = "---#the application ID#---";
public String SENDER_ID="-----#the sender ID-----#";
#Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Pushbots.init(this, SENDER_ID,PUSHBOTS_APPLICATION_ID);
Button inboxbutton = (Button) findViewById(R.id.button1);
inboxbutton.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
Intent intent = new Intent(MainActivity.this , SecondActivity.class);
startActivity(intent);
}
});
}
}
The Wrong Way:
Right click main project, choose Properties -> Java Build Path -> Projects -> Add..., this add the Android library Project as a dependency project in Android main project's build path, this does not work. If all required Android-related resources are defined in main project, you will not get any error at compile time, but when run the application, you get the exception described in the question.
The Correct Way:
Right click main project, choose Properties -> Android, in the Library section, add your Android library project here. Check out official dev guide Referencing a library project. This should fix all your problem. Also note that you have to use relative path reference the actual Android library project, as stated in the Library Project - Development considerations.
I faced the same problem. I added the library in the correct way but had the same porblem. My solution was to update the android-support-v4.jar to android-support-v13.jar. Afterwards it worked perfect!!
I got a very strange issue. Im using ActionbarSherlock in my project. And on very few Devices i get a:
java.lang.RuntimeException: Unable to start activity ComponentInfo{de.felitec.dow/de.felitec.dow.ui.LoginActivity}: java.lang.IllegalStateException: You must use Theme.Sherlock, Theme.Sherlock.Light, Theme.Sherlock.Light.DarkActionBar, or a derivative.
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1815)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1831)
at android.app.ActivityThread.access$500(ActivityThread.java:122)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1024)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:132)
at android.app.ActivityThread.main(ActivityThread.java:4123)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:491)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:849)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:607)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.IllegalStateException: You must use Theme.Sherlock, Theme.Sherlock.Light, Theme.Sherlock.Light.DarkActionBar, or a derivative.
at com.actionbarsherlock.internal.ActionBarSherlockCompat.generateLayout(ActionBarSherlockCompat.java:976)
at com.actionbarsherlock.internal.ActionBarSherlockCompat.installDecor(ActionBarSherlockCompat.java:902)
at com.actionbarsherlock.internal.ActionBarSherlockCompat.setContentView(ActionBarSherlockCompat.java:836)
at com.actionbarsherlock.app.SherlockActivity.setContentView(SherlockActivity.java:229)
at de.felitec.dow.ui.LoginActivity.onCreate(LoginActivity.java:36)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1053)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1779)
... 11 more
My LoginActivity looks like this:
public class LoginActivity extends SherlockActivity implements AuthCallback<OAuthConsumer> {
private ProgressDialog progDialog;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.login);
}
...
And my Manifest:
<application
android:label="#string/app_name"
android:icon="#drawable/ic_app_launcher"
android:name=".MainApplication"
android:theme="#style/MainAppTheme">
<activity
android:name=".ui.SplashActivity"
android:screenOrientation="portrait"
android:theme="#style/Theme.Sherlock.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity
android:name=".ui.LoginActivity"
android:windowSoftInputMode="adjustPan|stateHidden"
android:screenOrientation="portrait"/>
...
And finally my style.xml:
<style name="MainAppTheme" parent="#style/Theme.Sherlock.Light.DarkActionBar">
<item name="homeAsUpIndicator">#drawable/back_indicator</item>
...
Notice that the SplashActivity works just fine. When it starts the intent for LoginActivity it crashes, and i dont really see why.
thanks in advance
Update your Manifiest file with this.
android:theme="#style/Theme.Sherlock"
I got the stack trace below in the Android developer account. There is just one occurrence of this error.
java.lang.RuntimeException: Unable to instantiate application com.mysite.myapp.TestApplication: java.lang.ClassNotFoundException: com.mysite.myapp.TestApplication in loader dalvik.system.PathClassLoader[/data/app-private/com.mysite.myapp-2.apk]
at android.app.LoadedApk.makeApplication(LoadedApk.java:466)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:3268)
at android.app.ActivityThread.access$2200(ActivityThread.java:117)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:973)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3691)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:912)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:670)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: com.myapp.myapp.TestApplication in loader dalvik.system.PathClassLoader[/data/app-private/com.mysite.myapp-2.apk]
at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at android.app.Instrumentation.newApplication(Instrumentation.java:945)
at android.app.LoadedApk.makeApplication(LoadedApk.java:461)
... 11 more
In my manifest file, I have declared com.mysite.myapp.TestApplication.
My Manifest file looks like this:
<application
android:name="com.mysite.myapp.TestApplication"
android:icon="#drawable/app_icon"
android:label="#string/app_name"
android:theme="#style/Theme.myapp" >
<activity
android:name="com.mysite.myapp.ActivityDashboard"
android:configChanges="orientation|keyboard"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
...
If your main home page is ActivityDashboard.java
insert as below or if TestApplication.java
replace .ActivityDashboard as .TestApplication in the activity tag
<package name="com.mysite.myapp"
<application
android:name="TestApplication"
android:icon="#drawable/app_icon"
android:label="#string/app_name"
android:theme="#style/Theme.myapp" >
<activity android:name=".ActivityDashboard" android:configChanges="orientation|keyboard"
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>
android:name="com.mysite.myapp.ActivityDashboard"
Replace thr above in your manifest with the below.
android:name=".ActivityDashboard"
Alternatively:
android:name="com.mysite.myapp.TestApplication.ActivityDashboard"
I have an app with ~11k active installs for which I sometimes receive ClassNotFoundExceptions that I can't explain. They look like this:
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{name.of.my.MainActivityClass}: java.lang.ClassNotFoundException: name.of.my.MainActivityClass in loader dalvik.system.PathClassLoader[/mnt/asec/name.of.my-2/pkg.apk]
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1743)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1851)
at android.app.ActivityThread.access$1500(ActivityThread.java:132)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1038)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:150)
at android.app.ActivityThread.main(ActivityThread.java:4293)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:849)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:607)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: name.of.my.MainActivityClass in loader dalvik.system.PathClassLoader[/mnt/asec/name.of.my-2/pkg.apk]
at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at android.app.Instrumentation.newActivity(Instrumentation.java:1040)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1735)
... 11 more
I received some of these exceptions from users that updated my app (not only for the most recent version), so I think it is not a problem that is specific to some phones as the app worked for them before.
I got these exception reports for my main activity class, a receiver class and a BackupAgent class.
All of those classes are always instantiated directly from Android. My Manifest file looks like this:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="name.of.my"
android:versionCode="20"
android:versionName="1.10.2"
android:installLocation="auto">
<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="8" />
<application android:icon="#drawable/icon" android:label="#string/app_name" android:backupAgent="name.of.my.OwnBackupAgent">
<activity android:name="name.of.my.MainActivityClass"
android:label="#string/app_name"
android:theme="#style/MyTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<receiver android:name="name.of.my.OwnReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.media.RINGER_MODE_CHANGED" />
</intent-filter>
</receiver>
</application>
</manifest>
After searching the net for some hours, the most likely explanations I found are:
it might be related to moving the app to SD card while there are still some services running (but the android dev guide says that all services are canceled in this case, and it doesn't explain why my main activity class suddenly can't be found anymore)
the .apk might be corrupted after updating via the android market. Could this be true? If yes, what can I do against it - if not, what else might be the problem?