Android 解决手机unauthorized错误

转自:http://blog.csdn.net/quicksand201/article/details/19190821



手机开发者选项中USB调试已经打开,在电脑命令行下输入adb devices,显示手机未认证

D:\develop\androidroot\adt-bundle-windows-x86-20131030\sdk\platform-tools>adb devices
* daemon not running. starting it now on port 5037 *
* daemon started successfully *
List of devices attached
42f7f2230e4cafe7        unauthorized

网上搜了一圈,几经折腾,什么adb kill-server/start-server、重新开关USB调试、撤回USB除错授权,甚至坑爹的重刷手机系统都试过,也没有搞定。

没办法,折腾adb源代码去,看这里

https://android.googlesource.com/platform/system/core/+/d5fcafaf41f8ec90986c813f75ec78402096af2d

源码没看到,先看到一大段英文,英文水平一般,直接搬原文:

adb: Add public key authentification

Secure adb using a public key authentication, to allow USB debugging
only from authorized hosts.

When a device is connected to an unauthorized host, the adb daemon sends
the user public key to the device. A popup is shown to ask the user to
allow debugging once or permanantly from the host. The public key is
installed on the device in the later case. Other keys may be installed
at build time.

On the host, the user public/private key pair is automatically generated,
if it does not exist, when the adb daemon starts and is stored in
$HOME/.android/adb_key(.pub) or in $ANDROID_SDK_HOME on windows. If needed,
the ADB_KEYS_PATH env variable may be set to a :-separated (; under
Windows) list of private keys, e.g. company-wide or vendor keys.

On the device, vendors public keys are installed at build time in
/adb_keys. User-installed keys are stored in /data/misc/adb/adb_keys.

ADB Protocol change:
If the device needs to authenticate the host, it replies to CNXN
packets with an AUTH packet. The AUTH packet payload is a random token.
The host signs the token with one of its private keys and sends an AUTH(0)
packet. If the signature verification succeeds, the device replies with
a CNXN packet. Otherwise, it sends a new AUTH packet with a new token so
that the host can retry with another private key. Once the host has tried
all its keys, it can send an AUTH(1) packet with a public key as
payload. adbd then sends the public key to the framework (if it has been
started) for confirmation.

在电脑的win7系统上查看ANDROID_SDK_HOME,命令行 echo %ANDRIOD_SDK_HOME%

天啊,指向一个不存在的目录,哪个流氓软件干的

将电脑环境变量中的ANDRIOD_SDK_HOME删除,重新运行adb devices,手机上出现授权提示,问题解决。

D:\develop\androidroot\adt-bundle-windows-x86-20131030\sdk\platform-tools>adb devices
List of devices attached
42f7f2230e4cafe7        device



Android 解决手机unauthorized错误

时间: 2024-08-06 14:33:43

Android 解决手机unauthorized错误的相关文章

android 开发中遇到错误及解决办法总结

新手总结的开发中所遇到错误及解决办法,如有不对,欢迎指正,如有更好的解决办法,也请不吝赐教. 一.dialog.show()引起的android.view.WindowManager$BadTokenException错误 错误日志 android.view.WindowManager$BadTokenException: Unable to add window -- token [email protected] is not valid; is your activity running?

android studio 更新 Gradle错误解决方法(Gradle sync failed)

android studio 更新 Gradle错误解决方法 Android Studio每次更新版本都会更新Gradle这个插件,但由于长城的问题每次更新都是失败,又是停止在Refreshing Gradle Project ,有时新建项目的时候报 Gradle Project Compile Error 等等相关的问题 解决这些问题办法是 首先打开android studio项目 找到项目目录gradle\wrapper\gradle-wrapper.properties这个文件 内容如下

eclipse导入android项目后出现错误的解决方法

eclipse导入android项目后出现错误的解决方法 出现这样的错误是因为没有为项目指定sdk的原因 为项目指定sdk的方法右键点击工程名称,弹出菜单中点击“Properties->Android”,在Project build target 中指定你要使用的SDK版本即可

Android不同手机屏幕分辨率自适应【转】

有必要了解的 Android中常见的单位 dip, dp, px, sp之间的区别: dip: device independent pixels(设备独立像素). 不同设备有不同的显示效果,这个和设备硬件有关,一般我们为了支持WVGA.HVGA和QVGA 推荐使用这个,不依赖像素.px: pixels(像素). 不同设备显示效果相同,一般我们HVGA代表320x480像素,这个用的比较多.pt: point,是一个标准的长度单位,1pt=1/72英寸,用于印刷业,非常简单易用:sp: scal

Android 解决图片大量下载:软引用必须懂4点

Android 解决图片大量下载:软引用必须懂4点 可能对于Android开发者来说,软引用这个词有的会不是很熟悉,软引用在Java开发中用的比较多,但是,在Android开发中引用软引用,会给我们解决很多难题. AD: 1.对象的强.软.弱和虚引用 为了能更加灵活控制对象的生命周期,需要知道对象引用的4中级别,由高到低依次为 :强引用.软引用.弱引用和虚引用 备注: 这四种的区别: ⑴强引用(StrongReference) 强引用是使用最普遍的引用.如果一个对象具有强引用,那垃圾回收器绝不会

Android 多个DEX错误 Multiple dex files define Landroid/support/v7/app/ActionBar$DisplayOptions;

今天在写程序的时候我的Android Studio 突然编译错误(错误提示如下:)后来经过我的几番折腾发现每一次都要先Clear Project一下然后再Build就可以了,如果你第二次再Build的时候就报错.后来我就找到了最强的老师(Google)尝试解决!可惜很遗憾,我在Google上看到的都是Eclipse上的解决方法.并没有找到我想要的答案,难道要我每一次在Build的时候都要先Clear Project吗?最后又经过我的几番折腾我发现在Project Structure--->app

Android NDK开发常见错误

错误一: make: *** No rule to make target `/cygdrive/d/1-workspace/showmap-android-opengles/jni/showmap_opengles_OpenGLESRenderer.c', needed by `/cygdrive/d/1-workspace/showmap-android-opengles/obj/local/armeabi/objs/OpenGLESMap/showmap_opengles_OpenGLES

使用ListView 时,遇到了 Your content must have a ListView whose id attribute is 'android.R.id.list' 错误

今天在开发Android小应用的时候,使用到了ListView,在使用自己创建的listview风格的时候,就出现了如标题的错误提示信息,这个就让我纳闷了,以前也不会出现这个问题啊,而且也可以运行,赶紧查资料找原因,原来是我的主Activity继承了ListActivity,而ListActivity中必须有一个ListView,因为ListActivity启动时会默认去寻找这个ListView的id,如果没有找到,就会报错. 解决的方法很简单,就是在主Activity布局文件中加个ListVi

android开发常见编程错误总结

1.设置TextView的文本颜色 1 2 3 TextView tv; ... tv.setTextColor(R.color.white); 其实这样设置的颜色是 R.color.white的资源ID值所代表的颜色值,而不是资源color下的white颜色值:正确的做法如下: 1 tv.setTextColor(getResources().getColor(R.color.white)); 这个出错的概率满高的,就是因为二者都是int类,导致编译器不报错. 2.读取Cursor中的值 1