adb got two same serial numbers when connected to two smart phones

后端 未结 7 1289
心在旅途
心在旅途 2020-11-27 16:57

I have two smart phones (ZTEV788d, system Android 2.3.6) connected to a computer (Ubuntu 11.10) at the same time, using co

相关标签:
7条回答
  • 2020-11-27 17:38

    if your device is rooted try this way
    to change serial number your devices , first connect one of them to your pc then type this in cmd

    adb devices
    

    this shows your device id (serial number).

    List of devices attached
    P753A12D    device
    

    pick some new name ,for example NAME1
    then type this commands

    adb shell
    su 
    device_name="NEW_NAME"
    cd /sys/class/android_usb/android0/
    echo -n $device_name > iSerial
    cat iSerial
    

    exit exit from root
    exit exit from shell


    START
    now unplug the usb cable and run this commands

    adb kill-server
    

    connect your device again and type

    adb devices
    

    now you can see changes

    List of devices attached
    New_NAME    device
    

    END

    note : if it did not work first time
    disconnect your phone and do this parts of my guide from START to END again.

    0 讨论(0)
  • 2020-11-27 17:40

    1. Is that normal that two phones to have the same serial number?

    The purpose of the serial number is to uniquely identify the device, so they should be different. That being said, some manufacturers don't bother. It's also possible that the firmware is reporting the number incorrectly.

    https://stackoverflow.com/questions/4636794/strange-output-of-adb-devices?rq=1

    You can check the serial number on the actual devices, and see if it matches what adb is reporting.

    Settings > About Device > Phone Identity > Device Serial Number
    

    2. Can I change the serial number? if yes, how?

    There isn't an easy or consistent method for doing this that I'm aware of. Here are some examples where others have accomplished this feat (but I have not):

    xda-developers.com - Change Wifi , BT , IMEI , Serial Number of any mtk android phone

    hugestreet.info - How To Change IMEI, Device ID of Any Android Device


    3. Is there any way to run these install, push commands successfully even if the serial numbers are the same?

    There shouldn't be any problem running commands if only one device is connected at a time.

    0 讨论(0)
  • 2020-11-27 17:42

    Additionally you can use below commands when to handle multiple instance attached (device + emulator)

    adb -d shell #(or adb -e shell if you're connecting to an emulator).
    

    -d stands for device and -e stands for emulator

    0 讨论(0)
  • 2020-11-27 17:53

    I faced the very same problem. It's because the adb tool uses the serial numbers for identification of devices connected to usb instead of their device paths (which are unique for sure).

    If you feel up to getting your hands dirty, download the Android source tree, go to system/core/adb/transport.c, change it to something like that:

    void register_usb_transport(usb_handle *usb, const char *serial, const char *devpath, unsigned writeable)
    {
        atransport *t = calloc(1, sizeof(atransport));
        D("transport: %p init'ing for usb_handle %p (sn='%s')\n", t, usb,
          serial ? serial : "");
        init_usb_transport(t, usb, (writeable ? CS_OFFLINE : CS_NOPERM));
    //    if(serial) {
    //        t->serial = strdup(serial);
    //    }
        if(devpath) {
            t->devpath = strdup(devpath);
            t->serial = strdup(devpath);
        }
    

    type make adb from the top level path and voila. Devices use usb paths for identification. Now you can install & execute all of the devices from Eclipse with one click.

    0 讨论(0)
  • 2020-11-27 17:54

    The answer given by @mirokropacek works for Linux (and presumably Mac, too) but doesn't work for Windows, unfortunately. This is due to the way the register_usb_transport function is called in Windows. It turns out the devpath parameter is always NULL in Windows. I needed to handle the same situation so I adapted the solution given above to randomly generate a device ID for each device if the serial parameter is NULL or it is empty (zero length).

    I don't need to worry about differentiating devices over long periods of time and many devices so generating a pseudo-random number for the device ID with rand, then using sprintf to create a string representation of that ID seems to be sufficient for my needs but YMMV. It only generates a 4-digit hex number but it works well enough for me (for now at least).

    0 讨论(0)
  • 2020-11-27 17:56

    If you don't want to change the device itself, and/or don't have root access, and the device has network access, you could switch to using TCPIP instead of USB:

    1. Switch adb to using TCPIP: adb tcpip 5555
    2. Have adb connect to the device using the network: adb connect yourhostname

    I've run this through SSH tunnels where it would connect to localhost, so all devices show up as 'localhost' which is quite unuseful. Adding hosts to /etc/hosts (that all pointed to localhost) fixed that for me.

    0 讨论(0)
提交回复
热议问题