Using Genymotion in Android

Let’s get familiar with Genymotion.

Genymotion is the most powerful Android emulator for app developers & testers.

Developers can install the plugin of Genymotion in Android Studio plugin with few simple steps:

  1. Click File–> Settings
  2. Click on Plugins tabs left side on Settings window.
    settings
  3. Click Browse Repositories and search for Genymotion.
    genymotion_plugin
    On the right side of Browse Repositories pop up, there will be a button with name “Install”.
  4. Click on install button.
  5. Restart your Android Studio IDE. Now you can see, Genymotion is installed in Android studio.


How to use the Genymotion for the app?

  • After installation of Genymotion plugin, there will be a phone like an icon on the toolbar of Android Studio.
  • After clicking that icon Genymotion Device Manager will open, where you can see the list of available Genymotion virtual devices.
  • Select one of them or you can create the virtual device by clicking on New button.
  • Creating new virtual device will show a popup shown below,virtual_device_creation_wizard
    Where you have options to choose Android versions and Device model after that click on Next button.

    • You can choose the name for the virtual device shown as below,virtual_device_name
    • Click Next and download and install will start for the virtual device.That’s all. Now you can click on start button to start Genymotion virtual device.Now you can run your App on this device. Just hit Run button on your Android Studio’s toolbar, choose your virtual device from Available Virtual Devices and it will run your project on it.
    • To avoid the issues in your android app you can follow Do’s and Don’ts for Android this blog.

Do’s and Don’ts for Android Apps

There are few things most of the new android developers face. To avoid these issues while developing one should be following best practices to improve the functionality of the android app and to attain optimum results.

Do’s  for Android App Development

  • Prefer ConstraintLayout while making designs in xml file of android. It is more flexible. If necessary, look for others.
  • Give meaningful id name for each view in xml. For example, If you are using EditText for username and password then their names should be editTextUsername and editTextPassword.
  • If any group of views is repeatable in more than one xml file, make a different file with that group of views and include it where you want. Eg. <include layout=“@layout/toolbar”/> : toolbar is a different layout which has the design for common toolbar used in the app.
  • Write all the texts, used in the app, in string.xml file and give reference of that string in layout xml file. Also, all the messages should be defined in string.xml file. Later on, it will be easier to modify it.
  • Write all the dimensions, used in the app, in dimen.xml file and give reference of that dimensions in layout xml file.
  • Write all the colors, used in the app, in color.xml file and give reference of that color in layout xml file.
  • Try using style.xml file for custom view design instead of doing it programmatically.
  • All constants should be declared in separate java file say, Constants.java, Each constant should be static(it will allocate memory only one time and can be reusable) and final(not changeable).
  • Define all commonly used methods in one class say, Utils.java.
  • If code lines are exceeding 15-20 lines, put the code in a method.
  • The naming of variables, objects, methods, classes, interfaces, etc should be self-explanatory.
  • It’s better to write a separate class for any reusable functionality.
  • Project code should be divided into different modules. According to the module, you can put the java files in different packages under the main package.
  • The module can be Login, DrawerItems (if an app has the drawer, list out all the main files of drawer items), etc.. and it will depend on the project’s features.
  • Use fragment, if you want to show more than one screen in single Activity. A fragment is nothing but the part, part of design. It is totally dependent on Activity.
  • Interfaces can be used to pass the data of one class to other class(it can be Activity, Fragment, Service, or simple Java class) on any triggered event.
  • Service: It is used as a background task. Eg. To do network call, to play music in the background, etc.
  • Use Glide/Picasso library to load image URLs.
  • Use Retrofit library to make network calls. See this blog how to use it in android.
  • Use GreenDAO library to do local database transactions.
  • Use Genymotion virtual device to run the android app.
  • You can use Testfairy to distribute your android app remotely.

 

Similarly, you should know what are bad practices in android development, what to avoid while developing an android app. Below are some points developers should avoid.

Don’ts for Android App Development

  • Try to avoid using Relative layout, if it is not necessary.
  • Avoid using nested Linear layout it affects the UI performance.
  • Never use ‘my’ prefix in naming conventions. Also never use shortcut names. Eg tvNm, etPwd, etc.
  • Your code length for a class should not exceed 1000 lines. If possible try to add a supporting class.
  • Avoid using hard-coded values in Activity/Fragment as much as possible.
  • Avoid using libraries as a project module, instead, add dependencies in build.gradle file of app Module of the project.
  • Don’t use too many libraries.