How to generate APK and IPA files to test the ionic app?

I want to know how to generate the APK and IPA files to test the app in mobiles devices ? I had tried to do with Build.phonegap but it is generate APK files with error alert as “Error initialising Cordova : Class not found” ?