Search code examples
androidmobileadbnixos

How to install .apk file using adb on nixos?


I'm running nixos and I have a .apk file, i.e. an Android app.

There is the handy tool adb (Android Debug Bridge) and the command

adb install /path/to/app.apk

How do I get it to work on nixos?


Solution

  • The binary adb is in androidsdk. So either run

    nix-env -i androidsdk
    

    or add androidsdk to the list environment.systemPackages in /etc/nixos/configuration.nix.

    Your Android phone needs to be plugged in and have USB debugging enabled as documented on developer.android.com.

    Simply running adb install ... didn't work for me. Instead I did

    sudo adb start-server
    adb install /path/to/app.apk
    

    or

    adb install /path/to/app.apk -r
    

    for overwriting an already installed app.