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

前端 未结 30 1704
滥情空心
滥情空心 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:11

    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.

    0 讨论(0)
  • 2020-11-22 15:11

    Just drag and drop your apk to emulator

    0 讨论(0)
  • 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
    
    0 讨论(0)
  • 2020-11-22 15:13

    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
    
    0 讨论(0)
  • 2020-11-22 15:13
    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
    
    0 讨论(0)
  • 2020-11-22 15:13

    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
    
    0 讨论(0)
提交回复
热议问题