Upgrading Salesforce SDK App to Android Studio
As some of you would have noticed, there is no easy way to integrate the project created/upgraded using "forcedroid" into Android Studio. After some struggle, I followed below steps to acheive this.
1. Make sure you are on the right Cordova version. As of Salesforce Mobile SDK 3.3, Cordova 3.6.4 is supported. If you have Cordova 4, you have target your platform
To check the current version use - cordova platform
3. Also, remove any intermediate builds generated. I cleared the build folder using
rm -r build
4. Now to make sure all the references correctly placed, open the project in Ecclipse and check if the build is working properly.
5. Now open import the project into android studio
Open a New Project in the SDK
1. Make sure you are on the right Cordova version. As of Salesforce Mobile SDK 3.3, Cordova 3.6.4 is supported. If you have Cordova 4, you have target your platform
Cordova platform add android@3.6.4
2. If you have made earlier attempts, please remove all references to gradle and studio project settings.
rm -r .ideafind . -name "*.gradle" -type f -deletefind . -name "*.iml" -type f -delete
3. Also, remove any intermediate builds generated. I cleared the build folder using
rm -r build
4. Now to make sure all the references correctly placed, open the project in Ecclipse and check if the build is working properly.
5. Now open import the project into android studio
Open a New Project in the SDK
Once android platform is added to your project, you can open it from within Android Studio:
- Launch the Android Studio application.
- Select Import Project (Eclipse ADT, Gradle, etc).
- Select location where android platform is stored (your/project/platforms/android).
- For the Gradle Sync question you can simply answer Yes. Optionally, you may select the destination same as your/project/platforms/android
You are all set now and can build and run the app directly from Android Studio.
6. Now, I faced a series of errors. Resolutions are as stated below.
Error: Execution failed for task finished with non-zero exit value 2
Resolution: In the main project build.gradle include
defaultConfig {
multiDexEnabled true
}
multiDexEnabled true
}
Error: package com.google.android.gcm does not exist
Resolution: Include gcm.jar in main project
Error: duplicate entry android studio package debug classes for multidex
Resolution:
Error : Duplicated file copies in APK
Resolution: In the main project build.gradle include
References:
ReplyDeleteMy cousin recommended this blog and she was totally right keep up the fantastic work!
Google App Integration Madurai