Fix lỗi liên quan đến ADB

Mới gần đây khi mày mò thêm về React Native thì mình gặp phải một số lỗi liên quan đến ADB cụ thể như sau:

Khi mình test thử app thì không thể hoạt động được, gặp đủ lỗi linh tính, vì nhiều quá nên mình không kể ra đây được. Khi mình dùng adb devices để xem danh sách thiết bị thì gặp ra thông báo như bên dưới. Search google mãi mới có cách fix nhưng mà cũng chật vật lắm trong khi lỗi rõ ràng kia rồi nên mình đăng cái này mục đích chính là giúp mình nhớ lại thôi, có khi bạn nào vô tình gặp lỗi này mình cũng giúp fix một tay chứ sau này chết ốm mình không tìm lại được mất.

adb server version (39) doesn’t match this client (36); killing…
error: could not install *smartsocket* listener: Address already in use
ADB server didn’t ACK
* failed to start daemon *

và lỗi này

adb server is out of date. killing…
cannot bind ‘tcp:5037’
ADB server didn’t ACK
* failed to start daemon *

Cách fix như sau: Bạn bật command lên và chạy lần lượt nhé, nếu cái nào không được thì thêm sudo đằng trước để chạy với quyền super user

cp ~/Android/Sdk/platform-tools/adb /usr/bin/adb
chmod +x /usr/bin/adb
nano /etc/environment
source ~/.bashrc

Cá nhân mình vẫn chưa thực sự hiểu nguyên nhân lắm nhưng vẫn copy ra đây cho các bạn đọc. Bạn nào muốn đọc chi tiết hơn có thể xem tại đây còn cách fix thì ở link này

If you have adb installed as part of your Linux distribution, then your PATH probably points there. Chances are this adb is version 1.0.31 (or earlier).

Genymotion comes with its own adb in the tools/ directory, which is version 1.0.32 if you are running the latest Genymotion, currently 2.3.1. Unless you changed it in the settings, Genymotion will start the bridge with that copy.

Since adb operates in a client-server arrangement, the client version should match the daemon version. In your case, they don’t and that’s why you’re getting the adb server is out of date. killing… message. If the daemon is killed or dies, the Genymotion launcher automatically and immediately restarts adb (using its own copy), and that’s why your client can’t start a new daemon bound to port 5037.

The solution is to make sure that the version of adb you are invoking on the command line matches the one that Genymotion is bringing up as a daemon when it starts the VMs. The easiest way to ensure this is just to use the adb binary in Genymotion’s tools/ directory.

Note that if you have changed Genymotion’s default of using its own tools to use custom SDK tools, then you’ll need to use an adb client that matches the version contained in the SDK you’re pointing to. As far as I can tell, KitKat (4.4.4) and earlier SDKs contain adb version 1.0.31, while the Lollipop (5.0) SDKs have 1.0.32.

Trả lời

Email của bạn sẽ không được hiển thị công khai. Các trường bắt buộc được đánh dấu *