{"__v":0,"_id":"57979d3e9eaa220e006128ca","category":{"__v":7,"_id":"55bb441b54f9640d006e6cf2","pages":["55bb4450a8400c2d00873dd9","55bb46afa8400c2d00873de6","55bb46cca8400c2d00873dea","55bb4704a8400c2d00873ded","55bb47477313650d00c46e1e","568166af30018c0d006bf7fd","5685143fd96a760d00545d71"],"project":"559a61d2dbcfd20d00710b39","version":"559a61d2dbcfd20d00710b3c","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2015-07-31T09:47:07.862Z","from_sync":false,"order":6,"slug":"cordova-phonegap","title":"Cordova / PhoneGap SDK"},"parentDoc":null,"project":"559a61d2dbcfd20d00710b39","user":"559a618bdbcfd20d00710b38","version":{"__v":23,"_id":"559a61d2dbcfd20d00710b3c","project":"559a61d2dbcfd20d00710b39","createdAt":"2015-07-06T11:09:06.510Z","releaseDate":"2015-07-06T11:09:06.510Z","categories":["559a61d3dbcfd20d00710b3d","55a589ddaaf9cf1900114dd0","55a589e30f354f0d00fd0312","55a589ea80c8a30d00b323cc","55a589f6aaf9cf1900114dd1","55a58d4e80c8a30d00b323e6","55a8e7a227a17d21005251a2","55a93098cf45e1390093f351","55afb085f202b12100cd9e83","55afb22e902fd51700f5f8bf","55afb260902fd51700f5f8c2","55afb28ec8a85321007a5462","55afb294f202b12100cd9e95","55afb29b902fd51700f5f8c5","55afb2a1c8a85321007a5463","55afb2a7902fd51700f5f8c7","55afb2ad902fd51700f5f8c8","55afb2b5902fd51700f5f8ca","55b74b2131bccb190081bedc","55bb441b54f9640d006e6cf2","565711085cb2420d00d70071","5681681330018c0d006bf7ff","588f38b5923d610f00c72dad"],"is_deprecated":false,"is_hidden":false,"is_beta":true,"is_stable":true,"codename":"Version 1.0","version_clean":"1.0.0","version":"1"},"updates":[],"next":{"pages":[],"description":""},"createdAt":"2016-07-26T17:26:22.879Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":4,"body":"[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Dependencies conflict (Android)\"\n}\n[/block]\n##Symptom\nYou receive the following error message at compile time:\n\n```\n:transformClassesWithDexForDebug\nUNEXPECTED TOP-LEVEL EXCEPTION:\ncom.android.dex.DexException: Multiple dex files define Lcom/google/android/gms/internal/zzr;\n```\n\n##Solution\n\nMOCA Plugin for Cordova / PhoneGap requires the following dependencies on Android:\n- Google Play Services (GPSS) - Cloud Messaging (GCM)\n- GPSS - Location Services\n- GPSS - Ads\n- MessagePack\n\nIf you are using other plugins within your project, it is common that some of these plugins also rely on GPSS for some functionality. So the problem comes when some of these libraries uses a different versions of GPSS.\n\nMOCA 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. \n\nIn order to fix this issue, please use one of the following solutions:\n\nOption A:\n\nChange 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**.\n\nOption B:\n\nCreate a file called `build-extras.gradle` in the following folder `your_app_name > platforms > android` and paste the following code there.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"\\n\\n// When set, this function allows code to run at the end of `build.gradle`\\next.postBuildExtras = {\\n    configurations.all {\\n\\t\\tresolutionStrategy {\\n      \\t//Google Cloud Messaging\\n    \\t\\tforce 'com.google.android.gms:play-services-gcm:+'\\n    \\t\\t\\n      \\t//Google Location, Activity Recognition, and Places\\n   \\t\\t\\tforce 'com.google.android.gms:play-services-location:+'\\n\\n    \\t\\t//Google Mobile Ads\\n   \\t\\t\\tforce 'com.google.android.gms:play-services-ads:+'\\n\\t\\t}\\n\\t}\\n}\\n\",\n      \"language\": \"groovy\",\n      \"name\": \"build-extras.gradle\"\n    }\n  ]\n}\n[/block]\nIf 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.\n\nBelow you will find a list of possible GPSS dependencies\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"# Google+\\nforce 'com.google.android.gms:play-services-plus:+'\\n# Google Account Login\\nforce 'com.google.android.gms:play-services-auth:+'\\n# Google Actions, Base Client Library\\nforce 'com.google.android.gms:play-services-base:+'\\n# Google Address API\\nforce 'com.google.android.gms:play-services-identity:+'\\n# Google App Indexing\\nforce 'com.google.android.gms:play-services-appindexing:+'\\n# Google App Invites\\nforce 'com.google.android.gms:play-services-appinvite:+'\\n# Google Analytics\\nforce 'com.google.android.gms:play-services-analytics:+'\\n# Google Cast\\nforce 'com.google.android.gms:play-services-cast:+'\\n# Google Cloud Messaging\\nforce 'com.google.android.gms:play-services-gcm:+'\\n# Google Drive\\nforce 'com.google.android.gms:play-services-drive:+'\\n# Google Fit\\nforce 'com.google.android.gms:play-services-fitness:+'\\n# Google Location, Activity Recognition, and Places\\nforce 'com.google.android.gms:play-services-location:+'\\n# Google Maps\\nforce 'com.google.android.gms:play-services-maps:+'\\n# Google Mobile Ads\\nforce 'com.google.android.gms:play-services-ads:+'\\n# Mobile Vision\\nforce 'com.google.android.gms:play-services-vision:+'\\n# Google Nearby\\nforce 'com.google.android.gms:play-services-nearby:+'\\n# Google Panorama Viewer\\nforce 'com.google.android.gms:play-services-panorama:+'\\n# Google Play Game services\\nforce 'com.google.android.gms:play-services-games:+'\\n# SafetyNet\\nforce 'com.google.android.gms:play-services-safetynet:+'\\n# Android Pay\\nforce 'com.google.android.gms:play-services-wallet:+'\\n# Android Wear\\nforce 'com.google.android.gms:play-services-wearable:+'\",\n      \"language\": \"groovy\",\n      \"name\": \"GPSS dependency examples\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Application crashes at startup\"\n}\n[/block]\n##Symptom\n\nApplication crashes at startup with the following error message\n\n`java.lang.ClassCastException: android.app.Application cannot be cast to com.innoquant.moca.phonegap.MOCApp`\n\n##Solution\n\nMOCA Plugin works even if the app is not running, in order to achieve this functionality, it requires a class to be declared in your `AndroidManifest.xml` `application` tag. If the Android platform is already created when you installed MOCA Plugin, this is done automatically by the installation scripts, however it may not work if there is a conflict with other plugin that has the same requirement, or if the android platform is added afterwards.\n\nOpen your `AndroidManifest.xml` and check the `application` tag, you should observe something similar to this example (notice the `android:name=\"com.innoquant.phonegap.MOCApp\"`)\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/4dbf58c-android-name.png\",\n        \"android-name.png\",\n        579,\n        115,\n        \"#30302f\"\n      ]\n    }\n  ]\n}\n[/block]\n###Case 1: There is no `android:name` tag.\n\n####Solution\n- Just add the tag as shown in the image above.\n\n###Case 2: There are two `android:name` tags, or the class declared is from another plugin.\n\n####Solution\n- In this case the solution is not as straightforward and will require some Java coding in the project.\n\nIf there are two plugins with this requirement within your project, you will need to merge these two classes manually. If you have experience coding Java, just go ahead, create a new class with a name of your preference, merge all functionality in a single class (or create a proxy class that instantiates both classes) and declare this new class in the application tag.\n\nIn any case, if you are in this particular case, please open a [support ticket](mailto:support:::at:::mocaplatform.com). We would like to study in detail any more conflicts that may arise with the 3rd party plugin.\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Other Building errors\"\n}\n[/block]\n##Symptom\n\nYou receive the following error at compile time.\n\n```\n.../HelloWorld/platforms/android/build/intermediates/res/debug/values-v23/values.xml:5: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Inverse\n\n...HelloWorld/platforms/android/build/intermediates/res/debug/values-v23/values.xml:20: error: Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Button.Colored'.\n```\n\n####Solution\n\nMOCA Plugin requires project to be compiled against Android API level 23 (Android M). Please check you have included the min and target in your `config.xml` versions as follows:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<preference name=\\\"android-minSdkVersion\\\" value=\\\"14\\\" />\\n<preference name=\\\"android-targetSdkVersion\\\" value=\\\"23\\\" />\",\n      \"language\": \"xml\"\n    }\n  ]\n}\n[/block]\nIf problem persists, please check the following file:\n\n`YOUR_APP_FOLDER/platforms/android/project.properties`\n\nAnd change the configuration if needed:\n\n`target=android-23`","excerpt":"","slug":"common-issues-troubleshooting","type":"basic","title":"Common issues / Troubleshooting"}

Common issues / Troubleshooting


[block:api-header] { "type": "basic", "title": "Dependencies conflict (Android)" } [/block] ##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 also rely on GPSS for some functionality. So the problem comes when some of these libraries uses a different versions 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. [block:code] { "codes": [ { "code": "\n\n// When set, this function allows code to run at the end of `build.gradle`\next.postBuildExtras = {\n configurations.all {\n\t\tresolutionStrategy {\n \t//Google Cloud Messaging\n \t\tforce 'com.google.android.gms:play-services-gcm:+'\n \t\t\n \t//Google Location, Activity Recognition, and Places\n \t\t\tforce 'com.google.android.gms:play-services-location:+'\n\n \t\t//Google Mobile Ads\n \t\t\tforce 'com.google.android.gms:play-services-ads:+'\n\t\t}\n\t}\n}\n", "language": "groovy", "name": "build-extras.gradle" } ] } [/block] 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 [block:code] { "codes": [ { "code": "# Google+\nforce 'com.google.android.gms:play-services-plus:+'\n# Google Account Login\nforce 'com.google.android.gms:play-services-auth:+'\n# Google Actions, Base Client Library\nforce 'com.google.android.gms:play-services-base:+'\n# Google Address API\nforce 'com.google.android.gms:play-services-identity:+'\n# Google App Indexing\nforce 'com.google.android.gms:play-services-appindexing:+'\n# Google App Invites\nforce 'com.google.android.gms:play-services-appinvite:+'\n# Google Analytics\nforce 'com.google.android.gms:play-services-analytics:+'\n# Google Cast\nforce 'com.google.android.gms:play-services-cast:+'\n# Google Cloud Messaging\nforce 'com.google.android.gms:play-services-gcm:+'\n# Google Drive\nforce 'com.google.android.gms:play-services-drive:+'\n# Google Fit\nforce 'com.google.android.gms:play-services-fitness:+'\n# Google Location, Activity Recognition, and Places\nforce 'com.google.android.gms:play-services-location:+'\n# Google Maps\nforce 'com.google.android.gms:play-services-maps:+'\n# Google Mobile Ads\nforce 'com.google.android.gms:play-services-ads:+'\n# Mobile Vision\nforce 'com.google.android.gms:play-services-vision:+'\n# Google Nearby\nforce 'com.google.android.gms:play-services-nearby:+'\n# Google Panorama Viewer\nforce 'com.google.android.gms:play-services-panorama:+'\n# Google Play Game services\nforce 'com.google.android.gms:play-services-games:+'\n# SafetyNet\nforce 'com.google.android.gms:play-services-safetynet:+'\n# Android Pay\nforce 'com.google.android.gms:play-services-wallet:+'\n# Android Wear\nforce 'com.google.android.gms:play-services-wearable:+'", "language": "groovy", "name": "GPSS dependency examples" } ] } [/block] [block:api-header] { "type": "basic", "title": "Application crashes at startup" } [/block] ##Symptom Application crashes at startup with the following error message `java.lang.ClassCastException: android.app.Application cannot be cast to com.innoquant.moca.phonegap.MOCApp` ##Solution MOCA Plugin works even if the app is not running, in order to achieve this functionality, it requires a class to be declared in your `AndroidManifest.xml` `application` tag. If the Android platform is already created when you installed MOCA Plugin, this is done automatically by the installation scripts, however it may not work if there is a conflict with other plugin that has the same requirement, or if the android platform is added afterwards. Open your `AndroidManifest.xml` and check the `application` tag, you should observe something similar to this example (notice the `android:name="com.innoquant.phonegap.MOCApp"`) [block:image] { "images": [ { "image": [ "https://files.readme.io/4dbf58c-android-name.png", "android-name.png", 579, 115, "#30302f" ] } ] } [/block] ###Case 1: There is no `android:name` tag. ####Solution - Just add the tag as shown in the image above. ###Case 2: There are two `android:name` tags, or the class declared is from another plugin. ####Solution - In this case the solution is not as straightforward and will require some Java coding in the project. If there are two plugins with this requirement within your project, you will need to merge these two classes manually. If you have experience coding Java, just go ahead, create a new class with a name of your preference, merge all functionality in a single class (or create a proxy class that instantiates both classes) and declare this new class in the application tag. In any case, if you are in this particular case, please open a [support ticket](mailto:support@mocaplatform.com). We would like to study in detail any more conflicts that may arise with the 3rd party plugin. [block:api-header] { "type": "basic", "title": "Other Building errors" } [/block] ##Symptom You receive the following error at compile time. ``` .../HelloWorld/platforms/android/build/intermediates/res/debug/values-v23/values.xml:5: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Inverse ...HelloWorld/platforms/android/build/intermediates/res/debug/values-v23/values.xml:20: error: Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Button.Colored'. ``` ####Solution MOCA Plugin requires project to be compiled against Android API level 23 (Android M). Please check you have included the min and target in your `config.xml` versions as follows: [block:code] { "codes": [ { "code": "<preference name=\"android-minSdkVersion\" value=\"14\" />\n<preference name=\"android-targetSdkVersion\" value=\"23\" />", "language": "xml" } ] } [/block] If problem persists, please check the following file: `YOUR_APP_FOLDER/platforms/android/project.properties` And change the configuration if needed: `target=android-23`