Sunday, November 15, 2015

how to Install apk file from pc to the Android device or emulator

Step to install apk file from pc to android devices or emulator

Windows:

  1. First you must connect you devices or start your emulator (which I will not gonna talk about it.)
  2. Then open command prompt and type adb install [apk path]  
    • (ps:replace the [apk path with the path to the apk file  you want to install into the device / emulator) 
    • == don't tell me adb command not exist.
    • which you not yet put the android-sdk\tools or platform-tools folder into the environmental path. Then you have to go to the tools folder and type the command again.
  3.  Ok installed. end of story. Thx


Linux:

  1. Copy the apk file to platform-tools in android-sdk linux folder.
  2. Open Terminal and navigate to platform-tools folder in android-sdk.
  3. Then Execute this command -
  4. ./adb install FileName.apk
  5. If the operation is successful (the result is displayed on the screen), then you will find your file in the launcher of your emulator.

Mac:

  1. PATH=$PATH:~/Library/Android/sdk/platform-tools
  2. Example : PATH=$PATH:/users/jorgesys/eclipse/android-sdk-mac_64/tools
  3. Then run adb.


If any problems can leave a comment belows. I will Try to solve it ...but not mac user. Thank you. =D


Use variable inside gradie on android code

How to differentiate debug mode and release mode in android studio?

Hi, Recently I was find a solution to let the Android Studio able to determine whether the application is debug mode or release mode. So that I can easily switch the code inside the android so that the URL and link would be modified according to the debug/release mode.

In the end , I found the solution and the method to add the variable/constant inside the gradle file so that the android code able to call it .
First of all, there are 1 variable inside the gradle call BuildConfig.DEBUG  which is use to as the variable or toggle flag between the release mode and the debug mode.

If is the variable return true mean debug mode while false is release mode.

=| ok sorry for talk nothing on the variable that can be use on the android code which setting in gradle , we still haven't talk much about the variable which I will talk about it below.


Variable in gradle that can use on android java code


To use the variable or constant inside the gradle , first you have declare the value on the gradle file.
You could use the static member like BuildConfig to get the variable you want inside the gradle file.

Below is the example of put the value of you want inside the gradle file.

 android {
    buildTypes {
        debug {
            buildConfigField "String", "BASE_URL", "http://debug.server.com"
        }

        release {
            buildConfigField "String", "BASE_URL", "http://release.server.com"
        }
    }
}


if is want to using the string variable for debug, could call using BuildConfig.debug , and vice versa if want to call release.

Nothing much to say now, if got any others question or better method , you could just give the comment thank you for reading. Have a nice days.