I keep getting classNotFoundException when sending cloud notifications from firebase. The error logs that it can not find .java.MyFirebaseMessagingService I have followed everything as per the documentation but still can not find the fix.
Here's the error log. The app opens fine and only crashes when I send a message from the firebase console to test.
java.lang.RuntimeException: Unable to instantiate service com.myapp.MyApp.MyFirebaseMessagingService: java.lang.ClassNotFoundException: Didn't find class "com.myapp.MyApp.MyFirebaseMessagingService" on path: DexPathList[[zip file "/data/app/com.myapp.MyApp-2_H2R81paYjm5b8ZDse8Uw==/base.apk"],nativeLibraryDirectories=[/data/app/com.myapp.MyApp-2_H2R81paYjm5b8ZDse8Uw==/lib/arm64, /data/app/com.myapp.MyApp-2_H2R81paYjm5b8ZDse8Uw==/base.apk!/lib/arm64-v8a, /system/lib64, /vendor/lib64]]
E/AndroidRuntime( 5956): at android.app.ActivityThread.handleCreateService(ActivityThread.java:3577)
E/AndroidRuntime( 5956): at android.app.ActivityThread.-wrap4(Unknown Source:0)
E/AndroidRuntime( 5956): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1862)
E/AndroidRuntime( 5956): at android.os.Handler.dispatchMessage(Handler.java:106)
E/AndroidRuntime( 5956): at android.os.Looper.loop(Looper.java:198)
E/AndroidRuntime( 5956): at android.app.ActivityThread.main(ActivityThread.java:7055)
E/AndroidRuntime( 5956): at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime( 5956): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:523)
E/AndroidRuntime( 5956): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:836)
E/AndroidRuntime( 5956): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.myapp.MyAppMyFirebaseMessagingService" on path: DexPathList[[zip file "/data/app/com.myapp.MyApp-2_H2R81paYjm5b8ZDse8Uw==/base.apk"],nativeLibraryDirectories=[/data/app/com.myapp.MyApp-2_H2R81paYjm5b8ZDse8Uw==/lib/arm64, /data/app/com.myapp.MyApp-2_H2R81paYjm5b8ZDse8Uw==/base.apk!/lib/arm64-v8a, /system/lib64, /vendor/lib64]]
E/AndroidRuntime( 5956): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:125)
E/AndroidRuntime( 5956): at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
E/AndroidRuntime( 5956): at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
E/AndroidRuntime( 5956): at android.app.ActivityThread.handleCreateService(ActivityThread.java:3574)
E/AndroidRuntime( 5956): ... 8 more
And the manifest file is.
<application
android:name=".Application"
android:label="MyApp"
android:icon="#mipmap/ic_launcher">
<activity
android:name=".MainActivity"
android:launchMode="singleTop"
android:theme="#style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:showWhenLocked="true"
android:turnScreenOn="true"
android:windowSoftInputMode="adjustResize">
<!-- Specifies an Android theme to apply to this Activity as soon as
the Android process has started. This theme is visible to the user
while the Flutter UI initializes. After that, this theme continues
to determine the Window background behind the Flutter UI. -->
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="#style/NormalTheme"
/>
<!-- Displays an Android View that continues showing the launch screen
Drawable until Flutter paints its first frame, then this splash
screen fades out. A splash screen is useful to avoid any visual
gap between the end of Android's launch screen and the painting of
Flutter's first frame. -->
<meta-data
android:name="io.flutter.embedding.android.SplashScreenDrawable"
android:resource="#drawable/launch_background"
/>
<meta-data
android:name="com.google.firebase.messaging.default_notification_icon"
android:resource="#mipmap/ic_logo" />
<meta-data
android:name="com.google.firebase.messaging.default_notification_color"
android:resource="#color/colorAccent" />
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
<action android:name="FLUTTER_NOTIFICATION_CLICK" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<service
android:name=".service.MyFirebaseMessagingService"
>
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
<meta-data
android:name="flutterEmbedding"
android:value="2" />
</application>
I know that the question is answered but recently I too got stuck in the same issue and your comment saved me. Thanks! I want to increase the visibility of your answer for others.
To resolve this issue. I just removed this code segment and the application started working as intended:
<service
android:name=".service.MyFirebaseMessagingService"
>
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
I think there is no need to explicitly declare class .service.MyFirebaseMessagingService as you don't need to mention it for the projects.
Follow all the instructions provided in the firebase_messaging | Flutter Package. You may get one error error: incompatible types: PluginRegistry cannot be converted to FlutterEngine GeneratedPluginRegistrant.register with (registry); while following the instruction. To solve this error, follow the instructions provided in this thread: PluginRegistry cannot be converted to FlutterEngine
and you won't face any issues.
If you want to listen for messages on Background / Foreground , You don't need :
<service android:name=".service.MyFirebaseMessagingService">
The Flutter Package gives to you other tools to make this happen.
If you want to use Flutter for listening to Firebase PushNotifications (and not the native way), try to use the FirebaseMessaging.onMessage.listen( ... ) dart function.
And remember, for android:
If the application is currently in the foreground, the visible notification is not presented by default (but you can make it happen).
You can check how to use the notification handling in the Firebase flutter documentation:
https://firebase.flutter.dev/docs/messaging/notifications/
✌️
Related
I'm developing an App that can be Screen Pinned aka Corporate Owned Single Use aka Lock Task Mode.
If I pin it and then:
I close it (killing it) and then I launch it again
or after some code modification in android studio and then perform Run
restart after pin and unpin
I get the following error:
[homtom-ht3_pro-0123456789ABCDEF]: E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.xx.yyy, PID: 7928
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.xx.yyy/com.xx.yyy.activities.LauncherActivity}: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.xx.yyy/com.xx.yy.activities.StartActivity}; have you declared this activity in your AndroidManifest.xml?
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2534)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2614)
at android.app.ActivityThread.access$800(ActivityThread.java:178)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1470)
at android.os.Handler.dispatchMessage(Handler.java:111)
at android.os.Looper.loop(Looper.java:194)
at android.app.ActivityThread.main(ActivityThread.java:5643)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:960)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
Caused by: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.xx.yyy/com.xx.yyy.activities.StartActivity}; have you declared this activity in your AndroidManifest.xml?
at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1788)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1512)
at android.app.Activity.startActivityForResult(Activity.java:3809)
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:3760)
at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:859)
at android.app.Activity.startActivity(Activity.java:4090)
at android.app.Activity.startActivity(Activity.java:4058)
at com.xx.yyy.activities.LauncherActivity.onCreate(LauncherActivity.java:16)
at android.app.Activity.performCreate(Activity.java:6099)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1112)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2481)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2614)
at android.app.ActivityThread.access$800(ActivityThread.java:178)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1470)
at android.os.Handler.dispatchMessage(Handler.java:111)
at android.os.Looper.loop(Looper.java:194)
at android.app.ActivityThread.main(ActivityThread.java:5643)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:960)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
This is my Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.xx.yyy">
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<receiver
android:name=".receivers.DeviceAdminReceiver"
android:description="#string/app_name"
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_receiver" />
<intent-filter>
<action android:name="android.intent.action.DEVICE_ADMIN_ENABLED" />
<action android:name="android.intent.action.PROFILE_PROVISIONING_COMPLETE" />
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
<activity android:name=".activities.LauncherActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".activities.StartActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.HOME" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
</manifest>
If I don't ever pin the app I can restart/upgrade&run it many times I want.
The nice thing is that is not even possible to uninstall the app because it has been configured as Device Owner, and so, it cannot be uninstalled unless a factory reset.
I dont understand how is possible that my activity disappears after an app restart. Can be something related to the intent category or action?
If anyone else encountered this behavior can tell me I will submit an issue to the bug report site.
Thanks.
EDIT 18/3
I think maybe this is happening because at a certain point, I kill the home category activity that in my case is the missing StartActivity in question, and it is not restarted even if I restart the app.
Found the solution in my COSU disable pinning implementation, I was doing:
PackageManager mPackageManager = getApplicationContext().getPackageManager();;
mPackageManager.setComponentEnabledSetting(
new ComponentName(getApplicationContext(), StartActivity.class),
PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
PackageManager.DONT_KILL_APP);
to disable the pinning on device boot, but this actually disable the specified component.
The correct implementation would be:
PackageManager mPackageManager = getApplicationContext().getPackageManager();;
mPackageManager.setComponentEnabledSetting(
new ComponentName(getApplicationContext(), StartActivity.class),
PackageManager.COMPONENT_ENABLED_STATE_DEFAULT,
PackageManager.DONT_KILL_APP);
I am working with the new DirectBoot feature in Android 7.0 and I am trying to determine when the phone is still locked after a restart and in Direct Boot mode. To do this, I have implemented a BroadcastReceiver which I defined in the Manifest.
My understanding is that when a phone is restarted, it sends out an ACTION_LOCKED_BOOT_COMPLETED broadcast when it finishes booting but prior to the user entering their PIN. When the PIN is entered and phone becomes unlocked, an ACTION_BOOT_COMPLETED broadcast is sent. My Receiver works fine if I define its intent-filter to be ACTION_BOOT_COMPLETED, but as soon as I add LOCKED_BOOT_COMPLETED, I get Fatal error messages like this upon restarting the phone saying it couldn't instantiate my receiver:
01-06 07:25:30.917 3872-3872/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.nougatencryptiontest, PID: 3872
java.lang.RuntimeException: Unable to instantiate receiver com.example.nougatencryptiontest.MyReceiver: java.lang.ClassNotFoundException: Didn't find class "com.example.nougatencryptiontest.MyReceiver" on path: DexPathList[[zip file "/data/app/com.example.nougatencryptiontest-1/base.apk"],nativeLibraryDirectories=[/data/app/com.example.nougatencryptiontest-1/lib/arm64, /system/lib64, /vendor/lib64]]
at android.app.ActivityThread.handleReceiver(ActivityThread.java:3021)
at android.app.ActivityThread.-wrap18(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1561)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.example.nougatencryptiontest.MyReceiver" on path: DexPathList[[zip file "/data/app/com.example.nougatencryptiontest-1/base.apk"],nativeLibraryDirectories=[/data/app/com.example.nougatencryptiontest-1/lib/arm64, /system/lib64, /vendor/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at android.app.ActivityThread.handleReceiver(ActivityThread.java:3016)
at android.app.ActivityThread.-wrap18(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1561)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
I'm not sure why this DexPathList issue occurs only when I change my Receiver's intent-filter from BOOT_COMPLETED to LOCKED_BOOT_COMPLETED. Below is my Manifest that does not work (however, if I change intent-filter to just be BOOT_COMPLETED, application doesn't crash and receiver works perfectly fine!):
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.nougatencryptiontest">
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<application
android:allowBackup="true"
android:directBootAware="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<receiver android:name=".MyReceiver"
android:exported="true"
android:directBootAware="true">
<!-- Listening the BOOT_COMPLETED action for legacy pre-N devices -->
<intent-filter>
<action android:name="android.intent.action.LOCKED_BOOT_COMPLETED" />
</intent-filter>
</receiver>
<activity android:name=".MainActivity"
android:directBootAware="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
Any advice or pointers would be greatly appreciated.
My application was working ok, but after i added the push notifications from parse server, i started getting an error when the app is launched (see message below), while the app open and work ok, when i close the app the same is not doing the background search and notification.
09-30 17:22:12.006 10338-10349/br.com.inconnet.inbeacon E/Parcel: Class not found when unmarshalling: org.altbeacon.beacon.service.StartRMData
java.lang.ClassNotFoundException: org.altbeacon.beacon.service.StartRMData
at java.lang.Class.classForName(Native Method)
at java.lang.Class.forName(Class.java:324)
at android.os.Parcel.readParcelableCreator(Parcel.java:2404)
at android.os.Parcel.readParcelable(Parcel.java:2358)
at android.os.Message.readFromParcel(Message.java:571)
at android.os.Message.-wrap0(Message.java)
at android.os.Message$1.createFromParcel(Message.java:527)
at android.os.Message$1.createFromParcel(Message.java:525)
at android.os.IMessenger$Stub.onTransact(IMessenger.java:51)
at android.os.Binder.execTransact(Binder.java:453)
Caused by: java.lang.ClassNotFoundException: org.altbeacon.beacon.service.StartRMData
at java.lang.Class.classForName(Native Method)
at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
at java.lang.Class.classForName(Native Method)
at java.lang.Class.forName(Class.java:324)
at android.os.Parcel.readParcelableCreator(Parcel.java:2404)
at android.os.Parcel.readParcelable(Parcel.java:2358)
at android.os.Message.readFromParcel(Message.java:571)
at android.os.Message.-wrap0(Message.java)
at android.os.Message$1.createFromParcel(Message.java:527)
at android.os.Message$1.createFromParcel(Message.java:525)
at android.os.IMessenger$Stub.onTransact(IMessenger.java:51)
at android.os.Binder.execTransact(Binder.java:453)
Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available
if i remove the following information from my AndroidManifest.xml, the app works ok again.
<meta-data android:name="com.parse.push.gcm_sender_id"
android:value="id:xxxxxx" />
<service android:name="com.parse.PushService" />
<receiver android:name="com.parse.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="br.com.inconnet.inbeacon" />
</intent-filter>
</receiver>
<receiver android:name="com.parse.ParsePushBroadcastReceiver" android:exported="false">
<intent-filter>
<action android:name="com.parse.push.intent.RECEIVE" />
<action android:name="com.parse.push.intent.OPEN" />
<action android:name="com.parse.push.intent.DELETE" />
</intent-filter>
</receiver>
How can i make both work thogeter?
A similar problem has been reported by folks who are bundling their apps with certain other services and the Android Beacon Library. There is no known fix or even a fully understood cause. You can read more about the issue here:
https://github.com/AltBeacon/android-beacon-library/issues/306
One theory is that bundling some services with your app somehow forces other services in the app to run in a separate process, something the Android Beacon Library does not support.
If you have proguard settings enabled, you may want to try disabling them to see if this makes the problem go away.
I'm in the process of making my own Android app and along the way discovered GCM (Google Cloud Messaging). I followed the following tutorial exactly: http://javapapers.com/android/google-cloud-messaging-gcm-for-android-and-push-notifications/
The good news is that almost everything works properly, except that every time I send a push notification, the App force closes on the device. I don't think anything is wrong with the Eclipse project and I'm running Android 4.2.2 on my device. There are no compilation errors. It is driving me nuts that I can't figure out why the App keeps force closing.
The code is exactly the same as what is listed in the above link. For reference, here is my logcat:
E/AndroidRuntime( 7261): FATAL EXCEPTION: main
E/AndroidRuntime( 7261): java.lang.RuntimeException: Unable to instantiate receiver com.javapapers.android.GcmBroadcastReceiver: java.lang.ClassNotFoundException: Didn't find class "com.javapapers.android.GcmBroadcastReceiver" on path: /data/app/com.javapapers.android-1.apk
E/AndroidRuntime( 7261): at android.app.ActivityThread.handleReceiver(ActivityThread.java:2428)
E/AndroidRuntime( 7261): at android.app.ActivityThread.access$1600(ActivityThread.java:151)
E/AndroidRuntime( 7261): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1358)
E/AndroidRuntime( 7261): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime( 7261): at android.os.Looper.loop(Looper.java:137)
E/AndroidRuntime( 7261): at android.app.ActivityThread.main(ActivityThread.java:5285)
E/AndroidRuntime( 7261): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 7261): at java.lang.reflect.Method.invoke(Method.java:511)
E/AndroidRuntime( 7261): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102)
E/AndroidRuntime( 7261): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
E/AndroidRuntime( 7261): at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:126)
E/AndroidRuntime( 7261): at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime( 7261): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.javapapers.android.GcmBroadcastReceiver" on path: /data/app/com.javapapers.android-1.apk
E/AndroidRuntime( 7261): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:65)
E/AndroidRuntime( 7261): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
E/AndroidRuntime( 7261): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
E/AndroidRuntime( 7261): at android.app.ActivityThread.handleReceiver(ActivityThread.java:2423)
E/AndroidRuntime( 7261): ... 11 more
W/GTalkService( 1430): [DataMsgMgr] broadcast intent callback: result=CANCELLED forIntent { act=com.google.android.c2dm.intent.RECEIVE pkg=com.javapapers.android (has extras) }
My manifest looks like the following:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<permission
android:name="com.javapapers.android.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="com.javapapers.android.permission.C2D_MESSAGE" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-sdk
android:minSdkVersion="9"
android:targetSdkVersion="16" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name" >
<activity
android:name=".RegisterActivity"
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.javapapers.android.MainActivity"
android:configChanges="orientation|keyboardHidden"
android:label="#string/app_name" >
</activity>
<receiver
android:name=".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.javapapers.android" />
</intent-filter>
</receiver>
<service android:name=".GCMNotificationIntentService" />
I'm at my wits end trying to figure out what is wrong, so any and all help is appreciated.
What package is your GcmBroadcastReceiver located in?
When using the . prefix, like you did when declaring .GcmBroadcastReceiver, the . translates to your package name. So unless GcmBroadcastReceiver is located in com.javapapers.android then it will not work.
Even I faced same concern. Right Click project go to -> build Path -> Config Build path -> order and export -> check mark Android dependencies (google paly services.jar) shift to top. Now Clean and build and run your application.
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?