Android: Difference between revisions

Android Studio: Added a note about how to indicate accepting the license, apparently that has to be in the config file.
Almino (talk | contribs)
m Making it easier to list USB devices for beginners.
Line 239: Line 239:


=== Android Debug Bridge ===
=== Android Debug Bridge ===
Run <code>nix-shell -p usbutils --run "lsusb"</code> on your terminal to get the list of USB devices connected to your computer. Sample output ([https://stackoverflow.com/a/58594229/437459 source]):<pre>
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hubBus 001 Device 009: ID 138a:0010 Validity Sensors, Inc. VFS Fingerprint sensor
Bus 001 Device 008: ID 13d3:3491 IMC Networks
</pre>
<code>ID 1d6b:0003</code> can be seen as: <code>idVendor = 1d6b</code> and <code>idProduct = 0003</code>.
<syntaxhighlight lang="nix">
<syntaxhighlight lang="nix">
{
{
   programs.adb.enable = true;
   programs.adb.enable = true;
   services.udev.extraRules = ''
   services.udev.extraRules =
     # replace the "[]" for the idVendor and idProduct variable
     let
     SUBSYSTEM=="usb", ATTR{idVendor}=="[]", MODE="[]", GROUP="adbusers", TAG+="uaccess"
      # nix-shell -p usbutils --run "lsusb"
    SUBSYSTEM=="usb", ATTR{idVendor}=="[]", ATTR{idProduct}=="[]", SYMLINK+="android_adb"
      idVendor = "1d6b"; # Change according to the guide above
    SUBSYSTEM=="usb", ATTR{idVendor}=="[]", ATTR{idProduct}=="[]", SYMLINK+="android_fastboot"
      idProduct = "0003"; # Change according to the guide above
  '';
    in
     ''
      SUBSYSTEM=="usb", ATTR{idVendor}=="${idVendor}", MODE="[]", GROUP="adbusers", TAG+="uaccess"
      SUBSYSTEM=="usb", ATTR{idVendor}=="${idVendor}", ATTR{idProduct}=="${idProduct}", SYMLINK+="android_adb"
      SUBSYSTEM=="usb", ATTR{idVendor}=="${idVendor}", ATTR{idProduct}=="${idProduct}", SYMLINK+="android_fastboot"
    '';


   # add user to adbusers group
   # add user to adbusers group
Line 257: Line 269:
}
}
</syntaxhighlight>
</syntaxhighlight>
# [https://nixos.org/nix-dev/2015-April/016881.html more information on that snippet]
# [https://nixos.org/nix-dev/2015-April/016881.html more information on that snippet]
# [https://gist.github.com/Nadrieril/d006c0d9784ba7eff0b092796d78eb2a A shell.nix to build LineageOS]
# [https://gist.github.com/Nadrieril/d006c0d9784ba7eff0b092796d78eb2a A shell.nix to build LineageOS]