Create a Mobile Android or IOS app from Scratch

10:00:00 0 Comments




USING CORDOVA OR PhoneGap


(Setup for Eclipse Android Package Environment - if installed please ignore)
Download Package For Android setup Click To Download

Set Java Environment Variables
  1. Start > My Computer (right click)> Properties> Advance System Settings
  2. On System Properties window  Select Advance Tab
  3. Click Environment Variables
  4. In System Variable click New
  5. Variable Name: ANDROID_HOME  
  6. Variable Value: D:\All Proj\Android Activity\adt-bundle-windows-x86-20130917\sdk  (set your path)
  7. In System variable Open path variable and append in variable value  ;%ANDROID_HOME%\tools
  8. In System Variable click New ( Download latest version of  Apache .)
  9. Variable Name: ANT_HOME  
  10. Variable Value: C:\Program Files\ANT\apache-ant-1.9.3  (set your path)
  11. In System variable Open path variable and append in variable value  ;%ANT_HOME%\bin
  12. In System Variable click New ( Download latest version of  java jdk.)
  13. Variable Name: JAVA_HOME
  14. Variable Value: C:\Program Files\Java\jdk1.7.0_45  (set your path)
  15. In System variable Open path variable and append in variable value  ;%JAVA_HOME%\bin




Download and install Node.js.

Install the cordova module using npm utility of Node.js. The cordova module will automatically be downloaded by the npm utility.

(Commands for Installation :-  Start > Run > “cmd” )// to open command prompt
on Mac:
sudo npm install -g cordova

on Windows:
C:\>npm install -g cordova

Create New App ( Move to your folder path in cmd then follow below steps. )
>cordova create hello com.example.hello HelloWorld// Folder bundleID AppName
>cd hello
>cordova platform add ios  //For Mac
>cordova platform add android  //For Windows
>cordova platforms ls//For Mac -Folder view
>cordova build//For  Windows
>cordova build ios //For Mac
>cordova run android //For Windows( Please refer below section -- Get the device recognized by your system)

Plugins- if required
Basic device information (Device API):
cordova plugin add org.apache.cordova.device
Network Connection and Battery Events:
cordova plugin add org.apache.cordova.network-information
cordova plugin add org.apache.cordova.battery-status
Accelerometer, Compass, and Geolocation:
cordova plugin add org.apache.cordova.device-motion
cordova plugin add org.apache.cordova.device-orientation
cordova plugin add org.apache.cordova.geolocation
Camera, Media playback and Capture:
cordova plugin add org.apache.cordova.camera
cordova plugin add org.apache.cordova.media-capture
cordova plugin add org.apache.cordova.media
Access files on device or network (File API):
cordova plugin add org.apache.cordova.file
cordova plugin add org.apache.cordova.file-transfer
Notification via dialog box or vibration:
cordova plugin add org.apache.cordova.dialogs
cordova plugin add org.apache.cordova.vibration
Contacts:
cordova plugin add org.apache.cordova.contacts
Globalization:
cordova plugin add org.apache.cordova.globalization

Splashscreen:
cordova plugin add org.apache.cordova.splashscreen
Open new browser windows (InAppBrowser):
cordova plugin add org.apache.cordova.inappbrowser
Debug console:
cordova plugin add org.apache.cordova.console

To remove plugins
cordova plugin rm Plugin-Name
cordova plugin rm org.apache.cordova.console

Open your project
  1. Start Eclipse select your workspace
  2. Select File>New > New Project window will get open
  3. Select  Android Folder and then select “Android Project from  Existing Code”
  4. From Import Projects Window > Select Your Project (One which you created by cmd)
  5. Click Select All button
  6. Click Finish.
Note: Select your folder and refresh every time you open Eclipse or fires cordova build command




Get the device recognized by your system

This can be tricky, especially under Windows based systems where drivers tend to be a problem. Also, your device may come with additional information or specific drivers from the manufacturer.
For Windows: If the Android device is automatically recognized by the system you still might need to update the drivers with the ones that came with the Android SDK. This is done through the Windows Device Manager. —>If the device is not recognized automatically use the drivers from the Android SDK, or any specific drivers provided by the manufacturer. —>Additional info can be found here: USB Drivers for Windows
For Mac: If you’re developing on Mac OSX then no additional drivers are usually required.
Note: Don’t forget to turn on “USB Debugging” on your device. Go to Settings -> Developer options, then enable USB debugging. As of Android Jelly Bean 4.2 the Developer options are hidden by default. To enable them tap on Settings -> About Phone -> Build Version multiple times. Then you will be able to access the Settings -> Developer options.

How to Export Apk file
  1. Right Click on Folder (ie. Your Project) select Export
  2. From Export Window select Android Folder > Export Android Application click Next
  3. Select Project (by default its selected) click Next
  4. Key Selection >
    1. Create New keystroke (For Fist Time Every Project)
      1. Select Location To save Key File (Note: Save properly to use in next export)
      2. type password and confirm password (remember for the next time)
    2. Use Existing Key Stroke
      1. Select previous selected key
      2. Enter password
  5. Key alias Selection
    1. Create New Key >Next.
    2. Use Existing Key > select previous alias name enter password
  6. Fill the form use same password set validity more than 25 years
  7. Destination/Key Certificate window browse and type your Application name with .apk extention ie abc.apk
  8. Click Finish

0 comments: