Difference between revisions of "Mobile Development"

From Sinfronteras
Jump to: navigation, search
(Android platform requirements)
(Android platform requirements)
Line 201: Line 201:
 
* '''Setting environment variables:'''
 
* '''Setting environment variables:'''
 
:* Cordova's CLI tools require some environment variables to be set in order to function correctly. The CLI will attempt to set these variables for you, but in certain cases you may need to set them manually. The following variables should be updated:
 
:* Cordova's CLI tools require some environment variables to be set in order to function correctly. The CLI will attempt to set these variables for you, but in certain cases you may need to set them manually. The following variables should be updated:
 
  
 
::* Set the '''JAVA_HOME''' environment variable to the location of your JDK installation: See [[Java]]
 
::* Set the '''JAVA_HOME''' environment variable to the location of your JDK installation: See [[Java]]
 
  
 
::* Set the '''ANDROID_HOME''' environment variable to the location of your Android SDK installation:
 
::* Set the '''ANDROID_HOME''' environment variable to the location of your Android SDK installation:
Line 215: Line 213:
 
</blockquote>
 
</blockquote>
 
</blockquote>
 
</blockquote>
 
  
 
::* It is also recommended that you add the Android SDK's tools, tools/bin, and platform-tools directories to your PATH.
 
::* It is also recommended that you add the Android SDK's tools, tools/bin, and platform-tools directories to your PATH.

Revision as of 01:10, 13 October 2019

Device Considerations


Platform

Will you be developing for multiple platforms?

  • Android
  • iOS
  • Windows 10 Mobile
  • Blackberry 10
  • Firefox OS
  • Sailfish OS
  • Tizen
  • Ubuntu Touch
  • CynaogenOS



Hardware

  • Depending on the device, the specifications of hardware can be very different
  • Some devices may not have certain components
  • Vintage of components, such as processors and busses will make a difference to the chosen route



Language

  • What programming languages are supported natively by the device?
  • What language suits what you want to do best?
  • Do you need a combination of languages for collaborative tasks?



Form factor

  • Most platforms/OSes run on multiple devices, some more than others
  • Can your application be utilised on all form factors regardless of screen/size?



Native vs Hybrid Frameworks


Native Application Frameworks

Native application frameworks allow developers to access the native platform/OS API directly through code and develop their applications directly to the platform standards and practices


  • Pros:
  • Without other intermediate layers, this provides the best application per device in terms of performance
  • There is no third-party dependence on access to updates and bug fixes


  • Cons:
  • As a native application is written and compiled for a specific platform/OS, deployment on another platform typically requires the maintenance of a totally separate project for each of the supported platforms.
  • How the application is distributed can be different for each platform, requiring the maintenance of a separate distribution channel per platform



Hybrid Frameworks

Web-based frameworks are essentially tools/processes/procedures that allow us to write an application as a website rather than using any native code (e.g. PhoneGap/Cordova)


  • Pros:
  • Anyone with basic web-development skills (HTML, CSS, JS) can write a decent application.
  • There are several frameworks to choose from.
  • It is possible to wrap the content in an application or just access it with the built-in browser.
  • Applications can be accessible across multiple platforms.


  • Cons:
  • Going through so many higher-level languages and interpreters makes run-time much slower than a native application
  • Each platform has a unique style and mode of operation. This gets lost in a web-based application or, at least, requires a lot of work to make it seem intuitive for each platform.



Cordova/PhoneGap

https://cordova.apache.org/

https://phonegap.com

