如何离线安装SL4A解释器

发布于 2024-12-26 12:51:46 字数 148 浏览 2 评论 0原文

在我目前的工作中,我对 perl/python/lua 上的 android 脚本非常感兴趣,但我的流量消耗也非常有限,并且在重新刷新 android 设备后我可能需要经常重复解释器安装过程。那么有没有办法在没有互联网连接的情况下使用准备好的文件/档案在 SL4A 中安装解释器呢?

I'm really interested in android scripting on perl/python/lua at my current job, but I'm also very limited in traffic consumption and I may need frequently repeat interpreters install procedure after reflashing android devices. So is there any way to install interpreters in SL4A using prepared files/archives without internet connection?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

魔法唧唧 2025-01-02 12:51:46

为了安装 Py4a,我最终修改了 android/PythonForAndroid/src/com/googlecode/pythonforandroid/PythonDescriptor.java,将其中的 BASE_URL 更改为 file:// / 网址。然后,我能够将 adb push python_*.zip 文件放入该目录,并从那里安装。

关键是要注意 logcat 错误消息。由于我没有版本文件,代码始终要求 _r1.zip

应用以下补丁,然后按照 Py4A 的 README 文件中的说明构建 APK。

diff --git a/android/PythonForAndroid/src/com/googlecode/pythonforandroid/PythonDescriptor.java b/android/PythonForAndroid/src/com/googlecode/pythonforandroid/PythonDescriptor.java
index a891e98..89bb4f7 100644
--- a/android/PythonForAndroid/src/com/googlecode/pythonforandroid/PythonDescriptor.java
+++ b/android/PythonForAndroid/src/com/googlecode/pythonforandroid/PythonDescriptor.java
@@ -39,7 +39,7 @@ public class PythonDescriptor extends Sl4aHostedInterpreter {
   public static final String ENV_EXTRAS = "PY4A_EXTRAS";
   public static final String ENV_EGGS = "PYTHON_EGG_CACHE";
   public static final String ENV_USERBASE = "PYTHONUSERBASE";
-  public static final String BASE_URL = "http://python-for-android.googlecode.com/";
+  public static final String BASE_URL = "file:///data/data/tmp/";
   private static final int LATEST_VERSION = -1;
   private int cache_version = -1;
   private int cache_extras_version = -1;

获得 .apk 后,继续安装所有内容:

pushd android/PythonForAndroid
adb install -r bin/PythonForAndroid-debug.apk
popd

pushd python-build
adb shell mkdir -p /data/data/tmp/files
adb push python_r16.zip /data/data/tmp/files/python_r-1.zip
adb push python_extras_r14.zip /data/data/tmp/files/python_extras_r-1.zip
adb push python_scripts_r13.zip /data/data/tmp/files/python_scripts_r-1.zip
popd

最后一步是启动 Py4A,然后点击 Install

For installing Py4a, I ended up modifying android/PythonForAndroid/src/com/googlecode/pythonforandroid/PythonDescriptor.java, changing BASE_URL there into a file:/// URL. I was then able to adb push the python_*.zip files into that directory, and install from there.

A key was paying attention to the logcat error messages. As I had no version files, the code asked for an _r1.zip always.

Apply the following patch, and then just follow the instructions in the README file of Py4A to build the APK.

diff --git a/android/PythonForAndroid/src/com/googlecode/pythonforandroid/PythonDescriptor.java b/android/PythonForAndroid/src/com/googlecode/pythonforandroid/PythonDescriptor.java
index a891e98..89bb4f7 100644
--- a/android/PythonForAndroid/src/com/googlecode/pythonforandroid/PythonDescriptor.java
+++ b/android/PythonForAndroid/src/com/googlecode/pythonforandroid/PythonDescriptor.java
@@ -39,7 +39,7 @@ public class PythonDescriptor extends Sl4aHostedInterpreter {
   public static final String ENV_EXTRAS = "PY4A_EXTRAS";
   public static final String ENV_EGGS = "PYTHON_EGG_CACHE";
   public static final String ENV_USERBASE = "PYTHONUSERBASE";
-  public static final String BASE_URL = "http://python-for-android.googlecode.com/";
+  public static final String BASE_URL = "file:///data/data/tmp/";
   private static final int LATEST_VERSION = -1;
   private int cache_version = -1;
   private int cache_extras_version = -1;

Once you have the .apk, go ahead and install everything:

pushd android/PythonForAndroid
adb install -r bin/PythonForAndroid-debug.apk
popd

pushd python-build
adb shell mkdir -p /data/data/tmp/files
adb push python_r16.zip /data/data/tmp/files/python_r-1.zip
adb push python_extras_r14.zip /data/data/tmp/files/python_extras_r-1.zip
adb push python_scripts_r13.zip /data/data/tmp/files/python_scripts_r-1.zip
popd

The final step is to launch Py4A, and poke Install.

两仪 2025-01-02 12:51:46

我发现的简单方法是以在线模式安装所有内容一次,然后压缩目录的内容:

/data/data/com.googlecode.{language}forandroid,
/sdcard/com.googlecode.{language}forandroid,
/sdcard/sl4a

并使用以下批处理脚本进行任何后续安装(Windows)

set ADB_BIN="C:\Program Files (x86)\Android\android-sdk\platform-tools\adb.exe"
%ADB_BIN% install -r sl4a_r4.apk
%ADB_BIN% install -r PythonForAndroid_r4.apk
%ADB_BIN% install -r perl_for_android_r1.apk
%ADB_BIN% install -r lua_for_android_r1.apk

%ADB_BIN% push sd.tgz /sdcard/
%ADB_BIN% shell busybox tar -xzf /sdcard/sd.tgz -C /sdcard
%ADB_BIN% push data.tgz /sdcard/
%ADB_BIN% root
%ADB_BIN% remount
%ADB_BIN% shell busybox tar -xzf /sdcard/data.tgz -C /data/data

%ADB_BIN% shell rm /sdcard/sd.tgz
%ADB_BIN% shell rm /sdcard/data.tgz

The straightforward way that I found is to install everything in online mode once, then compress the contents of directories:

/data/data/com.googlecode.{language}forandroid,
/sdcard/com.googlecode.{language}forandroid,
/sdcard/sl4a

And make any subsequent install using following batch script (Windows)

set ADB_BIN="C:\Program Files (x86)\Android\android-sdk\platform-tools\adb.exe"
%ADB_BIN% install -r sl4a_r4.apk
%ADB_BIN% install -r PythonForAndroid_r4.apk
%ADB_BIN% install -r perl_for_android_r1.apk
%ADB_BIN% install -r lua_for_android_r1.apk

%ADB_BIN% push sd.tgz /sdcard/
%ADB_BIN% shell busybox tar -xzf /sdcard/sd.tgz -C /sdcard
%ADB_BIN% push data.tgz /sdcard/
%ADB_BIN% root
%ADB_BIN% remount
%ADB_BIN% shell busybox tar -xzf /sdcard/data.tgz -C /data/data

%ADB_BIN% shell rm /sdcard/sd.tgz
%ADB_BIN% shell rm /sdcard/data.tgz
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文