Ionic build doesn't work after update , com.android.dex.DexException

I had an working app build on ionic . It was build on older version a year ago and working fine . but now I wanted to build the app again with updated ionic Version and plugins .

I have following configuration :
System : Ubuntu 14.04
Ionic Version : 1.7.10
Cordova version : 5.4.1

and This is my cordova plugin list output
cordova-plugin-device 1.1.0 "Device" cordova-plugin-dialogs 1.2.0 "Notification" cordova-plugin-file 3.0.0 "File" cordova-plugin-geolocation 1.0.1 "Geolocation" cordova-plugin-google-analytics 0.8.1 "Google Universal Analytics Plugin" cordova-plugin-googleplayservices 19.0.3 "Google Play Services for Android" cordova-plugin-inappbrowser 1.1.0 "InAppBrowser" cordova-plugin-media 1.0.1 "Media" cordova-plugin-network-information 1.1.0 "Network Information" cordova-plugin-splashscreen 3.0.0 "Splashscreen" cordova-plugin-x-socialsharing 5.0.7 "SocialSharing" cordova-plugin-x-toast 2.2.3 "Toast" cordova-sqlite-storage 0.7.14 "Cordova sqlite storage plugin" ionic-plugin-keyboard 1.0.8 "Keyboard"

I just updated all these plugins. But now when I try to build the app it give the following error

`com.android.ide.common.internal.LoggedErrorException: Failed to run command:
/opt/android-sdk/build-tools/23.0.1/dx --dex --no-optimize --output /home/deepak/projects/ionic/pajh_new/platforms/android/build/intermediates/dex/debug --input-list=/home/deepak/projects/ionic/pajh_new/platforms/android/build/intermediates/tmp/dex/debug/inputList.txt
Error Code:
2
Output:

UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Lcom/google/android/gms/actions/ReserveIntents;
	at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596)
	at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:554)
	at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:535)
	at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)
	at com.android.dx.merge.DexMerger.merge(DexMerger.java:189)
	at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:502)
	at com.android.dx.command.dexer.Main.runMonoDex(Main.java:334)
	at com.android.dx.command.dexer.Main.run(Main.java:277)
	at com.android.dx.command.dexer.Main.main(Main.java:245)
	at com.android.dx.command.Main.main(Main.java:106)` 

I found a solution on R&D about this error that it occurs when two file refer to same class and error belongs to build.gradle file , where i found the following lines in the file

compile "com.google.android.gms:play-services-analytics:+" compile "com.android.support:support-v13:23+" compile "com.google.android.gms:play-services-gcm:+"

the solution depicts that "com.google.android.gms:play-services- only needs to be added once so i removed the last line but whne i again run the ionic build android , it gives the same error and these lines are again added to file.

Now i tried to remove one of the plugins , i just removed the plugin phonegap -plugin-push and again tried with a hope to work…

But only the error class changed this time:

com.android.ide.common.internal.LoggedErrorException: Failed to run command:/opt/android-sdk/build-tools/23.0.1/dx --dex --no-optimize --output /home/deepak/projects/ionic/pajh_new/platforms/android/build/intermediates/dex/debug --input-list=/home/deepak/projects/ionic/pajh_new/platforms/android/build/intermediates/tmp/dex/debug/inputList.txt
Error Code:
2
Output:

UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Lcom/google/android/gms/ads/identifier/AdvertisingIdClient$Info;
	at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596)
	at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:554)
	at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:535)
	at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)
	at com.android.dx.merge.DexMerger.merge(DexMerger.java:189)
	at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:502)
	at com.android.dx.command.dexer.Main.runMonoDex(Main.java:334)
	at com.android.dx.command.dexer.Main.run(Main.java:277)
	at com.android.dx.command.dexer.Main.main(Main.java:245)
	at com.android.dx.command.Main.main(Main.java:106)

`

I have same problem. Any suggestion?

cordova platform remove android
cordova platform add android

I have same problem. please help us!..