Search code examples
androidandroid-studioubuntuxiaomi

Android Studio see device as null


On Ubuntu Android Studio shows devices as null. Every time I turn on my laptop, I need to run the following console commands to add permissions:

./adb devices
./adb kill-server
sudo ./adb devices

Enter my password and then repeat:

./adb kill-server
./adb devices

Note I'm using a xiaomi phone.

Is there a way to get around this permission issues so I don't have to do it ever time.


Solution

  • Anyway, what I did to solve this problem.

    1. Defined in what cases I need to run these commands. For most ubuntu users there is a home folder (hidden file .bashrc).

      In which you can record the launch of these commands. But these commands will be triggered when you enter the bash command in the console.

    2. Since I have a shell .zshrc then I did the following:

      open console: gedit .zshrc

    When the file opens, add the following line:

    ./.add_device_permissions.sh
    

    After or before, we need to create this file: .add_device_permissions.sh in which we write the following:

    #!/bin/bash
    # Add permissions for Xiaomi Redmi Note 5
    ADB="/home/vadimm/Android/Sdk/platform-tools/adb"
    $ADB devices
    $ADB kill-server
    cat .permissions_redmi_note | sudo -S $ADB devices
    $ADB kill-server
    cat .permissions_redmi_note | sudo -S $ADB devices
    

    Also we need create .permissions_redmi_note where we need to hardcode our password.

    1. Not to add to the file .zshrc unnecessary we can specify the path when starting the system itself: Startup Applications Preferences

    Where we press on "Add" and write our command: /home/vadimm/.add_device_permissions.sh