Skip to content
This repository has been archived by the owner on Sep 4, 2020. It is now read-only.

[Android] App crashes right after launch (using fcm) #1800

Open
kukikiloke opened this issue Jun 19, 2017 · 43 comments
Open

[Android] App crashes right after launch (using fcm) #1800

kukikiloke opened this issue Jun 19, 2017 · 43 comments

Comments

@kukikiloke
Copy link

kukikiloke commented Jun 19, 2017

Actual Behaviour

App crashes right after launching it.

Steps to Reproduce

Nothing particular was done. Maybe configuration related?

Platform and Version

Android 6.0

(Android) What device vendor

Motorola G

Cordova CLI version and cordova platform version

cordova 6.5.0
cordova-android 6.2.1

Plugin version

Latest from master branch
cordova plugin add https://github.com/phonegap/phonegap-plugin-push

Sample Code that illustrates the problem

var pushMgr = PushNotification.init({
	android: {
		senderID: '1234567788',
		icon: 'notification',
		iconColor: '#ff3498db'
	},
	ios: {
		senderID: '1234567788',
		alert: 'true',
		badge: 'true',
		sound: 'true'
	}
});

Logs taken while reproducing problem

06-19 10:56:44.584 6055-6206/com.example.apps.myApp V/Push_Plugin: execute: action=init
06-19 10:56:44.596 6055-6207/com.example.apps.myApp V/Push_Plugin: execute: data=[{"android":{"senderID":"1234567788","icon":"notification","iconColor":"#ff3498db"},"ios":{"senderID":"1234567788","alert":"true","badge":"true","sound":"true"}}]
06-19 10:56:44.597 6055-6207/com.example.apps.myApp V/Push_Plugin: execute: jo={"senderID":"1234567788","icon":"notification","iconColor":"#ff3498db"}
06-19 10:56:44.919 6055-6207/com.example.apps.myApp E/AndroidRuntime: FATAL EXCEPTION: pool-1-thread-2
                                                                                    Process: com.example.apps.myApp, PID: 6055
                                                                                    android.content.res.Resources$NotFoundException: String resource ID #0x0
                                                                                        at android.content.res.Resources.getText(Resources.java:312)
                                                                                        at android.content.res.Resources.getString(Resources.java:400)
                                                                                        at android.content.Context.getString(Context.java:409)
                                                                                        at com.adobe.phonegap.push.PushPlugin.getStringResourceByName(PushPlugin.java:449)
                                                                                        at com.adobe.phonegap.push.PushPlugin.access$200(PushPlugin.java:31)
                                                                                        at com.adobe.phonegap.push.PushPlugin$1.run(PushPlugin.java:71)
                                                                                        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
                                                                                        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
                                                                                        at java.lang.Thread.run(Thread.java:818)
@fredgalvao
Copy link
Collaborator

Are you sure the notification file exists on your drawable folder (any of them)?

@kukikiloke
Copy link
Author

yes, they are not newly added and I just double checked that the file exists in the drawable folders (hdpi, mdpi, xhdpi, xxhdpi, xxxhdpi).

From the crash logs, it does not seem to be related to the image but reading the sender ID string

@kukikiloke
Copy link
Author

Followings are more detailed logs, particularly the line No package identifier when getting value for resource number 0x00000000. I googled it a bit and they pointed to the way setText() is called and I'm not sure where is it being used. So perhaps you have an idea?

