BOOT_COMPLETED receiver ActivityNotFoundException - android

I am trying to write an app that starts on boot up. My receiver works and my app is started on boot up, however it crashes because of ActivityNotFoundException. I may have messed up in the manifest somewhere. Please help to take a look.
This is the receiver code, LocationLock.class just does some stuff to lock the phone.
public class MyStartupIntentReceiver extends BroadcastReceiver {
#Override
public void onReceive(Context context, Intent intent){
Intent myStarterIntent = new Intent(context, LocationLock.class);
myStarterIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(myStarterIntent);
}
}
This is the manifest:
<?xml version="1.0" encoding="utf-8"?>
<application android:icon="#drawable/icon" android:label="#string/app_name">
<activity android:name=".LocationLock$Controller"
android:label="#string/app_name_controller">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<receiver android:name=".LocationLock"
android:label="#string/app_name"
android:permission="android.permission.BIND_DEVICE_ADMIN">
<meta-data android:name="android.app.device_admin"
android:resource="#xml/device_admin" />
<intent-filter>
<action android:name="android.app.action.DEVICE_ADMIN_ENABLED" />
</intent-filter>
</receiver>
<receiver android:name=".MyStartupIntentReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
</application>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
</manifest>
Below are the errors:
05-03 02:54:55.301: ERROR/AndroidRuntime(264): FATAL EXCEPTION: main
05-03 02:54:55.301: ERROR/AndroidRuntime(264): java.lang.RuntimeException: Unable to start receiver org.example.locationlock.MyStartupIntentReceiver: android.content.ActivityNotFoundException: Unable to find explicit activity class {org.example.locationlock/org.example.locationlock.LocationLock}; have you declared this activity in your AndroidManifest.xml?
05-03 02:54:55.301: ERROR/AndroidRuntime(264): at android.app.ActivityThread.handleReceiver(ActivityThread.java:2821)
05-03 02:54:55.301: ERROR/AndroidRuntime(264): at android.app.ActivityThread.access$3200(ActivityThread.java:125)
05-03 02:54:55.301: ERROR/AndroidRuntime(264): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2083)
05-03 02:54:55.301: ERROR/AndroidRuntime(264): at android.os.Handler.dispatchMessage(Handler.java:99)
05-03 02:54:55.301: ERROR/AndroidRuntime(264): at android.os.Looper.loop(Looper.java:123)
05-03 02:54:55.301: ERROR/AndroidRuntime(264): at android.app.ActivityThread.main(ActivityThread.java:4627)
05-03 02:54:55.301: ERROR/AndroidRuntime(264): at java.lang.reflect.Method.invokeNative(Native Method)
05-03 02:54:55.301: ERROR/AndroidRuntime(264): at java.lang.reflect.Method.invoke(Method.java:521)
05-03 02:54:55.301: ERROR/AndroidRuntime(264): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
05-03 02:54:55.301: ERROR/AndroidRuntime(264): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
05-03 02:54:55.301: ERROR/AndroidRuntime(264): at dalvik.system.NativeStart.main(Native Method)
05-03 02:54:55.301: ERROR/AndroidRuntime(264): Caused by: android.content.ActivityNotFoundException: Unable to find explicit activity class {org.example.locationlock/org.example.locationlock.LocationLock}; have you declared this activity in your AndroidManifest.xml?
05-03 02:54:55.301: ERROR/AndroidRuntime(264): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1404)
05-03 02:54:55.301: ERROR/AndroidRuntime(264): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1378)
05-03 02:54:55.301: ERROR/AndroidRuntime(264): at android.app.ContextImpl.startActivity(ContextImpl.java:622)
05-03 02:54:55.301: ERROR/AndroidRuntime(264): at android.content.ContextWrapper.startActivity(ContextWrapper.java:258)
05-03 02:54:55.301: ERROR/AndroidRuntime(264): at android.content.ContextWrapper.startActivity(ContextWrapper.java:258)
05-03 02:54:55.301: ERROR/AndroidRuntime(264): at org.example.locationlock.MyStartupIntentReceiver.onReceive(MyStartupIntentReceiver.java:12)
05-03 02:54:55.301: ERROR/AndroidRuntime(264): at android.app.ActivityThread.handleReceiver(ActivityThread.java:2810)
05-03 02:54:55.301: ERROR/AndroidRuntime(264): ... 10 more
Maybe I can't have two receivers listed one after another, but the MyStartupIntentReceiver has no activity associated with it.
Any help is much appreciated!

