SYMPTOM
You receive the following error message at compile time:
:transformClassesWithDexForDebug
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Lcom/google/android/gms/internal/zzr;
SOLUTION
MOCA Plugin for Cordova / PhoneGap requires the following dependencies on Android:
- Google Play Services (GPSS) - Cloud Messaging (GCM)
- GPSS - Location Services
- GPSS - Ads
- MessagePack
If you are using other plugins within your project, it is common that some of these plugins rely also on GPSS for some functionality. The problem arises when any of these libraries use a different version of GPSS.
MOCA Plugin expects at least GPSS version 8.3. We provide you the plugin with this version in the plugin configuration, so you can have predictable builds in the future.
In order to fix this issue, please use one of the following solutions:
Option A:
Change the mocabuild.gradle
file within the plugin folder and change all the versions to the latest one, bear in mind that your other plugins should also use the same version.
Option B:
Create a file called build-extras.gradle
in the following folder your_app_name > platforms > android
and paste the following code there.
// When set, this function allows code to run at the end of `build.gradle` ext.postBuildExtras = { configurations.all { resolutionStrategy { //Google Cloud Messaging force 'com.google.android.gms:play-services-gcm:+' //Google Location, Activity Recognition, and Places force 'com.google.android.gms:play-services-location:+' //Google Mobile Ads force 'com.google.android.gms:play-services-ads:+' } } }
If there is any other plugin that uses any part of GPSS, you should include it here as well, and remember: All GPSS dependencies must use the same version, otherwise you will get errors at Compile or at RunTime.
Below you will find a list of possible GPSS dependencies
# Google+ force 'com.google.android.gms:play-services-plus:+' # Google Account Login force 'com.google.android.gms:play-services-auth:+' # Google Actions, Base Client Library force 'com.google.android.gms:play-services-base:+' # Google Address API force 'com.google.android.gms:play-services-identity:+' # Google App Indexing force 'com.google.android.gms:play-services-appindexing:+' # Google App Invites force 'com.google.android.gms:play-services-appinvite:+' # Google Analytics force 'com.google.android.gms:play-services-analytics:+' # Google Cast force 'com.google.android.gms:play-services-cast:+' # Google Cloud Messaging force 'com.google.android.gms:play-services-gcm:+' # Google Drive force 'com.google.android.gms:play-services-drive:+' # Google Fit force 'com.google.android.gms:play-services-fitness:+' # Google Location, Activity Recognition, and Places force 'com.google.android.gms:play-services-location:+' # Google Maps force 'com.google.android.gms:play-services-maps:+' # Google Mobile Ads force 'com.google.android.gms:play-services-ads:+' # Mobile Vision force 'com.google.android.gms:play-services-vision:+' # Google Nearby force 'com.google.android.gms:play-services-nearby:+' # Google Panorama Viewer force 'com.google.android.gms:play-services-panorama:+' # Google Play Game services force 'com.google.android.gms:play-services-games:+' # SafetyNet force 'com.google.android.gms:play-services-safetynet:+' # Android Pay force 'com.google.android.gms:play-services-wallet:+' # Android Wear force 'com.google.android.gms:play-services-wearable:+'
Comments
0 comments
Article is closed for comments.