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 
Cordova platform add android@3.6.4
To check the current version use - cordova platform 

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:
  1. Launch the Android Studio application.
  2. Select Import Project (Eclipse ADT, Gradle, etc).
  1. Select location where android platform is stored (your/project/platforms/android).
  1. 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
}

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
ResolutionIn the main project build.gradle include



References:

Comments


  1. My cousin recommended this blog and she was totally right keep up the fantastic work!

    Google App Integration Madurai

    ReplyDelete

Post a Comment

Feedback - positive or negative is welcome.

Popular posts from this blog

How to prepare your LOB app for Intune?

Information Architecture - Setup your term store to scale

Generate token signing .CER from ADFS Federation Metadata XML