06-19 12:06:41.813 26742-26742/? I/art: Late-enabling -Xcheck:jni
06-19 12:06:41.881 26742-26742/com.example.apps.myApp W/System: ClassLoader referenced unknown path: /data/app/com.example.apps.myApp-2/lib/arm
06-19 12:06:41.884 26742-26742/com.example.apps.myApp I/InstantRun: Instant Run Runtime started. Android package is com.example.apps.myApp, real application class is null.
06-19 12:06:42.363 26742-26742/com.example.apps.myApp W/System: ClassLoader referenced unknown path: /data/app/com.example.apps.myApp-2/lib/arm
06-19 12:06:42.413 26742-26748/com.example.apps.myApp W/art: Suspending all threads took: 8.951ms
06-19 12:06:42.445 26742-26742/com.example.apps.myApp I/FirebaseInitProvider: FirebaseApp initialization unsuccessful
06-19 12:06:42.547 26742-26742/com.example.apps.myApp I/CordovaLog: Changing log level to DEBUG(3)
06-19 12:06:42.547 26742-26742/com.example.apps.myApp I/CordovaActivity: Apache Cordova native platform version 6.2.1 is starting
06-19 12:06:42.547 26742-26742/com.example.apps.myApp D/CordovaActivity: CordovaActivity.onCreate()
06-19 12:06:42.645 26742-26742/com.example.apps.myApp I/WebViewFactory: Loading com.google.android.webview version 58.0.3029.83 (code 302908300)
06-19 12:06:42.741 26742-26742/com.example.apps.myApp I/art: Rejecting re-init on previously-failed class java.lang.Class<com.android.webview.chromium.TokenBindingManagerAdapter>
06-19 12:06:42.741 26742-26742/com.example.apps.myApp I/art: Rejecting re-init on previously-failed class java.lang.Class<com.android.webview.chromium.TokenBindingManagerAdapter>
06-19 12:06:42.747 26742-26742/com.example.apps.myApp I/art: Rejecting re-init on previously-failed class java.lang.Class<com.android.webview.chromium.ServiceWorkerControllerAdapter>
06-19 12:06:42.748 26742-26742/com.example.apps.myApp I/art: Rejecting re-init on previously-failed class java.lang.Class<com.android.webview.chromium.ServiceWorkerControllerAdapter>
06-19 12:06:42.761 26742-26742/com.example.apps.myApp I/cr_LibraryLoader: Time to load native libraries: 1 ms (timestamps 6417-6418)
06-19 12:06:42.798 26742-26742/com.example.apps.myApp I/chromium: [INFO:library_loader_hooks.cc(140)] Chromium logging enabled: level = 0, default verbosity = 0
06-19 12:06:42.798 26742-26742/com.example.apps.myApp I/cr_LibraryLoader: Expected native library version number "58.0.3029.83", actual native library version number "58.0.3029.83"
06-19 12:06:42.826 26742-26742/com.example.apps.myApp I/cr_BrowserStartup: Initializing chromium process, singleProcess=true
06-19 12:06:42.861 26742-26742/com.example.apps.myApp I/Adreno-EGL: <qeglDrvAPI_eglInitialize:379>: QUALCOMM Build: 10/09/15, 6cbbf7d, I3193f6e94a
06-19 12:06:42.980 26742-26815/com.example.apps.myApp W/ResourceType: For resource 0x7f06002f, entry index(47) is beyond type entryCount(20)
06-19 12:06:42.980 26742-26815/com.example.apps.myApp W/ResourceType: Failure getting entry for 0x7f06002f (t=5 e=47) (error -75)
06-19 12:06:42.982 26742-26815/com.example.apps.myApp E/GooglePlayServicesUtil: The Google Play services resources were not found. Check your project configuration to ensure that the resources are included.
06-19 12:06:43.043 26742-26807/com.example.apps.myApp W/cr_BindingManager: Cannot setInForeground() - never saw a connection for the pid: 26742
06-19 12:06:43.048 26742-26823/com.example.apps.myApp D/ConnectivityManager.CallbackHandler: CM callback handler got msg 524290
06-19 12:06:43.145 26742-26742/com.example.apps.myApp D/SystemWebViewEngine: CordovaWebView is running on device made by: motorola
06-19 12:06:43.161 26742-26742/com.example.apps.myApp D/PluginManager: init()
06-19 12:06:43.245 26742-26742/com.example.apps.myApp D/FileUtils: Unrecognized extra filesystem identifier: assets
06-19 12:06:43.272 26742-26832/com.example.apps.myApp D/OpenGLRenderer: Use EGL_SWAP_BEHAVIOR_PRESERVED: true
06-19 12:06:43.398 26742-26742/com.example.apps.myApp D/CordovaWebViewImpl: >>> loadUrl(file:///android_asset/www/index.html)
06-19 12:06:43.429 26742-26811/com.example.apps.myApp W/cr_media: Requires BLUETOOTH permission
06-19 12:06:43.441 26742-26742/com.example.apps.myApp D/CordovaActivity: Started the activity.
06-19 12:06:43.441 26742-26742/com.example.apps.myApp D/CordovaActivity: Resumed the activity.
06-19 12:06:43.456 26742-26823/com.example.apps.myApp D/ConnectivityManager.CallbackHandler: CM callback handler got msg 524290
06-19 12:06:43.475 26742-26832/com.example.apps.myApp I/OpenGLRenderer: Initialized EGL, version 1.4
06-19 12:06:43.630 26742-26869/com.example.apps.myApp E/libEGL: validate_display:255 error 3008 (EGL_BAD_DISPLAY)
06-19 12:06:43.630 26742-26742/com.example.apps.myApp D/CordovaWebViewImpl: onPageDidNavigate(file:///android_asset/www/index.html)
06-19 12:06:43.715 26742-26869/com.example.apps.myApp W/VideoCapabilities: Unrecognized profile 2130706433 for video/avc
06-19 12:06:43.727 26742-26869/com.example.apps.myApp W/VideoCapabilities: Unrecognized profile/level 0/3 for video/mpeg2
06-19 12:06:43.751 26742-26869/com.example.apps.myApp I/VideoCapabilities: Unsupported profile 4 for video/mp4v-es
06-19 12:06:43.828 26742-26742/com.example.apps.myApp W/cr_BindingManager: Cannot call determinedVisibility() - never saw a connection for the pid: 26742
06-19 12:06:44.212 26742-26742/com.example.apps.myApp D/JsMessageQueue: Set native->JS mode to EvalBridgeMode
06-19 12:06:44.296 26742-26742/com.example.apps.myApp D/CordovaWebViewImpl: onPageFinished(file:///android_asset/www/index.html)
06-19 12:06:44.519 26742-26742/com.example.apps.myApp D/SystemWebChromeClient: file:///android_asset/www/plugins/cordova-plugin-apteligent/www/js/crittercism.js: Line 112 : Using Crittercism Plugin v3.3.2
06-19 12:06:44.519 26742-26742/com.example.apps.myApp I/chromium: [INFO:CONSOLE(112)] "Using Crittercism Plugin v3.3.2", source: file:///android_asset/www/plugins/cordova-plugin-apteligent/www/js/crittercism.js (112)
06-19 12:06:44.728 26742-26901/com.example.apps.myApp D/NetworkManager: toLower : wifi
06-19 12:06:44.729 26742-26901/com.example.apps.myApp D/NetworkManager: wifi : wifi
06-19 12:06:44.729 26742-26901/com.example.apps.myApp D/NetworkManager: Connection Type: wifi
06-19 12:06:44.729 26742-26901/com.example.apps.myApp D/NetworkManager: Connection Extra Info: "NSA-2GHz"
06-19 12:06:44.741 26742-26742/com.example.apps.myApp D/NetworkManager: toLower : wifi
06-19 12:06:44.741 26742-26742/com.example.apps.myApp D/NetworkManager: wifi : wifi
06-19 12:06:44.741 26742-26742/com.example.apps.myApp D/NetworkManager: Connection Type: wifi
06-19 12:06:44.741 26742-26742/com.example.apps.myApp D/NetworkManager: Connection Extra Info: "NSA-2GHz"
06-19 12:06:49.960 26742-26742/com.example.apps.myApp W/cr_BindingManager: Cannot call determinedVisibility() - never saw a connection for the pid: 26742
06-19 12:06:49.974 26742-26742/com.example.apps.myApp W/cr_BindingManager: Cannot call determinedVisibility() - never saw a connection for the pid: 26742
06-19 12:06:50.231 26742-26901/com.example.apps.myApp I/GAv4: Google Analytics 9.8.77 is starting up. To enable debug logging on a device run:
                                                                              adb shell setprop log.tag.GAv4 DEBUG
                                                                              adb logcat -s GAv4
06-19 12:06:50.287 26742-26901/com.example.apps.myApp W/PluginManager: THREAD WARNING: exec() call to UniversalAnalytics.startTrackerWithId blocked the main thread for 71ms. Plugin should use CordovaInterface.getThreadPool().
06-19 12:06:50.348 26742-26901/com.example.apps.myApp W/CordovaPlugin: Attempted to send a second callback for ID: UniversalAnalytics185771112
                                                                                     Result was: "Invalid action"
06-19 12:06:50.982 26742-26901/com.example.apps.myApp I/App: WARNING: Back Button Default Behavior will be overridden.  The backbutton event will be fired!
06-19 12:06:51.008 26742-27092/com.example.apps.myApp I/Crittercism: Initializing Crittercism 5.8.9 for App ID 55f8aa138d4d8c0a00d07984
06-19 12:06:51.050 26742-26901/com.example.apps.myApp W/PluginManager: THREAD WARNING: exec() call to SecureStorage.init blocked the main thread for 39ms. Plugin should use CordovaInterface.getThreadPool().
06-19 12:06:51.279 26742-26742/com.example.apps.myApp W/cr_BindingManager: Cannot call determinedVisibility() - never saw a connection for the pid: 26742
06-19 12:06:51.318 26742-26742/com.example.apps.myApp D/SystemWebChromeClient: file:///android_asset/www/app.js: Line 33024 : Created secure storage
06-19 12:06:51.319 26742-26742/com.example.apps.myApp I/chromium: [INFO:CONSOLE(33024)] "Created secure storage", source: file:///android_asset/www/app.js (33024)
06-19 12:06:51.399 26742-26901/com.example.apps.myApp V/Push_Plugin: execute: action=init
06-19 12:06:51.413 26742-26748/com.example.apps.myApp W/art: Suspending all threads took: 7.822ms
06-19 12:06:51.418 26742-26901/com.example.apps.myApp W/PluginManager: THREAD WARNING: exec() call to PushNotification.init blocked the main thread for 19ms. Plugin should use CordovaInterface.getThreadPool().
06-19 12:06:51.419 26742-26908/com.example.apps.myApp V/Push_Plugin: execute: data=[{"android":{"senderID":"1234567788","icon":"notification","iconColor":"#ff3498db"},"ios":{"senderID":"1234567788","alert":"true","badge":"true","sound":"true"}}]
06-19 12:06:51.420 26742-26908/com.example.apps.myApp V/Push_Plugin: execute: jo={"senderID":"1234567788","icon":"notification","iconColor":"#ff3498db"}
06-19 12:06:51.420 26742-26908/com.example.apps.myApp W/ResourceType: No package identifier when getting value for resource number 0x00000000
                                                                                    
                                                                                    --------- beginning of crash
06-19 12:06:51.432 26742-26908/com.example.apps.myApp E/AndroidRuntime: FATAL EXCEPTION: pool-1-thread-2
                                                                                      Process: com.example.apps.myApp, PID: 26742
                                                                                      android.content.res.Resources$NotFoundException: String resource ID #0x0
                                                                                          at android.content.res.Resources.getText(Resources.java:312)
                                                                                          at android.content.res.Resources.getString(Resources.java:400)
                                                                                          at android.content.Context.getString(Context.java:409)
                                                                                          at com.adobe.phonegap.push.PushPlugin.getStringResourceByName(PushPlugin.java:449)
                                                                                          at com.adobe.phonegap.push.PushPlugin.access$200(PushPlugin.java:31)
                                                                                          at com.adobe.phonegap.push.PushPlugin$1.run(PushPlugin.java:71)
                                                                                          at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
                                                                                          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
                                                                                          at java.lang.Thread.run(Thread.java:818)
06-19 12:06:51.465 26742-26742/com.example.apps.myApp D/CordovaActivity: Paused the activity.
06-19 12:06:51.721 26742-26832/com.example.apps.myApp E/Surface: getSlotFromBufferLocked: unknown buffer: 0xb9a58188
06-19 12:06:51.883 26742-26742/com.example.apps.myApp D/CordovaActivity: Stopped the activity.
06-19 12:06:51.883 26742-26742/com.example.apps.myApp D/CordovaActivity: CordovaActivity.onDestroy()
06-19 12:06:51.885 26742-26742/com.example.apps.myApp D/CordovaWebViewImpl: >>> loadUrl(about:blank)
06-19 12:06:51.886 26742-26742/com.example.apps.myApp W/cr_AwContents: WebView.destroy() called while WebView is still attached to window.
06-19 12:06:51.902 26742-26807/com.example.apps.myApp W/cr_BindingManager: Cannot setInForeground() - never saw a connection for the pid: 26742

@macdonst
Copy link
Member

@kukikiloke are you using FCM? Did you add the google-services.json into your project? I'm assuming you didn't and that is why it can't find the GCM_DEFAULT_SENDER_ID. The plugin API has changed between the v1 and v2 streams.

https://github.com/phonegap/phonegap-plugin-push/blob/master/docs/INSTALLATION.md#installation-requirements

Regardless, this is a bug as the app should not crash.

@kukikiloke
Copy link
Author

kukikiloke commented Jun 19, 2017

@macdonst Yes, I am using FCM. I also have google-services.json (as follows) on the same location as the config.xml. Could it be because I have more than 1 client defined?

{
  "project_info": {
    "project_number": "1234567788",
    "firebase_url": "https://example-b1234.firebaseio.com",
    "project_id": "example-b1234",
    "storage_bucket": "example-b1234.appspot.com"
  },
  "client": [
    {
      "client_info": {
        "mobilesdk_app_id": "1:1234567788:android:xxxxxxx",
        "android_client_info": {
          "package_name": "com.example.apps.appA"
        }
      },
      "oauth_client": [
        {
          "client_id": "1234567788-xxxxxxxxxx.apps.googleusercontent.com",
          "client_type": 3
        }
      ],
      "api_key": [
        {
          "current_key": "xxxxxxxx"
        }
      ],
      "services": {
        "analytics_service": {
          "status": 1
        },
        "appinvite_service": {
          "status": 1,
          "other_platform_oauth_client": []
        },
        "ads_service": {
          "status": 2
        }
      }
    },
    {
      "client_info": {
        "mobilesdk_app_id": "1:1234567788:android:xxxxxx",
        "android_client_info": {
          "package_name": "com.example.apps.appB"
        }
      },
      "oauth_client": [
        {
          "client_id": "1234567788-xxxxxxxxxx.apps.googleusercontent.com",
          "client_type": 3
        }
      ],
      "api_key": [
        {
          "current_key": "xxxxxxxx"
        }
      ],
      "services": {
        "analytics_service": {
          "status": 1
        },
        "appinvite_service": {
          "status": 1,
          "other_platform_oauth_client": []
        },
        "ads_service": {
          "status": 2
        }
      }
    },
    {
      "client_info": {
        "mobilesdk_app_id": "1:1234567788:android:xxxxxxxx",
        "android_client_info": {
          "package_name": "com.example.apps.myApp"
        }
      },
      "oauth_client": [
        {
          "client_id": "1234567788-xxxxxxxxxx.apps.googleusercontent.com",
          "client_type": 3
        }
      ],
      "api_key": [
        {
          "current_key": "xxxxxxxx"
        }
      ],
      "services": {
        "analytics_service": {
          "status": 1
        },
        "appinvite_service": {
          "status": 1,
          "other_platform_oauth_client": []
        },
        "ads_service": {
          "status": 2
        }
      }
    }
  ],
  "configuration_version": "1"
}

@kukikiloke kukikiloke changed the title [Android] App crashes right after launch [Android] App crashes right after launch (using fcm) Jun 19, 2017
@macdonst
Copy link
Member

@kukikiloke that shouldn't be a problem as the google services plugin should pick up the right value by build type.

@madara134
Copy link

me too ! i allway crash when receive notification topics !

@tlaverdure
Copy link

I am running into the same issue, it looks like the plugin cannot find the GCM_DEFAULT_SENDER_ID on init although the google-services.json file is in the root of the project and I've included this line in the anddroid platform:

<resource-file src="google-services.json" target="google-services.json" />

@tlaverdure
Copy link

Any update on this?

@tlaverdure
Copy link

I removed this plugin and it started working again.

https://github.com/EddyVerbruggen/cordova-plugin-safariviewcontroller

@maikelsgit
Copy link

maikelsgit commented Jul 26, 2017

Some help please, I have the same problem!
I have a Ionic project.

My Log:

V/Push_Plugin(10794): execute: action=init
V/Push_Plugin(10794): execute: data=[{"ios":{"fcmSandbox":"true","alert":"true","badge":"true","sound":"true","clearBadge":"false"},"android":{"senderID":"12345678","sound":"true","vibrate":"false","clearBadge":"false","iconColor":"#34363a"}}]
V/Push_Plugin(10794): execute: jo={"senderID":"12345678","sound":"true","vibrate":"false","clearBadge":"false","iconColor":"#34363a"}
W/ResourceType(10794): No package identifier when getting value for resource number 0x00000000
E/AndroidRuntime(10794): FATAL EXCEPTION: pool-1-thread-2
E/AndroidRuntime(10794): Process: com.companyname.appname, PID: 10794
E/AndroidRuntime(10794): android.content.res.Resources$NotFoundException: String resource ID #0x0
E/AndroidRuntime(10794): 	at android.content.res.Resources.getText(Resources.java:1334)
E/AndroidRuntime(10794): 	at android.content.res.Resources.getString(Resources.java:1428)
E/AndroidRuntime(10794): 	at android.content.Context.getString(Context.java:382)
E/AndroidRuntime(10794): 	at com.adobe.phonegap.push.PushPlugin.getStringResourceByName(PushPlugin.java:449)
E/AndroidRuntime(10794): 	at com.adobe.phonegap.push.PushPlugin.-wrap1(PushPlugin.java)
E/AndroidRuntime(10794): 	at com.adobe.phonegap.push.PushPlugin$1.run(PushPlugin.java:71)
E/AndroidRuntime(10794): 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
E/AndroidRuntime(10794): 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
E/AndroidRuntime(10794): 	at java.lang.Thread.run(Thread.java:818)

App Push Init

//iniate push service 
  var push = PushNotification.init({
    ios: {
      fcmSandbox: "false",
      alert: "true",
      badge: "true",
      sound: "true",
      clearBadge: "false"
    },
    android: {
      senderID: "12345678",
      sound: "true",
      vibrate: "false",
      clearBadge: "false",
      iconColor: "#34363a"
    }
});

Installation
According the installation instruction when you use Ionic

Note: if you are using Ionic you may need to specify the SENDER_ID variable in your package.json.

"cordovaPlugins": [
    {
      "locator": "phonegap-plugin-push"
    }
  ]

So I followed the installation instructions and added above to my existing package.json, result:

"cordovaPlugins": [
   "cordova-plugin-device",
  "cordova-plugin-console",
  "cordova-plugin-whitelist",
  "cordova-plugin-splashscreen",
  "cordova-plugin-statusbar",
  "ionic-plugin-keyboard",
  {
    "locator": "phonegap-plugin-push"
  }
],

I'm also using the safariviewcontroller plugin and removed it from my project, but app still stops after launch :(
I also have the latest Android SDK libraries.
Do I mis something?? Please help

@elsesiy
Copy link

elsesiy commented Jul 31, 2017

We're experiencing the same behavior and haven't found a solution so far. We're not using the SafariViewController-Plugin and the latest version of this plugin 2.0.0-rc5.

@faustoct1
Copy link

me too. any fix, workaround, solution, ... ?

@gregor-srdic
Copy link

I am also encountering this problem in combination with cordova-plugin-safariviewcontroller, if I remove it, it works. But I need it to support social login. Any idea what is causing the problem, has anyone been able to solve it?

@ben-8409
Copy link
Contributor

ben-8409 commented Aug 28, 2017

I am encountering the same problem, the reason in my case is that the resource string with the id gcm_defaultSenderId cannot be found. This crash occurs in the execute function of the plugin. I have added another catch so that the error does not crash the app, but of course, the plugin still is not working without the id.

diff --git a/src/android/com/adobe/phonegap/push/PushPlugin.java b/src/android/com/adobe/phonegap/push/PushPlugin.java
index 32f72bf..8f6292a 100644
--- a/src/android/com/adobe/phonegap/push/PushPlugin.java
+++ b/src/android/com/adobe/phonegap/push/PushPlugin.java
@@ -4,6 +4,7 @@ import android.app.Activity;
 import android.app.NotificationManager;
 import android.content.Context;
 import android.content.SharedPreferences;
+import android.content.res.Resources;
 import android.os.Bundle;
 import android.util.Log;
 
@@ -98,6 +99,10 @@ public class PushPlugin extends CordovaPlugin implements PushConstants {
                     } catch (IOException e) {
                         Log.e(LOG_TAG, "execute: Got IO Exception " + e.getMessage());
                         callbackContext.error(e.getMessage());
+                    } catch (Resources.NotFoundException e) {
+
+                        Log.e(LOG_TAG, "execute: Got Resources NotFoundException " + e.getMessage());
+                        callbackContext.error(e.getMessage());
                     }
 
                     if (jo != null) {

@gregor-srdic
Copy link

But does the push notifications functionality still work after you do this?
I have moved to Firebase plugin for now :O

@ben-8409
Copy link
Contributor

@gregor-srdic no, it does not. It just prevents the full app from crashing just because the plugin does not work. Which plugin do you use now?

To help debugging, here is a list of other plugins I use:

  • cordova-plugin-add-swift-support 1.6.1 "AddSwiftSupport"
  • cordova-plugin-app-event 1.2.0 "Application Events"
  • cordova-plugin-app-name 1.0.0 "App Namer"
  • cordova-plugin-app-version 0.1.9 "AppVersion"
  • cordova-plugin-backbutton 0.3.0 "Backbutton"
  • cordova-plugin-camera 2.4.1 "Camera"
  • cordova-plugin-compat 1.1.0 "Compat"
  • cordova-plugin-console 1.0.7 "Console"
  • cordova-plugin-device 1.1.6 "Device"
  • cordova-plugin-file 4.3.3 "File"
  • cordova-plugin-geolocation 2.4.3 "Geolocation"
  • cordova-plugin-globalization 1.0.7 "Globalization"
  • cordova-plugin-inappbrowser 1.7.1 "InAppBrowser"
  • cordova-plugin-splashscreen 4.0.3 "Splashscreen"
  • cordova-plugin-sqlite-2 1.0.4 "SQLitePlugin"
  • cordova-plugin-statusbar 2.2.3 "StatusBar"
  • cordova-plugin-webserver 1.0.3 "CordovaWebServer"
  • cordova-plugin-whitelist 1.3.2 "Whitelist"
  • cordova-plugin-wkwebview-engine 1.1.3 "Cordova WKWebView Engine"
  • cordova-plugin-x-socialsharing 5.1.8 "SocialSharing"
  • de.appplant.cordova.plugin.local-notification 0.8.5 "LocalNotification"
  • es6-promise-plugin 4.1.0 "Promise"
  • ionic-plugin-deeplinks 1.0.15 "Ionic Deeplink Plugin"
  • ionic-plugin-keyboard 2.2.1 "Keyboard"
  • phonegap-plugin-barcodescanner 6.0.8 "BarcodeScanner"
  • phonegap-plugin-push 2.0.0 "PushPlugin"

@arael
Copy link

arael commented Aug 30, 2017

I have the same issue here. Here is the list of my plugins:

cordova-plugin-device
cordova-plugin-network-information
cordova-plugin-file
cordova-plugin-file-transfer
cordova-plugin-splashscreen
cordova-plugin-inappbrowser
cordova-plugin-console
phonegap-plugin-push
cordova-plugin-uniquedeviceid
https://github.com/rtk/cordova-cookie-emperor.git

@macdonst
Copy link
Member

macdonst commented Sep 1, 2017

@ben-8409 I merged in your PR.

All, I still can't reproduce this bug so I can't fix it. If anyone has a detailed reproduction scenario please let me know.

@haelmx
Copy link

haelmx commented Sep 5, 2017

I have the same issue and removing cordova-plugin-safariviewcontroller as @tlaverdure commented has fixed it.

@tunafly
Copy link

tunafly commented Sep 13, 2017

@macdonst
I had the same issue and found that ext.postBuildExtras in push.gradle is replaced by other ext.postBuildExtras (In my case, ext.postBuildExtras in build-extras.gradle) for 2.0.0 and 2.0.0-rc5.
Because of this, the google service initialization is failed.

The plugin 'cordova-plugin-safariviewcontroller' also uses ext.postBuildExtras in SafariViewController-java17.gradle and it will replace postBuildExtras.

Thus, if some plugins use ext.postBuildExtras in *.gradle, then it can be replaced.

@canado
Copy link

canado commented Sep 19, 2017

I encounter the same problem

@ionut-movila
Copy link

For me solution was to move everything from .gradle files pertaining to plugins (push plugin and Safari view controller) to build-extras.gradle and comment out references to these files in project build.gradle and project.properties

@ardabeyazoglu
Copy link

The same issue here. If i change the problematic line with senderID = jo.getString("senderID");, it gets the sender id correctly. However then it fails with another error:
java.lang.IllegalStateException: Default FirebaseApp is not initialized in this process com.****. Make sure to call FirebaseApp.initializeApp(Context) first.

@ardabeyazoglu
Copy link

I solved the problem by adding cordova.system.library.7=com.google.android.gms:play-services-analytics:11.0.1 to project.properties instead of using '+' for the service.

@phillipplum
Copy link

I have the same issue and removing cordova-plugin-safariviewcontroller as @tlaverdure commented has fixed it.

@1N50MN14
Copy link

1N50MN14 commented Oct 2, 2017

Having the same issue, cordova-android 6.3.0 + FCM

@hirbod
Copy link

hirbod commented Oct 11, 2017

I'm facing the same Issue @macdonst
Removing cordova-plugin-safariviewcontroller didn't fix anything as I use my own "builds-extra" file.

The problem occurs if using "builds-extra.gradle" which I have to use, as cordova uses Java 1.6 instead of 1.7 for me

ext.postBuildExtras = {
    android {
        compileOptions {
            sourceCompatibility JavaVersion.VERSION_1_7
            targetCompatibility JavaVersion.VERSION_1_7
        }
        allprojects {
            compileOptions {
                sourceCompatibility = JavaVersion.VERSION_1_7
                targetCompatibility = JavaVersion.VERSION_1_7
            }
        }
    }
}

But I can't use my app without this..

EDIT:
I removed that file an put that stuff directly inside of "build.gradle"

    android {
        compileOptions {
            sourceCompatibility JavaVersion.VERSION_1_7
            targetCompatibility JavaVersion.VERSION_1_7
        }
        allprojects {
            compileOptions {
                sourceCompatibility = JavaVersion.VERSION_1_7
                targetCompatibility = JavaVersion.VERSION_1_7
            }
        }
    }

Now it works, but I can't use SafariViewController Plugin anymore, as it also uses postBuildExtras. So this is a 100% reproducable error

@aw-vm
Copy link

aw-vm commented Nov 3, 2017

@ardabeyazoglu what line did you changed for senderID = jo.getString("senderID"); was it senderID = getStringResourceByName(GCM_DEFAULT_SENDER_ID); ?

@ardabeyazoglu
Copy link

@valerymadiedo exactly. However it doesnt help that way, it produce error in other parts eventually. I solved it by playing with project.properties version numbers.

@aw-vm
Copy link

aw-vm commented Nov 3, 2017

@ardabeyazoglu thank you, I wanted to be sure as I did the change but got this error on the same line No value for senderID. I have changed my project.properties version numbers and still have the String resource ID #0x0

@ardabeyazoglu
Copy link

What error you see exactly ? And plz show your project.properties file contents

@aw-vm
Copy link

aw-vm commented Nov 3, 2017

@ardabeyazoglu I mean that When i changed to senderID = jo.getString("senderID"); the app still couldn't find the senderId. I am stuck in error with Push pluginError: String resource ID #0x0

I'm also using safariviewcontroller for Auth0 login. I know the phonegap-plugin-push works if I uninstall safariviewcontroller but I really need it for the auth functionality, as I need plugin-push for the notifications functionality. :(

project.properties

target=android-26
android.library.reference.1=CordovaLib
cordova.gradle.include.1=cordova-plugin-crosswalk-webview/selreceiver-xwalk.gradle
cordova.system.library.1=com.android.support:support-v13:26.+
cordova.system.library.2=me.leolin:ShortcutBadger:1.1.17@aar
cordova.system.library.3=com.google.firebase:firebase-messaging:11.0.1
cordova.gradle.include.2=phonegap-plugin-push/selreceiver-push.gradle
cordova.system.library.4=com.google.android.gms:play-services-location:11.0.1
cordova.gradle.include.3=cordova-plugin-safariviewcontroller/selreceiver-SafariViewController-java17.gradle
cordova.system.library.5=com.android.support:customtabs:23.2.0

@ardabeyazoglu
Copy link

Well i never used it so i dont know what cause this bug. But there are fcm push plugins you might consider instead of this plugin, if you dont use advanced features.

@tomercagan
Copy link

@macdonst - I encountered this problem as well today - on an app (plain cordova) that used to work with phonegap-plugin-push but after removing and adding platforms/plugins (don't ask, some repository issues) stopped working.

TL;DR

To reproduce (or, at list I think so):

  1. Create your regular cordova app (cordova create)
  2. Add android platform (cordova platform add android). Not sure whether it will happen in iOS as well.
  3. Add Phonegap Puh plugin (cordova plugin add phonegap-plugin-push, plus required json)
  4. Add MS code-push plugin (cordova plugin add cordova-plugin-code-push)
  5. Add your regular initialization code (I have it both for code push and push-plugin, in this order within deviceready but I don't know if it matters)
  6. cordova run android and enjoy the cryptic Error: String resource ID #0x0 error

The Long Story

(maybe it can help, not sure)

In the js console I was getting the (cryptic) error (which yields no meaningful google search results ):

Error: String resource ID #0x0

Using logcat, it seems that there's a Resource.NotFoundException as described earlier in this thread and the error handler added by @ben-8409 . (Note - I have not stepped through the code so I assume this is the cause of the error - trying to getStringResourceByName fails, I attached logcat below)

I was initially baffled with it as the app used to work before with the same set of plugins. After some tinkering (and headbanging), I realized that maybe there's some conflict between plugins (as suggested above, though I have not used the specific plugin). In my initial version (one that worked) the last plugin I added was cordova-plugin-code-push. When I added phonegap-plugin-push after it, it worked. In the second version (one that gave me error) I added phonegap-plugin-push before cordova-plugin-code-push.

To verify it, I created a new app adding the relevant plugins in the "wrong" order and indeed I was getting this error again. (see above how to reproduce).

My guess is that somehow some plugins conflicts but I don't know enough to know exactly what.

The relevant logcat messages follows. I believe the source is src\android\com\adobe\phonegap\push\PushPlugin.java around line 172 (from following the logcat messages)

11-18 13:56:50.440 25855 12684 V Push_Plugin: execute: jo={"iconColor":"#00ccfb"}
11-18 13:56:50.440 25855 12684 W ResourceType: No package identifier when getting value for resource number 0x00000000
11-18 13:56:50.440 25855 12684 E Push_Plugin: execute: Got Resources NotFoundException String resource ID #0x0

@rafalowski
Copy link

same problem here...
Adding the cordova-plugin-safariviewcontroller for using the auth0-cordova.js results that I stopped receiving push notifications...

Removing the cordova-plugin-safariviewcontroller and the push notifications are back

Please help.
I am also posting the Issue on the cordova-plugin-safariviewcontroller repository
EddyVerbruggen/cordova-plugin-safariviewcontroller#84

@adrenaline15
Copy link

Is there any progress on this issue?

I'm also facing the same problem: String resource ID #0x0

Since I also need to use the auth0-WebView authentication which requires cordova-plugin-safariviewcontroller I can't refrain on this plugin =/

@aw-vm
Copy link

aw-vm commented Mar 14, 2018

@adrenaline15 I also had to use auth0 and plugin push so I removed safariviewcontroller plugin and used directly auth0 and webAuth from auth0-js library. Using the library directly lets you build your own login view.

@tbassett44
Copy link

tbassett44 commented Apr 19, 2018

I was able to fix by updating my build-extras.gradle like this. Although i havent dug down in it, I think @tunafly is right. I noticed there was a cdvPluginPostBuildExtras towards the end of the build.gradle and was able to add support for the SafariViewController without wiping out the ext.postBuildExtras
set in this plugin.

ext.cdvDebugSigningPropertiesFile = 'release-signing.properties'
ext.cdvReleaseSigningPropertiesFile = 'release-signing.properties'
ext.cdvPluginPostBuildExtras.add({
    android {
        compileOptions {
            sourceCompatibility JavaVersion.VERSION_1_7
            targetCompatibility JavaVersion.VERSION_1_7
        }
        allprojects {
            compileOptions {
                sourceCompatibility = JavaVersion.VERSION_1_7
                targetCompatibility = JavaVersion.VERSION_1_7
            }
        }
    }
})

@codyrushing
Copy link

Is there any update on this? The safariviewcontroller plugin dev is saying that it can't be fixed from his end, so is anyone working on fixing phonegap-plugin-push?

Other folks suggest that using cordova v8 will fix this. I tried that, but it breaks cordova-plugin-customurlscheme, which is needed to register an oauth callback inside cordova. So trying to use oauth redirects + push notifications currently is not possible with phonegap until this gets fixed

@jcesarmobile
Copy link
Collaborator

If the problem is a conflict when using multiple postBuildExtras, it can’t be fixed on the plugin, should be fixed on Cordova. If you say that some people say it works on Cordova 8 you’ll have to update and try to fix the other plugin that doesn’t work there

@heralden
Copy link

It seems like Cordova already provides cdvPluginPostBuildExtras for this exact purpose, so I think the problem lies with cordova-plugin-safariviewcontroller and cordova-support-google-services. (the latter a dependency of phonegap-plugin-push)

Both of the plugins already have issues for this:
EddyVerbruggen/cordova-plugin-safariviewcontroller#84
chemerisuk/cordova-support-google-services#9

In other words, I don't think the problem lies with phonegap-plugin-push or Cordova.

See my latest comment on the safariviewcontroller issue for a simple temporary fix until the issue is fixed upstream.

@pavane90
Copy link

I had the same problem. My solution was like this.

please check this page
fechanique/cordova-plugin-fcm#499 (comment)

In platforms > android > cordova-plugin-fcm > youapp-FCMPlugin.gradle, remove the lines classpath 'com.google.gms:google-services:3.0.0' and apply plugin: com.google.gms.googleservices.GoogleServicesPlugin
In platforms > android > build.gradle, add classpath 'com.google.gms:google-services:3.2.1' in dependencies (around line 32)
In platforms > android > app > build.gradle, add apply plugin: 'com.google.gms.google-services' at the very end of the file
If this does not work, change lines 68 and 69 (framework tags) of plugins > cordova-plugin-fcm > plugin.xml to , remove and add the android platform again and redo the steps above.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

No branches or pull requests