Android 当我尝试使用 adb shell 打开数据库时,为什么在有根的 Nexus One 上出现“sqlite3:未找到”错误?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3645319/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Why do I get a "sqlite3: not found" error on a rooted Nexus One when I try to open a database using the adb shell?
提问by Julian A.
# sqlite3 /data/data/com.moodme.android/databases/moodme
sqlite3 /data/data/com.moodme.android/databases/moodme
sqlite3: not found
采纳答案by CommonsWare
On the Android emulator, sqlite3
is in /system/xbin
. There is no /system/xbin
on a Nexus One (Android 2.2). Hence, I suspect that sqlite3
is not installed on the Nexus One.
在 Android 模拟器上,sqlite3
在/system/xbin
. 有没有/system/xbin
在歌Nexus One(Android 2.2的)。因此,我怀疑sqlite3
Nexus One 上没有安装它。
回答by eveliotc
As an alternative (may not be secure or even good idea though) you can always upload the sqlite3
binary to /system/bin
this worked for me:
作为替代方案(尽管可能不安全甚至不是好主意),您始终可以将sqlite3
二进制文件上传到/system/bin
这对我有用:
First lets mount /system/
to allow read/write (rw)
首先让挂载/system/
以允许读/写(rw)
$ adb shell
$ su
# mount -o remount,rw /system
in another terminal change directory (cd) to where sqlite3
is and lets push it
在另一个终端更改目录 (cd) 到 where sqlite3
is 并让我们推送它
$ ls
sqlite3
$ adb push sqlite3 /sdcard/
Now back to the other shell lets copy and change permissions of the binary
现在回到另一个 shell,让我们复制和更改二进制文件的权限
# cat /sdcard/sqlite3 > /system/bin/sqlite3
# chmod 4755 /system/bin/sqlite3
Now lets mount back /system/
as read only (ro)
现在让我们/system/
以只读方式挂载(ro)
# mount -o remount,ro /system
And now we can use sqlite3 from shell:
现在我们可以从 shell 使用 sqlite3:
# sqlite3 /data/data/com.telly/databases/fun.db
SQLite version 3.7.4
Enter ".help" for instructions
sqlite> .tables
android_metadata lulz
Note: I'm using the sqlite3 binary that comes with "SuperOneClickv1.6.5-ShortFuse"
注意:我使用的是“SuperOneClickv1.6.5-ShortFuse”附带的 sqlite3 二进制文件
You can always pull sqlite3
binary from emulator:
您始终可以sqlite3
从模拟器中提取二进制文件:
Start an emulator and then from a terminal
启动模拟器,然后从终端启动
$ adb pull /system/xbin/sqlite3
If you are lazy like me you can download one right here for ICS or beforeor for Jelly Bean and later here
如果你像我一样懒惰,你可以在这里下载一个 ICS 或之前或Jelly Bean 和以后在这里
Make sure to use the proper one for your Android version as you may get eloc_library[1306]: 14446 cannot locate 'sqlite3_enable_load_extension'...
or similar errors on execute
确保为您的 Android 版本使用正确的版本,因为您可能会eloc_library[1306]: 14446 cannot locate 'sqlite3_enable_load_extension'...
在执行时遇到或类似的错误
回答by jiahao
From the answer of evelio, I had problem to push the sqlite3 file to /system/bin. So, instead, I have pushed it to the /sdcard.
从 evelio 的回答来看,我在将 sqlite3 文件推送到 /system/bin 时遇到了问题。因此,相反,我已将其推送到 /sdcard。
In this thread I found the right Solution (answer of Kila): How can I install sqlite3 on rooted NexusOne runs Gingerbread
在这个线程中,我找到了正确的解决方案(Kila 的回答): 如何在有根的 NexusOne 上安装 sqlite3 运行 Gingerbread
$ adb push sqlite3 /sdcard/
$ adb shell
$ su
# mount -o remount,rw -t yaffs2 /dev/block/mtdblock3 /system
# dd if=/sdcard/sqlite3 of=/system/bin/sqlite3
# chmod 4755 /system/bin/sqlite3
# mount -o remount,ro -t yaffs2 /dev/block/mtdblock3 /system
It works on my Samsung Galaxy S II with 2.3.3.
它适用于我的三星 Galaxy S II 2.3.3。
回答by Jeremy Kao
To install sqlite3 on NON-ROOTED devices, here is a way that has been proved working on my Galaxy S3, FYR.
要在非 ROOTED 设备上安装 sqlite3,这里有一种已被证明适用于我的 Galaxy S3,FYR 的方法。
$ adb -e pull /system/xbin/sqlite3 # get sqlite3 binary from emulator with the same CPU arch.
$ adb -d push sqlite3 /mnt/sdcard # push it
$ adb -d shell
$ run-as <PACKAGE_NAME> # run as your app, which should be debuggable.
$ cd databases; pwd
/data/data/<PACKAGE_NAME>/databases
$ cat /mnt/sdcard/sqlite3 > sqlite3 # copy it to internal storage directory
$ ls -l sqlite3
-rw-rw-rw- u0_a138 u0_a138 36860 2014-03-26 06:37 sqlite3
$ chmod 777 sqlite3 # change mode bits, to be executable
$ ./sqlite3 # now it works on your NON-ROOTED device
SQLite version 3.7.11 2012-03-20 11:35:50
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite>
回答by vinzzz
On the Nexus 4 do the following :
在 Nexus 4 上执行以下操作:
adb shell
$ su
# mount -o remount,rw -t yaffs2 /dev/block/mtdblock3 /system
# dd if=/sdcard/sqlite3 of=/system/xbin/sqlite3
# chmod 777 /system/xbin/sqlite3
# mount -o remount,ro -t yaffs2 /dev/block/mtdblock3 /system
Notice the folder is /system/xbin and the chmod is 777
注意文件夹是/system/xbin,chmod是777
回答by sivi
Some more information that may help someone about this issue
一些可以帮助某人解决此问题的更多信息
For the people who wonder where to get a working sqilte3 file binary to copy:
对于想知道从哪里获得可工作的 sqlte3 文件二进制文件的人:
You can use the emulator to get a working binary. You must before check if your build is based on _86, _64, or ARMand replicate this image or you may get an incompatible version that will cause an err.
您可以使用模拟器来获取工作二进制文件。您必须先检查您的构建是基于_86、_64 还是 ARM并复制此映像,否则您可能会得到不兼容的版本,从而导致错误。
Checking which version is your android device
检查哪个版本是您的 android 设备
https://www.quora.com/How-can-I-check-whether-my-Android-phone-is-32-bit-or-64-bit
https://www.quora.com/How-can-I-check-whether-my-Android-phone-is-32-bit-or-64-bit
Building ARM in android studio
在 android studio 中构建 ARM
Android Studio - How Can I Make an AVD With ARM Instead of HAXM?
Android Studio - 如何使用 ARM 而不是 HAXM 制作 AVD?
Then, use the notes below to move files between your machine and back to the android device.
然后,使用下面的说明在您的机器之间移动文件并返回到 android 设备。
Making adb writable
使 adb 可写
Android Emulator sdcard push error: Read-only file system
Android Emulator sdcard推送错误:只读文件系统
Copying files from adb to local device machine
将文件从 adb 复制到本地设备机器
How to copy selected files from Android with adb pull
如何使用 adb pull 从 Android 复制选定的文件
On a rooted device nexus 4 these links with the instruction on this page worked. Hope it helps someone. The key is you need to mount to get writing permission in the device via adb.
在有根设备的 nexus 4 上,这些链接与此页面上的说明有效。希望它可以帮助某人。关键是你需要挂载才能通过 adb 在设备中获得写入权限。