开发者

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?

开发者 https://www.devze.com 2023-01-15 09:12 出处:网络
# sqlite3 /data/data/com.moodme.android开发者_运维技巧/databases/moodme sqlite3 /data/data/com.moodme.android/databases/moodme
# sqlite3 /data/data/com.moodme.android开发者_运维技巧/databases/moodme
sqlite3 /data/data/com.moodme.android/databases/moodme
sqlite3: not found


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:

First lets mount /system/ to allow read/write (rw)

$ adb shell
$ su
# mount -o remount,rw /system

in another terminal change directory (cd) to where sqlite3 is and lets push it

$ ls
sqlite3
$ adb push sqlite3 /sdcard/

Now back to the other shell lets copy and change permissions of the binary

# cat /sdcard/sqlite3 > /system/bin/sqlite3
# chmod 4755 /system/bin/sqlite3

Now lets mount back /system/ as read only (ro)

# mount -o remount,ro /system

And now we can use sqlite3 from shell:

# 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"

You can always pull sqlite3 binary from emulator:

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 before or for Jelly Bean and later here

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


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.


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.

In this thread I found the right Solution (answer of Kila): How can I install sqlite3 on rooted NexusOne runs 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.


To install sqlite3 on NON-ROOTED devices, here is a way that has been proved working on my 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>


On the Nexus 4 do the following :

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


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:

You can use the emulator to get a working binary. You must before check if your build is based on _86, _64, or ARM and replicate this image or you may get an incompatible version that will cause an err.

Checking which version is your android device

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 - How Can I Make an AVD With ARM Instead of HAXM?


Then, use the notes below to move files between your machine and back to the android device.

Making adb writable

Android Emulator sdcard push error: Read-only file system

Copying files from adb to local device machine

How to copy selected files from Android with adb pull

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消