refactored the backend of the build apk process