Linux

[linux] ADB server didn't ACK 해결방법

thxxyj 2022. 10. 11. 08:42
728x90

문제상황 : ADB 동작안함 (adbkey, adbkey.pub 자동 생성안됨)

# adb devices

List of devices attached

* daemon not running; starting now at tcp:5037

ADB server didn't ACK

Full server startup log: /tmp/adb.0.log

Server had pid: 13892

--- adb starting (pid 13892) ---

adb I 05-17 08:55:17 13892 13892 main.cpp:57] Android Debug Bridge version 1.0.39

adb I 05-17 08:55:17 13892 13892 main.cpp:57] Version 1:8.1.0+r23-5ubuntu2

adb I 05-17 08:55:17 13892 13892 main.cpp:57] Installed as /usr/lib/android-sdk/platform-tools/adb

adb I 05-17 08:55:17 13892 13892 main.cpp:57]

adb I 05-17 08:55:17 13892 13892 adb_auth_host.cpp:416] adb_auth_init...

adb I 05-17 08:55:17 13892 13892 adb_auth_host.cpp:262] User key '/root/.android/adbkey' does not exist...

adb I 05-17 08:55:17 13892 13892 adb_auth_host.cpp:109] generate_key(/root/.android/adbkey)...

 

* failed to start daemon

error: cannot connect to daemon

 


해결 방법 .android/adbkey 생성하면 됨

# vi .android/adbkey

//android phones are lockable resources.
//each phone has an associated credential, that is an ADB key that it's accepted already
lock(resource: null, label: 'android-device', variable: 'LOCKED_RESOURCE', quantity: 1) {
    withCredentials([file(credentialsId: "${env.LOCKED_RESOURCE}-adbkey", variable: 'ADBKEY')]) {
        sh '''
            export ADB_VENDOR_KEYS="$ADBKEY"

            # start adb server with group plugdev
            # docker doesn't load groups from /etc/groups when using 'exec -u'
            sg plugdev "adb start-server"

            if ! adb devices -l | grep "device usb" ; then
                # can't talk to device
                if adb devices | grep "unauthorized" ; then
                    echo "phone connected but build slave unauthorized"
                    return 1
                fi
                echo "no phone connected?"
                return 2
            fi

            # We have to uninstall all company packages to prevent
            # "Package signatures do not match the previously installed version"
            adb shell 'pm list packages -f'  | grep $companyName | sed 's/.*base.apk=//' | xargs -I% adb uninstall % || true

            ./gradlew connectedCheck
            '''
        //tests archived below
    }
}

 

참고 : https://technicallycompetent.com/android-adb-keys/

728x90