How do you install an APK file in the Android emulator?

前端 未结 30 2183
滥情空心
滥情空心 2020-11-22 14:53

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.

30条回答
  •  再見小時候
    2020-11-22 15:12

    (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
    

提交回复
热议问题