you are trying to start a receiver class: Intent myStarterIntent = new Intent(context, LocationLock.class);, since in the manifest file it is declared as a reciever class: <receiver android:name=".LocationLock" so modify this declaration to activiy:
<activity
android:name=".LocationLock"
android:windowSoftInputMode="stateVisible|adjustResize" >
</activity>

have you tried defining it as an activity in your manifest?
for example, within your section:
<activity android:name=".MyStartupIntentReceiver"
android:launchMode="singleTop"
android:screenOrientation="portrait"
android:noHistory="true" />

Related

Starting an alarm manager application on reboot

Presently, I am working on app that sets the phone into the vibration mode or the ringer mode at the selected time. I have successfully implemented this using the alarmmanager in my application.
I want my app to remember all the pending intents when the phone is rebooted.
I found a sample code in the internet, but it seems to crash my app when the phone is rebooted. I don't know what's going wrong.
Here is alarmreciever.java
package ishan.khandelwal.vitsilentmode;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.media.AudioManager;
import android.widget.Toast;
public class AlarmReciever extends BroadcastReceiver
{
private AudioManager mAudioManager;
#Override
public void onReceive(Context context, Intent intent)
{
// TODO Auto-generated method stub
if ("android.intent.action.BOOT_COMPLETED".equals(intent.getAction())) {
Intent serviceIntent = new Intent("ishan.khandelwal.vitsilentmode");
context.startService(serviceIntent);
}
mAudioManager = (AudioManager)context.getSystemService(Context.AUDIO_SERVICE);
mAudioManager.setRingerMode(AudioManager.RINGER_MODE_VIBRATE);
// Show the toast
Toast.makeText(context, "Vibration Mode", Toast.LENGTH_SHORT).show();
}
}
Android manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="ishan.khandelwal.vitsilentmode"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="19" />
<!-- permission required to use Alarm Manager -->
<uses-permission android:name="com.android.alarm.permission.SET_ALARM"/>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<receiver
android:name=".receiver.StartMyServiceAtBootReceiver"
android:enabled="true"
android:exported="true"
android:label="StartMyServiceAtBootReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
<activity
android:name="ishan.khandelwal.vitsilentmode.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="ishan.khandelwal.vitsilentmode.GetSlots"
android:label="Select your slots"
android:screenOrientation="portrait" >
</activity>
<activity
android:name="ishan.khandelwal.vitsilentmode.MorningSlots"
android:label="Select your morning slots"
android:screenOrientation="portrait" >
</activity>
<activity
android:name="ishan.khandelwal.vitsilentmode.EveningSlots"
android:label="Select your evening slots"
android:screenOrientation="portrait" >
</activity>
<activity
android:name="ishan.khandelwal.vitsilentmode.Labs"
android:label="Select your lab slots"
android:screenOrientation="portrait" >
</activity>
<activity
android:name="ishan.khandelwal.vitsilentmode.About"
android:label="About"
android:screenOrientation="portrait" >
</activity>
<activity
android:name="ishan.khandelwal.vitsilentmode.AlarmReciever"
android:label="AlarmReciever" >
</activity>
<!-- Register the Alarm Receiver -->
<receiver android:name=".AlarmReciever"/>
<activity
android:name="ishan.khandelwal.vitsilentmode.RingerMode"
android:label="RingerMode" >
</activity>
<!-- Register the Alarm Receiver -->
<receiver android:name=".RingerMode"/>
</application>
Logcat:
07-23 23:33:12.057: I/ActivityManager(858): Start proc com.android.providers.calendar for broadcast com.android.providers.calendar/.CalendarReceiver: pid=1116 uid=10023 gids={3003}
07-23 23:33:12.067: I/ActivityThread(1116): Pub com.android.calendar: com.android.providers.calendar.CalendarProvider2
07-23 23:33:12.087: I/SurfaceFlinger(858): Boot is finished (2041 ms)
07-23 23:33:12.128: I/ActivityManager(858): Start proc ishan.khandelwal.vitsilentmode for broadcast ishan.khandelwal.vitsilentmode/.receiver.StartMyServiceAtBootReceiver: pid=1127 uid=10031 gids={}
07-23 23:33:12.137: D/AndroidRuntime(1127): Shutting down VM
07-23 23:33:12.137: W/dalvikvm(1127): threadid=1: thread exiting with uncaught exception (group=0xb6fac4f0)
07-23 23:33:12.137: E/AndroidRuntime(1127): FATAL EXCEPTION: main
07-23 23:33:12.137: E/AndroidRuntime(1127): java.lang.RuntimeException: Unable to instantiate receiver ishan.khandelwal.vitsilentmode.receiver.StartMyServiceAtBootReceiver: java.lang.ClassNotFoundException: ishan.khandelwal.vitsilentmode.receiver.StartMyServiceAtBootReceiver in loader dalvik.system.PathClassLoader[/data/app/ishan.khandelwal.vitsilentmode-1.apk]
07-23 23:33:12.137: E/AndroidRuntime(1127): at android.app.ActivityThread.handleReceiver(ActivityThread.java:1773)
07-23 23:33:12.137: E/AndroidRuntime(1127): at android.app.ActivityThread.access$2400(ActivityThread.java:117)
07-23 23:33:12.137: E/AndroidRuntime(1127): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:981)
07-23 23:33:12.137: E/AndroidRuntime(1127): at android.os.Handler.dispatchMessage(Handler.java:99)
07-23 23:33:12.137: E/AndroidRuntime(1127): at android.os.Looper.loop(Looper.java:130)
07-23 23:33:12.137: E/AndroidRuntime(1127): at android.app.ActivityThread.main(ActivityThread.java:3683)
07-23 23:33:12.137: E/AndroidRuntime(1127): at java.lang.reflect.Method.invokeNative(Native Method)
07-23 23:33:12.137: E/AndroidRuntime(1127): at java.lang.reflect.Method.invoke(Method.java:507)
07-23 23:33:12.137: E/AndroidRuntime(1127): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
07-23 23:33:12.137: E/AndroidRuntime(1127): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
07-23 23:33:12.137: E/AndroidRuntime(1127): at dalvik.system.NativeStart.main(Native Method)
07-23 23:33:12.137: E/AndroidRuntime(1127): Caused by: java.lang.ClassNotFoundException: ishan.khandelwal.vitsilentmode.receiver.StartMyServiceAtBootReceiver in loader dalvik.system.PathClassLoader[/data/app/ishan.khandelwal.vitsilentmode-1.apk]
07-23 23:33:12.137: E/AndroidRuntime(1127): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
07-23 23:33:12.137: E/AndroidRuntime(1127): at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
07-23 23:33:12.137: E/AndroidRuntime(1127): at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
07-23 23:33:12.137: E/AndroidRuntime(1127): at android.app.ActivityThread.handleReceiver(ActivityThread.java:1764)
07-23 23:33:12.137: E/AndroidRuntime(1127): ... 10 more
Thanks for the help in advance.
Ok, the problem is that you have specified in your AndroidManifest the wrong/a nonexistent receiver implementation. You specified this:
<receiver
android:name=".receiver.StartMyServiceAtBootReceiver"
android:enabled="true"
android:exported="true"
android:label="StartMyServiceAtBootReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
The problem is you have no class called StartMyServiceAtBootReceiver. What you I think you should have is something like this:
<receiver
android:name=".AlarmReceiver"
android:enabled="true"
android:exported="true"
android:label="StartMyServiceAtBootReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>

