^_^

2013年11月28日星期四

如何在 Mac 系统为 Nexus 4 升级 Android 4.4 Kitkat 并 Root

虽然我的 Nexus 4 早早收到 Android 4.4 Kitkat OTA 升级,但是升级过程并非一帆风顺,原因是我上次 Nexus 4 Unlock & Root 的时候,似乎破坏了系统应用的完整性,即便我 Unroot 了,还是出现机器人倒地加感叹号的错误。

既然 OTA 升级不行,只好换个方法直接刷官方原厂 Kitkat 镜像包,整个过程是在 MacBook Pro 上完成的,而 adb 环境早已搭建好。如下所示,adb 工具位于“/Users/foolbear/Documents/Android/adt-bundle-mac-x86_64-20130917/sdk/platform-tools”,即 ANDROID_TOOLS_PATH。
FoolMBP:platform-tools foolbear$ cd
FoolMBP:~ foolbear$ less .bash_profile
export ANDROID_SDK_ROOT=/Users/foolbear/Documents/Android/adt-bundle-mac-x86_64-20130917/sdk/
export ANDROID_NDK_ROOT=/Users/foolbear/Documents/Android/android-ndk-r9
export ANDROID_TOOLS_PATH=/Users/foolbear/Documents/Android/adt-bundle-mac-x86_64-20130917/sdk/platform-tools
export NDK_ROOT=/Users/foolbear/Documents/Android/android-ndk-r9
export TRANSPORTER_HOME=/Applications/Xcode.app/Contents/Applications/Application\ Loader.app/Contents/MacOS/itms/bin
export PATH=$PATH:$ANDROID_SDK_ROOT
export PATH=$PATH:$ANDROID_NDK_ROOT
export PATH=$PATH:$TRANSPORTER_HOME
export PATH=$PATH:$ANDROID_TOOLS_PATH
.bash_profile (END)
下载官方原厂 Kitkat 镜像包,“Factory Images "occam" for Nexus 4 - 4.4 (KRT16S)”就是我们需要的。解压到 ANDROID_TOOLS_PATH 中,如下:
FoolMBP:platform-tools foolbear$ ls -ls
total 942488
448 -rw-rw---- 1 foolbear staff 226063 7 25 16:50 NOTICE.txt
2488 -rwxrwxr-x 1 foolbear staff 1270784 7 25 16:48 adb
0 drwxrwx--- 3 foolbear staff 102 7 25 16:49 api
4408 -rw-r-----@ 1 foolbear staff 2256360 11 20 00:41 bootloader-mako-makoz20i.img
408 -rwxrwxr-x 1 foolbear staff 208704 7 25 16:48 fastboot
8 -rw-r-----@ 1 foolbear staff 968 11 20 00:41 flash-all.bat
8 -rwxr-x--x@ 1 foolbear staff 836 11 28 16:01 flash-all.sh
8 -rwxr-x--x@ 1 foolbear staff 797 11 20 00:41 flash-base.sh
843624 -rw-r-----@ 1 foolbear staff 431934072 11 20 00:41 image-occam-krt16s.zip
91080 -rw-r-----@ 1 foolbear staff 46630400 11 20 00:41 radio-mako-m9615a-cefwmazm-2.0.1700.84.img
8 -rw-rw-r-- 1 foolbear staff 39 7 25 16:48 source.properties
0 drwxrwx--- 12 foolbear staff 408 7 25 16:48 sys trace
其中 flash-all.sh 需要修改一下,将其中“fastboot -w update image-occam-krt16s.zip”改成“fastboot update image-occam-krt16s.zip”:
FoolMBP:platform-tools foolbear$ less flash-all.sh
#!/bin/sh

# Copyright 2012 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

