Windows XP Windows 7 Windows 2003 Windows Vista Windows 綜合教學 Linux 系統教學
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟體教學
您现在的位置: Windows教程網 >> Windows教程 >  >> Linux 系統教學 >> 關於 Linux

Ubuntu 14.04 運行 adb 提示「No such file or directory」解決方案

編輯:關於 Linux

在 Ubuntu 14.04 (64位) 上執行 adb 時,常遇到 bash: /path/to/adb: No such file or directory 錯誤。實際上檔案存在,但因 adb 是 32 位執行檔,系統缺少 32 位動態鏈接庫導致無法載入。本文提供標準解決方案。

錯誤現象

$ ./adb devices
bash: ./adb: No such file or directory

$ file ./adb
./adb: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux.so.2, for GNU/Linux 2.6.24, BuildID[sha1]=..., not stripped

file 命令確認是 32 位動態鏈接程式,缺少 32 位庫時內核拒絕載入,報錯誤導性地顯示「No such file or directory」。

解決方案:安裝 32 位基礎庫

# 啟用多架構支援(Ubuntu 13.10+)
sudo dpkg --add-architecture i386
sudo apt update

# 安裝 adb 所需 32 位庫
sudo apt install libc6:i386 libstdc++6:i386 libz1:i386 libncurses5:i386

關鍵庫說明:

  • libc6:i386:C 標準庫,所有 32 位程式基礎。
  • libstdc++6:i386:C++ 標準庫,adb 依賴。
  • libz1:i386:壓縮庫,adb 通訊協議用到。
  • libncurses5:i386:終端庫,部分 adb 版本需要。

驗證修復

$ ./adb version
Android Debug Bridge version 1.0.31
...
$ ./adb devices
List of devices attached
...

進階:使用 64 位 adb 避免多架構麻煩

Android SDK Platform-Tools 23.1.0+ 提供原生 64 位 adb。建議下載最新 Platform-Tools 替換舊版:

wget https://dl.google.com/android/repository/platform-tools-latest-linux.zip
unzip platform-tools-latest-linux.zip
# 將 platform-tools/adb 加入 PATH 或替換舊路徑

常見避坑

操作後果
僅安裝 ia32-libsUbuntu 13.10+ 已移除此元包,無效
安裝 lib32z1 lib32stdc++6舊套件名,新版 Ubuntu 改為 :i386 後綴
修改 ld.so.conf 指向 32 位庫不必要,多架構機制自動處理

適用範圍

本方案同樣適用於 Ubuntu 16.04、18.04、20.04 等 64 位系統上運行任何 32 位 ELF 執行檔(如舊版 Android SDK 工具、專有驅動安裝程式等)。

安裝上述 32 位基礎庫後,adb 即可正常運行,無需降級系統或使用虛擬機。

Copyright © Windows教程網 All Rights Reserved