I updated Nexus 7 with Android Lollipop and now i can't access SQLite db from IntelliJ IDEA 14. Everything was working fine before Lollipop update, even though Android wasn't rooted i could access db from IntelliJ (but not pull it via ADB). The error i am getting when i try to connect is:
Data Source Synchronization Error
Cannot synchronize 'SQLite': run-as: exec failed for /data/local/tmp/intellij_native_tools/get_modification_time Error:Permission denied
I am aware that SQLite was updated in lollipop from 3.7 to 3.8. What could cause this kind of error? Wrong DB creation, old DB drivers, something else?
adb root
doesn't resolve anything, there's numerous issues depending on environment. Here's how I got it working on emulator where I spend a lot of my development time.
First we need to resolve the error only position independent executables (PIE) are supported
with the binary.
get the source of android ultimate plugin tool:
git clone https://android.googlesource.com/platform/tools/adt/idea
cd idea/android/ultimate/get_modification_time/jni
Apply the following patch:
diff --git a/android/ultimate/get_modification_time/jni/Application.mk b/android/ultimate/get_modification_time/jni/Application.mk
index a252a72..bdf815d 100644
--- a/android/ultimate/get_modification_time/jni/Application.mk
+++ b/android/ultimate/get_modification_time/jni/Application.mk
@@ -1 +1,2 @@
APP_ABI := all
+APP_PLATFORM := android-16
You'll need to setup a recent version of NDK to build, I had ndk-r10d installed already.
# ndk-r10d
ndk-build
cd ..
cp -R libs native_tools
# update the intellij plugin with whatever arch you plan to use
# adjust the path here to where your copy of IntelliJ is located
zip -u ~/local/apps/idea/plugins/android/lib/android-ultimate.jar native_tools/*/get_modification_time
Note that you need to update the path in that last line to point to your local IntelliJ installation. For example, on MacOS, it'll be:
zip -u /Applications/IntelliJ\ IDEA\ 14.app/Contents/plugins/android/lib/android-ultimate.jar native_tools/*/get_modification_time
Restart IntelliJ.
Next, we'll be replacing /system/bin/run-as
on the emulator. Create the following script locally and name it run-as
.
#! /system/bin/sh
INTELLIJ_NATIVE="/data/local/tmp/intellij_native_tools/get_modification_time"
if [ "$2" = "$INTELLIJ_NATIVE" ]; then
cd /data/local/tmp/intellij_native_tools
./get_modification_time "$3"
else
/system/bin/run-as.org "$@"
fi
Start the emulator. After it has booted, update it.
# update run-as after start
adb shell mount -o remount,rw /system
adb shell mv /system/bin/run-as /system/bin/run-as.org
adb push ./run-as /system/bin/run-as
Now you can synchronize to your heart's content.
Note, you may also want to follow progress on the bug upstream which just had priority bumped after posting this: https://youtrack.jetbrains.com/issue/IDEA-137606
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With