fastboot flash bootloader bootloader-mako-makoz20i.img
fastboot reboot-bootloader
sleep 5
fastboot flash radio radio-mako-m9615a-cefwmazm-2.0.1700.84.img
fastboot reboot-bootloader
sleep 5
fastboot update image-occam-krt16s.zip
~
(END)
准备好工具,我们就开工吧。连接 Nexus 4 和 MacBook Pro,并在手机上开启 USB 调试。然后执行下面命令进入 bootloader 模式:
FoolMBP:platform-tools foolbear$ adb reboot bootloader
手机进入 bootloader 模式后,再执行:
FoolMBP:platform-tools foolbear$ ./flash-all.sh
sending 'bootloader' (2203 KB)...
OKAY [ 0.077s]
writing 'bootloader'...
OKAY [ 0.334s]
finished. total time: 0.411s
rebooting into bootloader...
OKAY [ 0.002s]
finished. total time: 0.002s
sending 'radio' (45537 KB)...
OKAY [ 1.526s]
writing 'radio'...
OKAY [ 2.926s]
finished. total time: 4.453s
rebooting into bootloader...
OKAY [ 0.001s]
finished. total time: 0.001s
archive does not contain 'boot.sig'
archive does not contain 'recovery.sig'
archive does not contain 'system.sig'
--------------------------------------------
Bootloader Version...: MAKOZ30d
Baseband Version.....: M9615A-CEFWMAZM-2.0.1700.97
Serial Number........: 04cf05161a484cd8
--------------------------------------------
checking product...
OKAY [ 0.002s]
checking version-bootloader...
OKAY [ 0.002s]
checking version-baseband...
OKAY [ 0.002s]
sending 'boot' (6360 KB)...
OKAY [ 0.218s]
writing 'boot'...
OKAY [ 0.435s]
sending 'recovery' (6908 KB)...
OKAY [ 0.249s]
writing 'recovery'...
OKAY [ 0.609s]
erasing 'system'...
OKAY [ 1.263s]
sending 'system' (700496 KB)...
OKAY [ 23.254s]
writing 'system'...
OKAY [ 53.708s]
rebooting...

finished. total time: 79.753s
过程整个还是相当快的,Nexus 就已经升级到 Android 4.4 Kitkat 了 。下面我们就要开始 Root 这台 Nexus 4。上次我们用的 Nexus Root Toolkit 是个很棒的工具,目前也已经支持 Kitkat 了,但是它只能在 Windows PC 上运行,在 Mac OS 上我们只能另辟蹊径了。这里要介绍大神 chainfire(SuperSU 的作者) 的 CF-Auto-Root 工具包,这个工具您不需要刷第三方 recovery 就可以 root 了,并且工具非常干净,是真正的一键 root。如果您之前没有解锁的话,这个工具会解锁手机,但是这样数据会被清空,建议您备份数据,好在我已经 Unlock 过了

首先,我们到 CF-Auto-Root 官方网站找到“LGE - Nexus 4 - occam”并下载工具包并解压缩。
FoolMBP:CF-Auto-Root-mako-occam-nexus4 foolbear$ ls -ls
total 24
0 drwxr-xr-x@ 3 foolbear staff 102 11 28 17:24 image
8 -rw-r--r--@ 1 foolbear staff 936 11 20 19:55 root-linux.sh
8 -rwxrwxrwx@ 1 foolbear staff 930 11 20 19:55 root-mac.sh
8 -rw-r--r--@ 1 foolbear staff 829 11 20 19:55 root-windows.bat
0 drwxr-xr-x@ 7 foolbear staff 238 11 28 17:24 tools
这个工具包自带了 Tools,不必用 ANDROID_TOOLS_PATH 中的了。同上面一样,连接 Nexus 4 和 MacBook Pro,并在手机上开启 USB 调试。先进入 bootloader 模式,再 Root:
FoolMBP:CF-Auto-Root-mako-occam-nexus4 foolbear$ adb reboot bootloader
FoolMBP:CF-Auto-Root-mako-occam-nexus4 foolbear$ ./root-mac.sh

----- CF-Auto-Root-mako-occam-nexus4 -----

Please make sure your device is in bootloader/fastboot mode before continuing.

***WARNING*** ALL YOUR DATA *MAY* BE WIPED ! ***WARNING***

We are going to run the OEM UNLOCK command on your device. If your device
was not previously unlocked, this will wipe all your data !

After the unlock, CF-Auto-Root will boot. You should see a big red Android
on your device's screen.

You may need to enter your administrator password to continue.

Press Ctrl+C to cancel !

Press ENTER to continue

Password:
... FAILED (remote: Already Unlocked)
downloading 'boot.img'... OKAY
booting... OKAY

It may take a minute or so for the red Android to appear. If it doesn't show up
at all, there may be a problem.

Press ENTER to continue
至此,Root 已完成。我们再通过官方电子市场,安装 SuperSU。但是我实际安装后,发现 SuperSU 总是报错,运行停止。解决方法是,进入了设置-应用,找到 SuperSU,选择卸载更新,再重新更新即可。
本站文章除注明外,均为本站原创
转载请注明文章转载自: 大笨熊乐园 [ https://blog.foolbear.com/ ]
文章标题: 如何在 Mac 系统为 Nexus 4 升级 Android 4.4 Kitkat 并 Root
文章地址: https://blog.foolbear.com/2013/11/mac-nexus-4-android-44-kitkat-root.html

没有评论 :

发表评论

Related Posts with Thumbnails