Apache Cordova/PhoneGap enables software programmers to build applications for mobile devices using CSS3, HTML5, and JavaScript instead of relying on platform-specific APIs like those in Android, iOS, or Windows Phone. It enables wrapping up of CSS, HTML, and JavaScript code depending upon the platform of the device. It extends the features of HTML and JavaScript to work with the device. The resulting applications are hybrid, meaning that they are neither truly native mobile application (because all layout rendering is done via Web views instead of the platform's native UI framework) nor purely Web-based (because they are not just Web apps, but are packaged as apps for distribution and have access to native device APIs).


Is PhoneGap equal to Cordova? https://www.businessofapps.com/news/apache-cordova-adobe-phonegap-know-real-differences/

PhoneGap is a distribution of Apache Cordova. So Apache Cordova serves as the engine to power PhoneGap just like WebKit is an engine that powers Chrome and Safari (iOS browser). Nonetheless, as an app developer or as an organization, you don't have to worry about the differences between these two. The story is like this:

  • PhoneGap was previously a product of Adobe.
  • To keep it open-source always and follow standards, PhoneGap codebase was handed over to Apache.
  • At Apache, it got a name change as Cordova.
  • And now it’s better known as Apache Cordova.

The most important to understand here is that PhoneGap is powered by apache Cordova. PhoneGap is Cordova plus some extra Adobe stuff. If you are developing a hybrid mobile app, you can either create it using proper Cordova or choose Adobe's ecosystem for using PhoneGap distribution of Cordova.

The open-source Cordova/PhoneGap will be always free and delivered by Apache. Over time, Adobe may add values to this (current) codebase that consists of other Adobe services and that will be named as PhoneGap, which will be chargeable.



Installing Cordova

https://cordova.apache.org/docs/en/latest/guide/cli/


The Cordova command-line tool is distributed as an npm package.


  • Install Cordova with NPM:
sudo npm install -g cordova

The -g flag above tells npm to install cordova globally. Otherwise it will be installed in the node_modules subdirectory of the current working directory.


  • Check Cordova Version:
cordova --version


If you don't already have one. Following installation, you should be able to invoke git on your command line. The CLI uses it to download assets when they are referenced using a url to a git repo.



Using Cordova

https://cordova.apache.org/docs/en/latest/guide/cli/



Create the App - Project folder

https://cordova.apache.org/docs/en/latest/guide/cli/

Execute the below command to create an «Cordova application environment/Project folder»:

cordova create myapp

or using the entire syntax:

cordova create path [id [name [config]]] [options]
cordova create hello com.example.hello HelloWorld


This creates the required directory structure for your cordova app. By default, the cordova create script generates a skeletal web-based application whose home page is the project's www/index.html file.


Now add the required platform in your application. This will create required files for the corresponding platform under the platforms/android and platforms/ios directories (may be necessary to use sudo):

cd myapp
cordova platform add ios
cordova platform add android


Use below command to list the installed and available platforms for Cordova application:

cordova platform -ls


If you accidentally added any platform which you no longer needs, just remove that using commands like below:

cordova platform remove ios
cordova platform remove android



Install pre-requisites for building

To build and run apps, you need to install SDKs for each platform you wish to target. Alternatively, if you are using browser for development you can use browser platform which does not require any platform SDKs.

To check if you satisfy requirements for building the platform:

cordova requirements


Android platform requirements

https://cordova.apache.org/docs/en/latest/guide/platforms/android/index.html#requirements-and-support

In Ubuntu 18.04:

  • Java Development Kit (JDK): See Java


  • Gradle:
sudo apt install gradle


  • Android SDK:
sudo apt install android-sdk


  • Setting environment variables:
  • Cordova's CLI tools require some environment variables to be set in order to function correctly. The CLI will attempt to set these variables for you, but in certain cases you may need to set them manually. The following variables should be updated:
  • Set the JAVA_HOME environment variable to the location of your JDK installation: See Java
  • Set the ANDROID_HOME environment variable to the location of your Android SDK installation:

On Ubuntu, android-sdk (if installed using apt) is usually at:

/usr/lib/android-sdk
  • It is also recommended that you add the Android SDK's tools, tools/bin, and platform-tools directories to your PATH.



Build the Cordova Application

On all requirements completed successfully run the build command to build your application:

cordova build              ## Build all added platforms 
cordova build android      ## Build for specific platform