Android : illegaljavaexception Could not execute the method for activity

I'm trying using intent to add class to an application. I have made SecondAcitivity class and modified the manifest file as well. My application is running i.e. First activity Containing the button works well, but onclick on button the error comes and it does not displays a second activity.
This is my MainActivity.java file
package com.intent.usingintent;
import android.os.Bundle;
import android.content.Intent;
import android.app.Activity;
import android.view.View;
public class MainActivity extends Activity {
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void onClick(View view){
startActivity(new Intent("com.intent.SecondActivity"));
}
}
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.intent.usingintent"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.intent.usingintent.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="com.intent.SecondActivity"
android:label="SecondActivity" >
</activity>
<intent-filter>
<action android:name=".SecondActivity" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</application>
</manifest>
ERROR LOG
07-09 13:57:45.922: W/dalvikvm(20185): threadid=1: thread exiting with uncaught exception (group=0x40d8e2a0)
07-09 13:57:45.932: E/AndroidRuntime(20185): FATAL EXCEPTION: main
07-09 13:57:45.932: E/AndroidRuntime(20185): java.lang.IllegalStateException: Could not execute method of the activity
07-09 13:57:45.932: E/AndroidRuntime(20185): at android.view.View$1.onClick(View.java:3699)
07-09 13:57:45.932: E/AndroidRuntime(20185): at android.view.View.performClick(View.java:4223)
07-09 13:57:45.932: E/AndroidRuntime(20185): at android.view.View$PerformClick.run(View.java:17275)
07-09 13:57:45.932: E/AndroidRuntime(20185): at android.os.Handler.handleCallback(Handler.java:615)
07-09 13:57:45.932: E/AndroidRuntime(20185): at android.os.Handler.dispatchMessage(Handler.java:92)
07-09 13:57:45.932: E/AndroidRuntime(20185): at android.os.Looper.loop(Looper.java:137)
07-09 13:57:45.932: E/AndroidRuntime(20185): at android.app.ActivityThread.main(ActivityThread.java:4898)
07-09 13:57:45.932: E/AndroidRuntime(20185): at java.lang.reflect.Method.invokeNative(Native Method)
07-09 13:57:45.932: E/AndroidRuntime(20185): at java.lang.reflect.Method.invoke(Method.java:511)
07-09 13:57:45.932: E/AndroidRuntime(20185): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1008)
07-09 13:57:45.932: E/AndroidRuntime(20185): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:775)
07-09 13:57:45.932: E/AndroidRuntime(20185): at dalvik.system.NativeStart.main(Native Method)
07-09 13:57:45.932: E/AndroidRuntime(20185): Caused by: java.lang.reflect.InvocationTargetException
07-09 13:57:45.932: E/AndroidRuntime(20185): at java.lang.reflect.Method.invokeNative(Native Method)
07-09 13:57:45.932: E/AndroidRuntime(20185): at java.lang.reflect.Method.invoke(Method.java:511)
07-09 13:57:45.932: E/AndroidRuntime(20185): at android.view.View$1.onClick(View.java:3694)
07-09 13:57:45.932: E/AndroidRuntime(20185): ... 11 more
07-09 13:57:45.932: E/AndroidRuntime(20185): Caused by: android.content.ActivityNotFoundException: No Activity found to handle Intent { act=com.intent.SecondActivity }
07-09 13:57:45.932: E/AndroidRuntime(20185): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1580)
07-09 13:57:45.932: E/AndroidRuntime(20185): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1431)
07-09 13:57:45.932: E/AndroidRuntime(20185): at android.app.Activity.startActivityForResult(Activity.java:3446)
07-09 13:57:45.932: E/AndroidRuntime(20185): at android.app.Activity.startActivityForResult(Activity.java:3407)
07-09 13:57:45.932: E/AndroidRuntime(20185): at android.app.Activity.startActivity(Activity.java:3617)
07-09 13:57:45.932: E/AndroidRuntime(20185): at android.app.Activity.startActivity(Activity.java:3585)
07-09 13:57:45.932: E/AndroidRuntime(20185): at com.intent.usingintent.MainActivity.onClick(MainActivity.java:17)
07-09 13:57:45.932: E/AndroidRuntime(20185): ... 14 more
07-09 13:57:57.072: I/Process(20185): Sending signal. PID: 20185 SIG: 9
In your App, your second activity in com.intent.usingintent package.And your intent action is com.intent.SecondActivity,and write <intent-filter> inside <activity> tag.
So in manifest file,Change
<activity
android:name="com.intent.SecondActivity"
android:label="SecondActivity" >
</activity>
<intent-filter>
<action android:name=".SecondActivity" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
to
<activity
android:name="com.intent.usingintent.SecondActivity"
android:label="SecondActivity" >
<intent-filter>
<action android:name="com.intent.SecondActivity" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
You have misplaced IntentFilter for the SecondActivity in the manifest. Put it insude <activity></activity>
Though you do no treally need that you can simply do startActivity(new Intent(this, SecondActivity.class));
in your manifest file instead of this
<activity
android:name="com.intent.SecondActivity"
android:label="SecondActivity" >
</activity>
replace with
<activity
android:name="com.intent.usingintent.SecondActivity"
android:label="SecondActivity" >
</activity>
and even in your java class also
startActivity(new Intent("com.intent.SecondActivity"));
replace this with
startActivity(new Intent("com.intent.usingintent.SecondActivity"));
change in manifest file
<activity
android:name="com.intent.usingintent.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="SecondActivity"></activity>
change in click event
Intent n=new Intent(MainActivity.this,SecondActivity.class);
startActivity(n);

Android - exception launching project on start after copying a lot of code over from another project

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

Android ClassNotFoundException on published app

I have an application thats been published awhile on Google play, I have been fixing reported bugs as they come in but recently this log below came in and I don't know what to make of it:
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.mammothtooth.flightinfo/com.mammothtooth.flightinfo.ui.SplashActivity}: java.lang.ClassNotFoundException: com.mammothtooth.flightinfo.ui.SplashActivity in loader dalvik.system.PathClassLoader[/system/framework/com.google.android.maps.jar:/mnt/asec/com.mammothtooth.flightinfo-1/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:4277)
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:839)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: com.mammothtooth.flightinfo.ui.SplashActivity in loader dalvik.system.PathClassLoader[/system/framework/com.google.android.maps.jar:/mnt/asec/com.mammothtooth.flightinfo-1/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)
Does anyone know anything about this type of error log? My SplashScreenActivity is there and its defined as the entry point of the application in the manifest as follows:
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/Theme.Sherlock" >
<uses-library android:name="com.google.android.maps" />
<activity
android:label="#string/app_name"
android:name=".ui.SplashActivity"
android:theme="#android:style/Theme.NoTitleBar"
android:configChanges="keyboard|keyboardHidden|orientation"
android:screenOrientation="portrait">
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Would the placing of the uses-library be an issue in the manifest?
I can't reproduce this issue on any of my android devices so any help is greatly appreciated in locating what might be the cause of this issue.

