function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Adrian HidalgoAdrian Hidalgo 

MC-Cordova-Plugin package R does not exist

I'm trying to integrate Marketing Cloud Push Notifications with Ionic 3 using Salesforce Marketing Cloud Cordova Plugin, but when I execute ionic cordova run android --device the error "package R does not exist" appears, here is a part of the error code:
 
BUILD FAILED

Total time: 27.239 secs
Error: /Users/aiusda/Ionic/push_notifications_MC/platforms/android/gradlew: Command failed with exit code 1 Error output:
/Users/aiusda/Ionic/push_notifications_MC/platforms/android/src/com/salesforce/marketingcloud/cordovaplugin/MCCordovaPluginApplication.java:31: error: package R does not exist
        boolean mcAnalyticsEnabled = "enabled".equalsIgnoreCase(getString(R.string.MCANALYTICS));
                                                                           ^
/Users/aiusda/Ionic/push_notifications_MC/platforms/android/src/com/salesforce/marketingcloud/cordovaplugin/MCCordovaPluginApplication.java:38: error: package R does not exist
                .setNotificationChannelName(String.valueOf(R.string.CHANNELNAME))
                                                            ^
/Users/aiusda/Ionic/push_notifications_MC/platforms/android/src/com/salesforce/marketingcloud/cordovaplugin/MCCordovaPluginApplication.java:36: error: package R does not exist
                .setGcmSenderId(getString(R.string.GCMSENDERID))
                                           ^
/Users/aiusda/Ionic/push_notifications_MC/platforms/android/src/com/salesforce/marketingcloud/cordovaplugin/MCCordovaPluginApplication.java:35: error: package R does not exist
                .setAccessToken(getString(R.string.ACCESSTOKEN))
                                           ^
/Users/aiusda/Ionic/push_notifications_MC/platforms/android/src/com/salesforce/marketingcloud/cordovaplugin/MCCordovaPluginApplication.java:34: error: package R does not exist
                .setApplicationId(getString(R.string.APPID))
Salesforce Marketing Cloud Cordova Plugin Repository

Someone can help me?
Douglas Midgley 7Douglas Midgley 7
Also same error coming up with vanilla Cordova framwork :(
Douglas Midgley 7Douglas Midgley 7
I've looked into the cause and it seems for some reason the r.java file is not available to this class :/ even from the r.java files I checked I couldn't find the variables so maybe something else is going wrong.
Hardcoding (as much as it isnt a great idea) seems to a viable workaround at the moment APPNAME\platforms\android\app\src\main\java\com\salesforce\marketingcloud\cordovaplugin\MCCordovaPluginApplication.java
Adrian HidalgoAdrian Hidalgo
To solve this I added the line in MCCordovaPluginApplication.java:

import com.cloudmobile.mcpn.R;

Where com.cloudmobile.mcpn is the packete of my application. However, another problem appeared:
 
12-27 14:45:36.988 2900-2920/com.cloudmobile.mcpn E/dalvikvm: Could not find class 'android.app.NotificationChannel', referenced from method com.salesforce.marketingcloud.notifications.c.a
12-27 14:45:37.052 2900-2920/com.cloudmobile.mcpn E/dalvikvm: Could not find class 'android.support.v4.app.JobIntentService$JobServiceEngineImpl', referenced from method android.support.v4.app.JobIntentService.onCreate
12-27 14:45:58.277 2900-2900/com.cloudmobile.mcpn E/CordovaWebViewImpl: CordovaWebView: TIMEOUT ERROR!

 
Douglas Midgley 7Douglas Midgley 7
Hmm Doing the same, I didnt get that error. The main issue for me is that the secrets.xml resource file doesnt contain the strings, once I add those there everythings works as expected. Did you have the values present in secrets.xml
Adrian HidalgoAdrian Hidalgo
In fact, my secrets.xml is empty too, the values are stored in platforms/android/android.json