please i tried coding an android app using eclipse luna. I am writing a client gcm codes to push notifications. I have finished without any compiling errors, but wen i execute it on the mobile phone, the app crashes. Please below is the log i have been getting. Thanks for helping
05-23 23:07:27.303: D/AndroidRuntime(18211): Shutting down VM
05-23 23:07:27.303: W/dalvikvm(18211): threadid=1: thread exiting with uncaught exception (group=0x41f522a0)
05-23 23:07:27.303: E/AndroidRuntime(18211): FATAL EXCEPTION: main
05-23 23:07:27.303: E/AndroidRuntime(18211): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.prgguru.example/com.prgguru.example.MainActivity}: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.prgguru.example/com.prgguru.example.HomeActivity}; have you declared this activity in your AndroidManifest.xml? 05-23 23:07:27.303: E/AndroidRuntime(18211): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2110)
05-23 23:07:27.303: E/AndroidRuntime(18211): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2135)
05-23 23:07:27.303: E/AndroidRuntime(18211): at android.app.ActivityThread.access$700(ActivityThread.java:140)
05-23 23:07:27.303: E/AndroidRuntime(18211): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1237)
05-23 23:07:27.303: E/AndroidRuntime(18211): at android.os.Handler.dispatchMessage(Handler.java:99)
05-23 23:07:27.303: E/AndroidRuntime(18211): at android.os.Looper.loop(Looper.java:137)
05-23 23:07:27.303: E/AndroidRuntime(18211): at android.app.ActivityThread.main(ActivityThread.java:4921)
05-23 23:07:27.303: E/AndroidRuntime(18211): at java.lang.reflect.Method.invokeNative(Native Method)
05-23 23:07:27.303: E/AndroidRuntime(18211): at java.lang.reflect.Method.invoke(Method.java:511)
05-23 23:07:27.303: E/AndroidRuntime(18211): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1038)
05-23 23:07:27.303: E/AndroidRuntime(18211): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:805)
05-23 23:07:27.303: E/AndroidRuntime(18211): at dalvik.system.NativeStart.main(Native Method)
05-23 23:07:27.303: E/AndroidRuntime(18211): Caused by: android.content.ActivityNotFoundException: Unable to find explicit activityclass {com.prgguru.example/com.prgguru.example.HomeActivity}; have you declared this activity in your AndroidManifest.xml?
05-23 23:07:27.303: E/AndroidRuntime(18211): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1556)
05-23 23:07:27.303: E/AndroidRuntime(18211): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1431)
05-23 23:07:27.303: E/AndroidRuntime(18211): at android.app.Activity.startActivityForResult(Activity.java:3428)
05-23 23:07:27.303: E/AndroidRuntime(18211): at android.app.Activity.startActivityForResult(Activity.java:3389)
05-23 23:07:27.303: E/AndroidRuntime(18211): at android.app.Activity.startActivity(Activity.java:3599)
05-23 23:07:27.303: E/AndroidRuntime(18211): at android.app.Activity.startActivity(Activity.java:3567)
05-23 23:07:27.303: E/AndroidRuntime(18211): at com.prgguru.example.MainActivity.onCreate(MainActivity.java:61)
05-23 23:07:27.303: E/AndroidRuntime(18211): at android.app.Activity.performCreate(Activity.java:5188)
05-23 23:07:27.303: E/AndroidRuntime(18211): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094)
05-23 23:07:27.303: E/AndroidRuntime(18211): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2074)
05-23 23:07:27.303: E/AndroidRuntime(18211): ... 11 more
05-23 23:07:27.343: D/dalvikvm(18211): GC_CONCURRENT freed 224K, 13% free 7212K/8199K, paused 12ms+2ms, total 35ms
below is also my manifest file. this is how i make the manifest file
`<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.prgguru.example"
android:versionCode="1"
android:versionName="1.0" >
<!-- GCM requires Android SDK version 2.2 (API level 8) or above. -->
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="22" />
<!-- GCM connects to Internet Services. -->
<uses-permission android:name="android.permission.INTERNET" />
<!-- GCM requires a Google account. -->
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<!-- Keeps the processor from sleeping when a message is received. -->
<uses-permission android:name="android.permission.WAKE_LOCK" />
<!-- Creates a custom permission so only this app can receive its messages. -->
<permission
android:name="com.prgguru.example.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="com.prgguru.example.permission.C2D_MESSAGE" />
<!-- This app has permission to register and receive data message. -->
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<!-- Network State Permissions to detect Internet status -->
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<!-- Permission to vibrate -->
<uses-permission android:name="android.permission.VIBRATE" />
<!-- Main activity. -->
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<meta-data android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
<!-- Register Activity -->
<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>
<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.prgguru.example" />
</intent-filter>
</receiver>
<service android:name=".GCMNotificationIntentService" />
</application>
</manifest>`
Whenever you make a new Activity and are going to display it you need to add a reference to it in your AndroidManifest.xml
For example you can simply do
<activity name="your.package.activityname" />
For more information see, Declaring class names in the documentation.
Related
I have finally finished my app and everything was working fine. I went back to add in the admob stuff and now it will not start in the emulator. it says it successfully installed the app on the emulator but it does not launch and the icon is not visible to try to manually run. I think the manifest is where my error is but I am unsure.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.androidsleepmachine.gamble"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="16"
android:targetSdkVersion="18" />
<uses-permission android:name="android.permission.WAKE_LOCK" >
</uses-permission>
<uses-permission android:name="android.permission.Internet" >
</uses-permission>
<uses-permission android:name="android.permission.Write_EXTERNAL_STORAGE" >
</uses-permission>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" >
</uses-permission>
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.google.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation"
></activity>
<activity
android:name=".Splash"
android:label="#string/app_name"
android:theme="#android:style/Theme.Dialog" >
<intent-filter>
<action android:name="com.AndroidSleepMachine.gamble.SPLASH" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name="com.AndroidSleepMachine.gamble.HOME"
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=".About"
android:label="#string/app_name"
android:theme="#android:style/Theme.Dialog" >
<intent-filter>
<action android:name="com.AndroidSleepMachine.gamble.ABOUT" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity android:name="com.androidsleepmachine.gamble.Ship" />
<activity android:name="com.androidsleepmachine.gamble.OceanThunder" />
<activity android:name="com.androidsleepmachine.gamble.Ocean" />
<activity android:name="com.androidsleepmachine.gamble.Forest" />
<activity android:name="com.androidsleepmachine.gamble.Rain" />
<activity android:name="com.androidsleepmachine.gamble.Thunderbirds" />
<activity android:name="com.androidsleepmachine.gamble.Meditation" />
<activity android:name="com.androidsleepmachine.gamble.Focus" />
<activity android:name="com.androidsleepmachine.gamble.Pain" />
</application>
</manifest>
logcat files
09-23 13:17:47.582: E/AndroidRuntime(1563): FATAL EXCEPTION: main
09-23 13:17:47.582: E/AndroidRuntime(1563): java.lang.RuntimeException: Unable to
instantiate activity
ComponentInfo{com.androidsleepmachine.gamble/com.AndroidSleepMachine.gamble.HOME}:
java.lang.ClassNotFoundException: com.AndroidSleepMachine.gamble.HOME
09-23 13:17:47.582: E/AndroidRuntime(1563): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1983)
09-23 13:17:47.582: E/AndroidRuntime(1563): at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
09-23 13:17:47.582: E/AndroidRuntime(1563): at
android.app.ActivityThread.access$600(ActivityThread.java:130)
09-23 13:17:47.582: E/AndroidRuntime(1563): at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
09-23 13:17:47.582: E/AndroidRuntime(1563): at
android.os.Handler.dispatchMessage(Handler.java:99)
09-23 13:17:47.582: E/AndroidRuntime(1563): at
android.os.Looper.loop(Looper.java:137)
09-23 13:17:47.582: E/AndroidRuntime(1563): at
android.app.ActivityThread.main(ActivityThread.java:4745)
09-23 13:17:47.582: E/AndroidRuntime(1563): at
java.lang.reflect.Method.invokeNative(Native Method)
09-23 13:17:47.582: E/AndroidRuntime(1563): at
java.lang.reflect.Method.invoke(Method.java:511)
09-23 13:17:47.582: E/AndroidRuntime(1563): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
09-23 13:17:47.582: E/AndroidRuntime(1563): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
09-23 13:17:47.582: E/AndroidRuntime(1563): at
dalvik.system.NativeStart.main(Native Method)
09-23 13:17:47.582: E/AndroidRuntime(1563): Caused by:
java.lang.ClassNotFoundException: com.AndroidSleepMachine.gamble.HOME
09-23 13:17:47.582: E/AndroidRuntime(1563): at
dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
09-23 13:17:47.582: E/AndroidRuntime(1563): at
java.lang.ClassLoader.loadClass(ClassLoader.java:501)
09-23 13:17:47.582: E/AndroidRuntime(1563): at
java.lang.ClassLoader.loadClass(ClassLoader.java:461)
09-23 13:17:47.582: E/AndroidRuntime(1563): at
android.app.Instrumentation.newActivity(Instrumentation.java:1053)
09-23 13:17:47.582: E/AndroidRuntime(1563): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1974)
It looks like your main activity name is incorrect. Java is case sensitive and your application package name is
package="com.androidsleepmachine.gamble"
while your main activity class name is
com.AndroidSleepMachine.gamble.HOME
The ClassNotFoundException is being thrown because your Activity class name is incorrect in the manifest and isn't being found by the class loader.
It cannot find a class called:
com.AndroidSleepMachine.gamble.HOME
Why is "AndroidSleepMachine" using capital letters?
Why not just use:
android:name=".HOME"
...if your class is indeed called HOME.java? Case-sensitivity may be causing your issue.
com.AndroidSleepMachine.gamble.HOME is not the same as com.androidsleepmachine.gamble.HOME
I have developed test application Using worklight for android environment. When i test that on worklight server it works fine, but when i tried to run the same on android virtual device (AVD) it throws an error message like Sorry The application Test (process com.Test) has stopped unexpectedly. Please try again. and the application terminates.
I am using Eclipse 4.2 and android version for AVD is 2.3.3
What is the solution of this...???
`
06-21 10:59:28.407: W/dalvikvm(1209): Unable to resolve superclass of Lcom/Test/Test; (14)
06-21 10:59:28.407: W/dalvikvm(1209): Link of class 'Lcom/Test/Test;' failed
06-21 10:59:28.427: D/AndroidRuntime(1209): Shutting down VM
06-21 10:59:28.427: W/dalvikvm(1209): threadid=1: thread exiting with uncaught exception (group=0xb607d4f0)
06-21 10:59:28.467: E/AndroidRuntime(1209): FATAL EXCEPTION: main
06-21 10:59:28.467: E/AndroidRuntime(1209): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.Test/com.Test.Test}: java.lang.ClassNotFoundException: com.Test.Test in loader dalvik.system.PathClassLoader[/data/app/com.Test-1.apk]
06-21 10:59:28.467: E/AndroidRuntime(1209): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1569)
06-21 10:59:28.467: E/AndroidRuntime(1209): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
06-21 10:59:28.467: E/AndroidRuntime(1209): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
06-21 10:59:28.467: E/AndroidRuntime(1209): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
06-21 10:59:28.467: E/AndroidRuntime(1209): at android.os.Handler.dispatchMessage(Handler.java:99)
06-21 10:59:28.467: E/AndroidRuntime(1209): at android.os.Looper.loop(Looper.java:130)
06-21 10:59:28.467: E/AndroidRuntime(1209): at android.app.ActivityThread.main(ActivityThread.java:3683)
06-21 10:59:28.467: E/AndroidRuntime(1209): at java.lang.reflect.Method.invokeNative(Native Method)
06-21 10:59:28.467: E/AndroidRuntime(1209): at java.lang.reflect.Method.invoke(Method.java:507)
06-21 10:59:28.467: E/AndroidRuntime(1209): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
06-21 10:59:28.467: E/AndroidRuntime(1209): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
06-21 10:59:28.467: E/AndroidRuntime(1209): at dalvik.system.NativeStart.main(Native Method)
06-21 10:59:28.467: E/AndroidRuntime(1209): Caused by: java.lang.ClassNotFoundException: com.Test.Test in loader dalvik.system.PathClassLoader[/data/app/com.Test-1.apk]
06-21 10:59:28.467: E/AndroidRuntime(1209): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
06-21 10:59:28.467: E/AndroidRuntime(1209): at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
06-21 10:59:28.467: E/AndroidRuntime(1209): at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
06-21 10:59:28.467: E/AndroidRuntime(1209): at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
06-21 10:59:28.467: E/AndroidRuntime(1209): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1561)
06-21 10:59:28.467: E/AndroidRuntime(1209): ... 11 more
`
Manifest code:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.Test"
android:versionCode="1"
android:versionName="1.0">
<supports-screens
android:smallScreens="false"
android:normalScreens="true"
android:largeScreens="false"
android:resizeable="false"
android:anyDensity="false"
/>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<!-- Push permissions -->
<permission android:name="com.Test.permission.C2D_MESSAGE" android:protectionLevel="signature" />
<uses-permission android:name="com.Test.permission.C2D_MESSAGE" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.USE_CREDENTIALS" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<application
android:label="#string/app_name"
android:debuggable="true"
android:icon="#drawable/icon" >
<activity android:name=".Test"
android:label="#string/app_name"
android:configChanges="orientation|keyboardHidden"
android:launchMode="singleTask">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="com.Test.Test.NOTIFICATION" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<!-- Preference Activity -->
<activity
android:name="com.worklight.common.WLPreferences"
android:label="Worklight Settings">
</activity>
<!-- Push service -->
<!-- In order to use the c2dm library, an application must declare a class with the name C2DMReceiver, in its own package, extending com.google.android.c2dm.C2DMBaseReceiver
It must also include this section in the manifest, replacing "com.google.android.apps.chrometophone" with its package name. -->
<service android:name=".GCMIntentService" />
<!-- Only google service can send data messages for the app. If permission is not set - any other app can generate it -->
<receiver android:name="com.google.android.gcm.GCMBroadcastReceiver" android:permission="com.google.android.c2dm.permission.SEND">
<!-- Receive the actual message -->
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<category android:name="com.Test" />
</intent-filter>
<!-- Receive the registration id -->
<intent-filter>
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<category android:name="com.Test" />
</intent-filter>
</receiver>
</application>
<uses-sdk android:minSdkVersion="10" />
</manifest>
Test.Java
package com.Test;
import android.os.Bundle;
import com.worklight.androidgap.WLDroidGap;
public class Test extends WLDroidGap {
#Override
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
}
/**
* onWLInitCompleted is called when the Worklight runtime framework initialization is complete
*/
#Override
public void onWLInitCompleted(Bundle savedInstanceState){
super.loadUrl(getWebMainFilePath());
// Add custom initialization code after this line
}
}
AVD 2.3.x has a known bug which prevents it from running WebView based apps. Use OS 4.x or 2.2.
I have developed an application and implemented GCM(Google Cloud Messaging), it works perfectly fine on the emulator as well as on bluestacks but when I run it on a device it stops unfortunately and I can't get the reason.
Manifest file
<uses-sdk android:minSdkVersion="8" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.androiddemos.NotificationActivity"
android:label="#string/app_name" >
</activity>
<activity
android:name=".ResultActivity"
android:parentActivityName=".MainActivity" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".NotificationActivity" />
</activity>
<activity
android:name=".GcmActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<receiver
android:name="com.google.android.gcm.GCMBroadcastReceiver"
android:permission="com.google.android.c2dm.permission.SEND" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<category android:name="com.example.androiddemos" />
</intent-filter>
</receiver>
<service android:name=".GCMIntentService" >
</service>
</application>
<permission
android:name="com.example.androiddemos.permission.C2D_MESSAGE"
android:protectionLevel="signature" >
</permission>
<!-- App receives GCM messages. -->
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<!-- GCM connects to Google Services. -->
<uses-permission android:name="android.permission.INTERNET" />
<!-- GCM requires a Google account. -->
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<!-- Keeps the processor from sleeping when a message is received. -->
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="com.example.androiddemos.permission.C2D_MESSAGE" />
LOgcat
01-09 14:55:27.034: E/AndroidRuntime(25344): java.lang.IllegalArgumentException: android.content.pm.PackageManager$NameNotFoundException: ComponentInfo{com.example.androiddemos/com.example.androiddemos.MainActivity}
01-09 14:55:27.034: E/AndroidRuntime(25344): at android.support.v4.app.TaskStackBuilder.addParentStack(TaskStackBuilder.java:236)
01-09 14:55:27.034: E/AndroidRuntime(25344): at android.support.v4.app.TaskStackBuilder.addParentStack(TaskStackBuilder.java:215)
01-09 14:55:27.034: E/AndroidRuntime(25344): at com.example.androiddemos.GcmActivity.sendNotification(GcmActivity.java:70)
01-09 14:55:27.034: E/AndroidRuntime(25344): at com.example.androiddemos.GcmActivity.checkGCM(GcmActivity.java:49)
01-09 14:55:27.034: E/AndroidRuntime(25344): at com.example.androiddemos.GcmActivity$1.onClick(GcmActivity.java:33)
01-09 14:55:27.034: E/AndroidRuntime(25344): at android.view.View.performClick(View.java:4084)
01-09 14:55:27.034: E/AndroidRuntime(25344): at android.view.View$PerformClick.run(View.java:16966)
01-09 14:55:27.034: E/AndroidRuntime(25344): at android.os.Handler.handleCallback(Handler.java:615)
01-09 14:55:27.034: E/AndroidRuntime(25344): at android.os.Handler.dispatchMessage(Handler.java:92)
01-09 14:55:27.034: E/AndroidRuntime(25344): at android.os.Looper.loop(Looper.java:137)
01-09 14:55:27.034: E/AndroidRuntime(25344): at android.app.ActivityThread.main(ActivityThread.java:4745)
01-09 14:55:27.034: E/AndroidRuntime(25344): at java.lang.reflect.Method.invokeNative(Native Method)
01-09 14:55:27.034: E/AndroidRuntime(25344): at java.lang.reflect.Method.invoke(Method.java:511)
01-09 14:55:27.034: E/AndroidRuntime(25344): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
01-09 14:55:27.034: E/AndroidRuntime(25344): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
01-09 14:55:27.034: E/AndroidRuntime(25344): at dalvik.system.NativeStart.main(Native Method)
01-09 14:55:27.034: E/AndroidRuntime(25344): Caused by: android.content.pm.PackageManager$NameNotFoundException: ComponentInfo{com.example.androiddemos/com.example.androiddemos.MainActivity}
01-09 14:55:27.034: E/AndroidRuntime(25344): at android.app.ApplicationPackageManager.getActivityInfo(ApplicationPackageManager.java:225)
01-09 14:55:27.034: E/AndroidRuntime(25344): at android.support.v4.app.NavUtils.getParentActivityName(NavUtils.java:298)
01-09 14:55:27.034: E/AndroidRuntime(25344): at android.support.v4.app.NavUtils.getParentActivityIntent(NavUtils.java:261)
01-09 14:55:27.034: E/AndroidRuntime(25344): at android.support.v4.app.TaskStackBuilder.addParentStack(TaskStackBuilder.java:229)
01-09 14:55:27.034: E/AndroidRuntime(25344): ... 15 more
I believe the problem is because you do not have MainActivity defined in your manifest based on this logcat line:
14:55:27.034: E/AndroidRuntime(25344): Caused by:
android.content.pm.PackageManager$NameNotFoundException:
ComponentInfo{com.example.androiddemos/com.example.androiddemos.MainActivity} 01-09
You have MainActivity referenced as the parentActivityName but not defined in the manifest at all:
<activity
android:name=".ResultActivity"
android:parentActivityName=".MainActivity" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".NotificationActivity" />
</activity>
If you are still using MainActivity you will need to add it to the manifest:
<activity
android:name=".MainActivity">
</activity>
am getting this exception:
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{business.premium/business.premium.Problemio}:
java.lang.ClassNotFoundException: business.premium.Problemio
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1880)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
at android.app.ActivityThread.access$600(ActivityThread.java:123)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4424)
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:784)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: business.premium.Problemio
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
at android.app.Instrumentation.newActivity(Instrumentation.java:1023)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1871)
... 11 more
java.lang.ClassNotFoundException: business.premium.Problemio
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
at android.app.Instrumentation.newActivity(Instrumentation.java:1023)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1871)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
at android.app.ActivityThread.access$600(ActivityThread.java:123)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4424)
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:784)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
at dalvik.system.NativeStart.main(Native Method)
it says that class is not there, but it IS there. I tried to configure things in my project's build path, but not too sure what to tweak there.
And here is how I start my Manifest file:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="business.premium"
android:versionCode="1"
android:versionName="1.0" >
<supports-screens android:largeScreens="true" android:normalScreens="true" android:smallScreens="true"/>
<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="15"/>
<uses-permission android:name="android.permission.INTERNET" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/CustomTheme"
android:name="MyApplication"
android:debuggable="true">
<activity
android:name=".Problemio"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Any thoughts on how to solve this, or what to look into? Thanks!
Its because you specified the "android:name" attribute in the application node in the manifest file.
Do not use the android:name attribute!
It, misleadingly, does not have anything to do with the name of your app and is actually the name of an extra class to load before loading your application. That's why you are getting the ClassNotFoundException.
Remove it and it should work:
<application
android:icon="#drawable/icon"
android:label="#string/app_name"
android:description="#string/help_text" >
This answer is taken from: java.lang.ClassNotFoundException on working app
My app has been running okay until the recent Froyo update. After installing the Android 2.2 SDK, I can compile my code without any errors. However, when I run it, it just force closes:
Here's the log:
05-23 10:15:13.463: DEBUG/AndroidRuntime(423): >>>>>>>>>>>>>> AndroidRuntime START <<<<<<<<<<<<<<
05-23 10:15:13.463: DEBUG/AndroidRuntime(423): CheckJNI is ON
05-23 10:15:14.193: DEBUG/AndroidRuntime(423): --- registering native functions ---
05-23 10:15:15.293: DEBUG/AndroidRuntime(423): Shutting down VM
05-23 10:15:15.303: DEBUG/dalvikvm(423): Debugger has detached; object registry had 1 entries
05-23 10:15:15.333:
INFO/AndroidRuntime(423): NOTE: attach of thread 'Binder Thread #3' failed
05-23 10:15:16.003: DEBUG/AndroidRuntime(431): >>>>>>>>>>>>>> AndroidRuntime START <<<<<<<<<<<<<<
05-23 10:15:16.013:
DEBUG/AndroidRuntime(431): CheckJNI is ON
05-23 10:15:16.273: DEBUG/AndroidRuntime(431): --- registering native functions ---
05-23 10:15:17.392: INFO/ActivityManager(59): Starting activity: Intent { act=android.intent.action.MAIN cat=
[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.handyapps.easymoney/.EasyMoney }
05-23 10:15:17.602: DEBUG/AndroidRuntime(431): Shutting down VM
05-23 10:15:17.662: DEBUG/dalvikvm(431): Debugger has detached; object registry had 1 entries
05-23 10:15:17.742: INFO/AndroidRuntime(431): NOTE: attach of thread 'Binder Thread #3' failed
05-23 10:15:17.912: INFO/ActivityManager(59): Start proc com.handyapps.easymoney for activity
com.handyapps.easymoney/.EasyMoney: pid=438 uid=10035 gids={1006, 1015}
05-23 10:15:19.032: DEBUG/AndroidRuntime(438): Shutting down VM
05-23 10:15:19.032: WARN/dalvikvm(438): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
05-23
10:15:19.062: ERROR/AndroidRuntime(438): FATAL EXCEPTION: main
05-23 10:15:19.062: ERROR/AndroidRuntime(438): java.lang.RuntimeException: Unable to instantiate application
com.handyapps.easymoney.EasyMoney: java.lang.ClassCastException: com.handyapps.easymoney.EasyMoney
05-23 10:15:19.062: ERROR/AndroidRuntime(438): at android.app.ActivityThread$PackageInfo.makeApplication
(ActivityThread.java:649)
05-23 10:15:19.062: ERROR/AndroidRuntime(438): at android.app.ActivityThread.handleBindApplication
(ActivityThread.java:4232)
05-23 10:15:19.062: ERROR/AndroidRuntime(438): at android.app.ActivityThread.access$3000(ActivityThread.java:125)
05-23 10:15:19.062: ERROR/AndroidRuntime(438): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2071)
05-23 10:15:19.062: ERROR/AndroidRuntime(438): at android.os.Handler.dispatchMessage(Handler.java:99)
05-23 10:15:19.062: ERROR/AndroidRuntime(438): at android.os.Looper.loop(Looper.java:123)
05-23 10:15:19.062: ERROR/AndroidRuntime(438): at android.app.ActivityThread.main(ActivityThread.java:4627)
05-23 10:15:19.062: ERROR/AndroidRuntime(438): at java.lang.reflect.Method.invokeNative(Native Method)
05-23 10:15:19.062: ERROR/AndroidRuntime(438): at java.lang.reflect.Method.invoke(Method.java:521)
05-23 10:15:19.062: ERROR/AndroidRuntime(438): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run
(ZygoteInit.java:868)
05-23 10:15:19.062: ERROR/AndroidRuntime(438): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
05-23 10:15:19.062: ERROR/AndroidRuntime(438): at dalvik.system.NativeStart.main(Native Method)
05-23 10:15:19.062: ERROR/AndroidRuntime(438): Caused by: java.lang.ClassCastException: com.handyapps.easymoney.EasyMoney
05-23 10:15:19.062: ERROR/AndroidRuntime(438): at android.app.Instrumentation.newApplication(Instrumentation.java:957)
05-23 10:15:19.062: ERROR/AndroidRuntime(438): at android.app.Instrumentation.newApplication(Instrumentation.java:942)
05-23 10:15:19.062: ERROR/AndroidRuntime(438): at android.app.ActivityThread$PackageInfo.makeApplication
(ActivityThread.java:644)
05-23 10:15:19.062: ERROR/AndroidRuntime(438): ... 11 more
05-23 10:15:19.082: WARN/ActivityManager(59): Force finishing activity com.handyapps.easymoney/.EasyMoney
05-23 10:15:19.592: WARN/ActivityManager(59): Activity pause timeout for HistoryRecord{450018f0
com.handyapps.easymoney/.EasyMoney}
//////////////THE ANDROID MANIFEST FILE////
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.permission.CAMERA"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-feature android:name="android.hardware.camera" />
<uses-sdk android:minSdkVersion="3" android:targetSdkVersion="4" />
<application android:icon="#drawable/icon"
android:name="#string/app_name" android:label="#string/app_name"
android:debuggable="false">
<activity android:name=".EasyMoney"
android:label="#string/app_name"
android:theme="#android:style/Theme.NoTitleBar"
android:launchMode="singleTask"
android:clearTaskOnLaunch="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".TranList" android:label="#string/app_name" android:theme="#android:style/Theme.Light.NoTitleBar"/>
<activity android:name=".TranEdit" android:theme="#android:style/Theme.Light.NoTitleBar" android:windowSoftInputMode="stateAlwaysHidden"/>
<activity android:name=".BillReminderEdit" android:theme="#android:style/Theme.Light.NoTitleBar" android:windowSoftInputMode="stateAlwaysHidden"/>
<activity android:name=".BillReminderList" android:launchMode="singleTop" android:theme="#android:style/Theme.Light.NoTitleBar"/>
<activity android:name=".BudgetList" android:theme="#android:style/Theme.Light.NoTitleBar"/>
<activity android:name=".BudgetEdit" android:theme="#android:style/Theme.Light.NoTitleBar" android:windowSoftInputMode="stateAlwaysHidden"/>
<activity android:name=".Search" android:theme="#style/CustomDialogTheme" android:windowSoftInputMode="stateAlwaysHidden"/>
<activity android:name=".PasscodeEntry" android:theme="#style/CustomDialogTheme" android:windowSoftInputMode="stateAlwaysHidden" android:screenOrientation="portrait"/>
<activity android:name=".AccountList" android:theme="#android:style/Theme.Light.NoTitleBar">
</activity>
<activity android:name=".AccountEdit" android:theme="#android:style/Theme.Light.NoTitleBar" android:windowSoftInputMode="stateAlwaysHidden"/>
<activity android:name=".UserSettingsEdit" android:theme="#android:style/Theme.Light.NoTitleBar" android:windowSoftInputMode="stateAlwaysHidden"/>
<activity android:name=".CurrencySettingsEdit" android:theme="#android:style/Theme.Light.NoTitleBar" android:windowSoftInputMode="stateAlwaysHidden"/>
<activity android:name=".DisplaySettingsEdit" android:theme="#android:style/Theme.Light.NoTitleBar" android:windowSoftInputMode="stateAlwaysHidden"/>
<activity android:name=".BackupSettingsEdit" android:theme="#android:style/Theme.Light.NoTitleBar" android:windowSoftInputMode="stateAlwaysHidden"/>
<activity android:name=".CategoryList" android:theme="#android:style/Theme.Light.NoTitleBar" />
<activity android:name=".CategoryEdit" android:theme="#android:style/Theme.Light.NoTitleBar" android:windowSoftInputMode="stateAlwaysHidden"/>
<activity android:name=".ExpenseByCategory" android:theme="#android:style/Theme.Light.NoTitleBar"/>
<activity android:name=".BalanceReport" android:theme="#android:style/Theme.Light.NoTitleBar"/>
<activity android:name=".MonthlyExpenseReport" android:theme="#android:style/Theme.Light.NoTitleBar"/>
<activity android:name=".MonthlyIncomeReport" android:theme="#android:style/Theme.Light.NoTitleBar"/>
<activity android:name=".MonthlyCashflowReport" android:theme="#android:style/Theme.Light.NoTitleBar"/>
<activity android:name=".PhotoList" android:theme="#android:style/Theme.Light.NoTitleBar" />
<activity android:name=".ExpenseByPayee" android:theme="#android:style/Theme.Light.NoTitleBar"/>
<activity android:name=".ExpenseBySubCategory" android:theme="#android:style/Theme.Light.NoTitleBar"/>
<service android:name="StartAlarm_Service">
<intent-filter>
<action android:name="com.handyapps.easymoney.StartAlarm_Service" />
</intent-filter>
</service>
<service android:name=".AlarmService_Service" android:process=":remote" />
<receiver android:name="StartupIntentReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<category android:name="android.intent.category.HOME" />
</intent-filter>
</receiver>
<receiver android:name=".WidgetProvider" android:label="#string/widget_name">
<intent-filter>
<action
android:name="android.appwidget.action.APPWIDGET_UPDATE" />
</intent-filter>
<meta-data
android:name="android.appwidget.provider"
android:resource="#xml/widget" />
</receiver>
<receiver
android:name=".WidgetProvider" android:label="#string/widget_name">
<intent-filter>
<action
android:name="android.appwidget.action.APPWIDGET_UPDATE" />
<data android:scheme="easymoney_widget" />
</intent-filter>
<meta-data
android:name="android.appwidget.provider"
android:resource="#xml/widget" />
</receiver>
<receiver android:name=".WidgetProvider">
<intent-filter>
<action android:name="com.handyapps.easymoney.WIDGET_CONTROL" />
<data android:scheme="easymoney_widget" />
</intent-filter>
</receiver>
</application>
The main startup class is com.handyapps.easymoney.EasyMoney. I placed a breakpoint at the start of the onCreate() method but I discovered it didn't even reach there. Somehow, the application just couldn't be loaded in Android 2.2... but it works perfectly fine for all the previous Android versions. Been trying to find the cause for the past 2 days but am totally stumped!!
I've found the solution! Just need to remove the android:name attribute from the application tag in the manifest... but the compiler should have given a warning or error.
From ClassCastException:
Thrown when a program attempts to cast
a an object to a type with which it is
not compatible.
I would go through the code and check the casts I am doing.