My Android App Keeps Crashing

I've started to learn Android Development and I got this snippit off of google android development site, it keeps on crashing.
My specs are:
Android 4.0.3
API 15
Code:
package lewes.android.hello;
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
public class HelloAndroid extends Activity {
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
TextView tv = new TextView(this);
tv.setText("Hello, Android");
setContentView(tv);
}
}
I get...
Unfortenualy, HelloAndroid is not responding.
Please help me!
MY MANIFEST:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="lewes.android.hello"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="15" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name" >
<activity
android:name=".HelloWorld"
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>
</manifest>
LogCat:
03-17 11:35:19.835: D/AndroidRuntime(562): Shutting down VM
03-17 11:35:19.835: W/dalvikvm(562): threadid=1: thread exiting with uncaught
exception (group=0x409c01f8)
03-17 11:35:19.914: E/AndroidRuntime(562): FATAL EXCEPTION: main
03-17 11:35:19.914: E/AndroidRuntime(562): java.lang.RuntimeException: Unable to
instantiate activity
ComponentInfo{lewes.android.hello/lewes.android.hello.HelloWorld}:
java.lang.ClassNotFoundException: lewes.android.hello.HelloWorld
03-17 11:35:19.914: E/AndroidRuntime(562): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1880)
03-17 11:35:19.914: E/AndroidRuntime(562): at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
03-17 11:35:19.914: E/AndroidRuntime(562): at
android.app.ActivityThread.access$600(ActivityThread.java:123)
03-17 11:35:19.914: E/AndroidRuntime(562): at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
03-17 11:35:19.914: E/AndroidRuntime(562): at
android.os.Handler.dispatchMessage(Handler.java:99)
03-17 11:35:19.914: E/AndroidRuntime(562): at android.os.Looper.loop(Looper.java:137)
03-17 11:35:19.914: E/AndroidRuntime(562): at
android.app.ActivityThread.main(ActivityThread.java:4424)
03-17 11:35:19.914: E/AndroidRuntime(562): at
java.lang.reflect.Method.invokeNative(Native Method)
03-17 11:35:19.914: E/AndroidRuntime(562): at
java.lang.reflect.Method.invoke(Method.java:511)
03-17 11:35:19.914: E/AndroidRuntime(562): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
03-17 11:35:19.914: E/AndroidRuntime(562): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
03-17 11:35:19.914: E/AndroidRuntime(562): at dalvik.system.NativeStart.main(Native
Method)
03-17 11:35:19.914: E/AndroidRuntime(562): Caused by:
java.lang.ClassNotFoundException: lewes.android.hello.HelloWorld
03-17 11:35:19.914: E/AndroidRuntime(562): at
dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
03-17 11:35:19.914: E/AndroidRuntime(562): at
java.lang.ClassLoader.loadClass(ClassLoader.java:501)
03-17 11:35:19.914: E/AndroidRuntime(562): at
java.lang.ClassLoader.loadClass(ClassLoader.java:461)
03-17 11:35:19.914: E/AndroidRuntime(562): at
android.app.Instrumentation.newActivity(Instrumentation.java:1023)
03-17 11:35:19.914: E/AndroidRuntime(562): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1871)
03-17 11:35:19.914: E/AndroidRuntime(562): ... 11 more
03-17 11:40:20.114: I/Process(562): Sending signal. PID: 562 SIG: 9
Delete one of the application sections from your manifest.
Keep the one where the activity corresponds to the name of your class.
make your manifest look exactly like this
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="lewes.android.hello"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="15" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name" >
<activity
android:name=".HelloAndroid"
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>
</manifest>
Change
<activity
android:name=".HelloAndroidActivity"
to
<activity
android:name=".HelloAndroid"
SDK does not mention about this. But as my experience, activity (this) can not be used inside onCreate(Bundle) to initialize new objects. To be used as a parameter for constructors, this is nothing within onCreate().
You can follow this hello world. It uses static xml layout.
Hope this helps you :-)

Categories

Resources