I finally managed to obfuscate my Android application, now I want to test it by installing the APK file and running it on the emulator.
How can I install an APK file on the Android Emulator?
I finally managed to obfuscate my Android application, now I want to test it by installing the APK file and running it on the emulator.
How can I install an APK file on the Android Emulator?
You can simply drag and drop the .apk file of your application to the emulator and it will automatically start installing.
Another option:
Windows:
adb install [.apk path]
Example:
adb install C:\Users\Name\MyProject\build\Jorgesys.apk
Linux:
platform-tools
in the android-sdk linux
folder../adb install FileName.apk
Mac:
PATH=$PATH:~/Library/Android/sdk/platform-tools
Example : PATH=$PATH:/users/jorgesys/eclipse/android-sdk-mac_64/tools
Then run adb.
Mac:
1.Run the emulator,
2.then copy your .apk file and paste into /Users/your_system_username/Library/Android/sdk/platform-tools
,
if you are not able to find sdk path in your mac system, do the following steps: Open finder->select
Go option on top menu -> select Go to Folder option -> it will popup a window with a textfield: /Users/your_system_username/Library/Android/sdk/
-> now open platform-tools folder and paste your copied .apk file,
Now open the terminal and type the following:
cd Library/Android/sdk/platform-tools
execute the following in your terminal: ./adb install yourapkfilename.apk
if you get the following error message: error: no devices found - waiting for device
, follow step 5.
Run your emulator from Android Studio, once emulator active then repeat step 4, you will see the success message on your terminal.
If you've created more than one emulators or if you have an Android device plugged in, adb will complain with
error: more than one device and emulator
adb help
is not extremely clear on what to do:
-d - directs command to the only connected USB device...
-e - directs command to the only running emulator...
-s <serial number> ...
-p <product name or path> ...
The flag you decide to use has to come before the actual adb command:
adb -e install path/to/app.apk
Copy .apk file in your SDK's platform-tools/ directory,then install the .apk on the emulator by using cmd(on windows):
adb install <path_to_your_bin>.apk
or
./adb install <path_to_your_bin>.apk
If there is more than one emulator running, you can find all running emulators by this command:
adb devices
or
./adb devices
then you must specify the emulator upon which to install the application, by its serial number, with the -s option. For example:
adb -s emulator-5554 install path/to/your/app.apk
or
./adb -s emulator-5554 install path/to/your/app.apk
First you need to install Android Studio on your machine. Then simply follow these steps.
Drag and drop
Simply drag-and-drop the apk file into your emulator.
You can also run your android emulator without Android Studio.
Let's suppose you have to install Facebook APK on your emulator.
You can use adb to install the APK to the running emulator in OS X like this:
./adb install ~/FBAndroid-2.1.apk
And on Windows, like this:
adb install %HOMEPATH%\FBAndroid-2.1.apk
Once complete, check the apps screen of the emulator to check that the app has been installed correctly. If you need to force the upgrade of this app from a previous version, add the -r flag, like this on OS X:
./adb install -r ~/FBAndroid-2.1.apk
keep your emulator up and running. In the command line, go inside the platform-tools folder, in your sdk folder which come with adt bundle and execute following command :
>adb install <yourFilename.apk>
This command detect your running emulator/emulators and show you the list of devices where you can install this app(show if any physical device/devices connected to your computer.). Then you can select any one, if only one emulator is running then app will directly installed on it by default.
Note: For above command your .apk file needs to be in same directory.
for more detailed tutorial follo : This link
(TESTED ON MACOS)
The first step is to run the emulator
emulator -avd < avd_name>
then use adb to install the .apk
adb install < path to .apk file>
If adb throws error like APK already exists or something alike. Run the adb shell while emulator is running
adb shell
cd data/app
adb uninstall < apk file without using .apk>
If adb and emulator are commands not found do following
export PATH=$PATH://android-sdk-macosx/platform-tools://android-sdk-macosx/android-sdk-macosx/tools:
For future use put the above line at the end of .bash_profile
vi ~/.bash_profile
Best way is to create a app, which opens the apk file on the emulator. You have to copy the .apk file to the download folder of your emulator. Then replace yourAppName.apk with your .apk name.
here is the code
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(new File(Environment.getExternalStorageDirectory() + "/download/" + "yourAppName.apk")), "application/vnd.android.package-archive");
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
}
}
(1) You can also use gradle commands to install your APK while choosing the product and flavor (Debug or Release). See this Guide.
./gradlew assembleDebug (Incase you don't have the APK generated)
./gradlew installDebug
Incase you want a fresh install, you can remove any earlier installed builds on the device with below commands
./gradlew uninstallDebug
./gradlew installDebug
(2) You can also use the adb commands directly:
Setup adb for command line
export PATH=/Users/mayurik/Library/Android/sdk/platform-tools/adb:/Users/mayurik/Library/Android/sdk/tool
Command line ADB install
adb -d install pathto/sample.apk (on device)
adb -e install pathto/sample.apk (on emulator)
Also check the documentation here
$ adb devices
List of devices attached
emulator-5554 device
emulator-5555 device
$ adb -s emulator-5555 install helloWorld.apk
On Linux I do this:
emulator -list-avds
cd android && ./gradlew assembleRelease
adb -s '8e138a9c' install app/build/outputs/apk/app-release.apk
Thats it. You can also use ./gradlew installRelease
1) paste the myapp.apk in platform-tools folder , in my case C:\Users\mazbizxam\AppData\Local\Android\android-sdk\platform-tools, this is the link in my case it may change to you people
2)open the directory in CMD CD C:\Users\mazbizxam\AppData\Local\Android\android-sdk\platform-tools
3)Now you are in platform-tools folder , just type adb install myapp.apk
please ensure that your emulator is turn on , if every thing is ok apk will install
Start the console (Windows XP), Run -> type cmd, and move to the platform-tools folder of SDK directory.
In case anyone wondering how to run cmd
in platform-tools
folder of SDK directory, if you are running a new enough version of Windows, follow the steps:
platform-tools
through Windows Explorer.shift
right click and you will find the option "Open Command window here".Hope it helps