Android Lollipop上的IntelliJ SQLite权限被拒绝,之前有过工作

Mla*_*vic 12 sqlite android intellij-idea cordova

我使用Android Lollipop更新了Nexus 7,现在我无法从IntelliJ IDEA 14访问SQLite数据库.在Lollipop更新之前一切正常,即使Android没有root,我可以从IntelliJ访问数据库(但不能通过ADB获取) .我尝试连接时遇到的错误是:

Data Source Synchronization Error
Cannot synchronize 'SQLite': run-as: exec failed for /data/local/tmp/intellij_native_tools/get_modification_time Error:Permission denied
Run Code Online (Sandbox Code Playgroud)

我知道SQLite在棒棒糖中从3.7更新到3.8.什么可能导致这种错误?错误的数据库创建,旧的DB驱动程序,还有什么?

dsk*_*ner 4

adb root不能解决任何问题,取决于环境,有很多问题。以下是我如何在模拟器上运行它,我花了很多开发时间。

only position independent executables (PIE) are supported首先我们需要解决二进制文件的错误。

获取android Ultimate插件工具的源码:

git clone https://android.googlesource.com/platform/tools/adt/idea
cd idea/android/ultimate/get_modification_time/jni
Run Code Online (Sandbox Code Playgroud)

应用以下补丁:

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
Run Code Online (Sandbox Code Playgroud)

您需要安装最新版本的 NDK 才能构建,我已经安装了 ndk-r10d。

# 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
Run Code Online (Sandbox Code Playgroud)

请注意,您需要更新最后一行中的路径以指向本地 IntelliJ 安装。例如,在 MacOS 上,它将是:

zip -u /Applications/IntelliJ\ IDEA\ 14.app/Contents/plugins/android/lib/android-ultimate.jar native_tools/*/get_modification_time
Run Code Online (Sandbox Code Playgroud)

重新启动 IntelliJ。

接下来,我们将/system/bin/run-as在模拟器上进行替换。在本地创建以下脚本并将其命名为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
Run Code Online (Sandbox Code Playgroud)

启动模拟器。启动后,更新它。

# 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
Run Code Online (Sandbox Code Playgroud)

现在您可以随心所欲地同步。

请注意,您可能还想跟踪上游错误的进展情况,该错误在发布此内容后优先级发生了变化: https: //youtrack.jetbrains.com/issue/IDEA-137606