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.
I might be wrong, but on Windows I simply drag and drop the .apk
into Android Emulator. I mean, doing all mentioned above seems to be a lot of work.
Just drag and drop your apk to emulator
(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
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
go to sdk folder, then go to tools.
copy your apk file inside the tool directory
./emulator -avd myEmulator
to run the emulator on mac
./adb install myApp.apk
to install app on the emulator
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