How do I install APK using Android updater script - android

I'm attempting to use Android's updater script language (Edify?) to install an APK over-the-air to an embedded device that I have control over. Here's a link that describes the language.
My first attempt was the following:
package_extract_file("added_files/data/app/test.apk", "/data/app/test.apk");
That resulted in test.apk being automatically installed in /data/data/com.acme.test, however the directory /data/data/com.acme.test/lib is empty, whereas it should contain test.so, a shared library contained in test.apk. (If I manually install using adb install test.apk, the library is extracted.)
I then tried extracting the APK into /data instead of /data/app so the OS wouldn't automatically install it into /data/data, and I could try installing using the script:
package_extract_file("added_files/data/app/test.apk", "/data/test.apk");
run_program("/system/bin/pm", "install", "/data/test.apk");
That resulted in the following error:
about to run program [/system/bin/pm] with 3 args
run_program: execv failed: Exec format error
run_program: child exited with status 1
I'm not sure why the above error happened.
Is there a way to install an APK and have its shared libraries extracted automatically? I could install the libraries manually, but I'm hoping to avoid that.

I'm not familiar with Edify, but by looking at the documentation, package_extract_file() simply extracts the APK as the archive file that it is. Why data ends up inside /data/data is strange; are you sure that isn't just left behind from a previous installation? I'd suggest fully uninstalling the app and trying again.
It seems to me that that particular function isn't suited for installing the app. You might want to try installing it through a command:
run_program("adb", "install", "-r", "added_files/data/app/test.apk");

Edify scripts run in a recovery mode and depending on your device not all partitions are available by default. Most likely your problem is that the partition you are trying to use is not mounted yet.

Related

Run XSLT-script on android smartphone and/or tablet

I have a relatively simple question:
Is there a possibility to run an xslt-script on an android device? I have an .xml file, using a .xsl script to create a new .xml file.
On windows I am using saxon, which works good, but as I don´t have always access to it I would prefer to run a script on my android phone and/or android tablet.
I did some research with google and also on this site, but i didn´t found any clear answer.
thanks in advance and greetings
I have now found a way to run both Saxon-JS 2 or rather its command line tool xslt3 as well as Saxon HE Java from a command line terminal for Android.
I installed Termux, I had to use the version from F-Droid, as the one on the Google play store seems to be no longer supported, then in the Termux terminal shell I installed node and java (try to run with e.g. ˋnodeˋ and it will tell you the ˋpkg install ...ˋ command line to install, then I did e.g. ˋnpm install -g xslt3ˋ to install Saxon-JS's command line tool and downloaded the Saxon HE 11.2 Java zip from Sourceforge with wget and unzipped it and finally I am able to run e.g. xslt3 to run Saxon-JS or java -jar path-to-saxon11jar to run XSLT 3 (or in the case of Saxon Java of course XQuery too.
The interaction with the rest of the Android file system is a bit complicated to find out but the Linux Terminal shell has its own file system with a storage folder with sub folders like storage/download linked to the usual download folder other Android apps (e.g. your browser) use.
Here is a screenshot of Termux on my Android tablet showing the execution of Saxon HE 11 Java and Saxon-JS 2: .
It turns out the same procedure doesn't work quite as well on my Android phone which has Android 12 as the running Java and therefore Saxon HE 11 or any other Saxon Java HE currently does not work due to a known issue https://github.com/termux/termux-packages/issues/7332. But Node.js and npm and therefore Saxon-JS with xslt3 run fine on that phone.

Building WebView From Chromium for Android

I am trying to follow the instructions to build the webview apk from chromium base. I am running a Android-7.0 build. I finished the compilation process for chromium and generated the APK. I have two questions related to steps after APK generation.
Firstly the library name is different from what I expected. The default webview.apk has a library name libwebviewchromium.so, but the APK I built from chromium (SystemWebView.apk) contains the lib libwebviewchromium.cr.so. I wanted to ask whether that can cause problems and if others also saw this.
Secondly, I am unable to uninstall the com.android.webview app from the device. The instructions require uninstallation of this app and deleting its folder before the new APK can be installed. I get the error:
$ adb uninstall com.android.webview
[DELETE_FAILED_INTERNAL_ERROR]
I wanted to ask if anyone knows how to resolve this. I saw a related question and want to ask if there is any other approach that doing what this answer suggests.
The following answer is related to the second part of my question.
I did the following steps to make the SystemWebView.apk work (note: the webview.apk was a system app in my build under /system/app; the steps below were used to install & test SystemWebView.apk as a third party app)
(Take a look at step 6 first for taking back up of 2 files)
Firstly I followed the linked answer to adb pull & edit the packages.xml and packages.list files (I haven't pushed them yet)
adb shell stop
I push the two files
I then deleted the following folders (basically any trace of com.android.webview):
/system/app/webview
/data/data/com.android.webview
/data/user/0/com.android.webview
/data/misc/profiles/cur/0/com.android.webview
/data/misc/profiles/ref/com.android.webview
/data/user_de/0/com.android.webview
adb install SystemWebView.apk
I also had kept a back up of libwebviewchromium64.relro and libwebviewchromium32.relro files from /data/misc/shared_relro/. After the install, I noticed that these files get erased for some reason, so I copied them in again (first copying into sdcard and then moving into shared_relro folder).
adb shell start
After that I tested a simple app containing a WebView, and could see web pages loaded.
You have to build SystemWebView.apk with
ninja -C out/Release system_webview_apk
For more details check this page.
https://chromium.googlesource.com/chromium/src/+/master/docs/android_build_instructions.md
and
https://www.chromium.org/developers/how-tos/build-instructions-android-webview
adb uninstall com.android.webview
fails because this is a system app, you can directly replace the webview.apk in
/system/app/webview/ dir, after this do stop && start
for this you need root permission.
Native web view has many limitations in performance and caching.
I would rather suggest you to CustomTabsClient, a web view supported by Chrome Browser. you could get it by adding following dependencies to your project.
dependencies {
...
compile 'com.android.support:customtabs:23.3.0'
}
For more detail visit.
https://developer.chrome.com/multidevice/android/customtabs

Running C code on android using termux or gnuroot?

I'm trying to run c code on my android device using various terminal emulator apps. I have tried 3 so far and all of them are giving me errors. The first one I tried was the most popular: terminal IDE. Ever since the later versions of android have been released this app will not compile c code due to a position independent executable (PIE) error. Next up was a promising app called termux. This app allows me to compile my C code with gcc but gives me "permission denied" errors whenever I try to run even the simplest of codes. I have examined and researched this error thoroughly. I have tried using chmod in various different ways as well as checking the permissions using ls -l and have tried compiling and running in both the external sd card AS WELL AS on the internal device storage. I understand that the SD card doesn't have exec permission but it still won't work even in my device's internal memory. I have asked for help from the termux creator but to no avail. No matter what I do I cannot seem to get these codes to run on my android device. It is not rooted and I don't plan to root it any time soon. All of these apps claim that they should work without rooting the device. I finally tried running C code in another app (my last hope) called gnuroot. Unfortunately I'm still getting the permission denied error, but the code does compile as it did in termux. I can't access any of the directories created by these apps by the way. They are hidden from the "my files" app which normally lets me browse directories on my device. However, the directories shown when I type in ls are not in the my files app, so I can't place any files directly in them. I can only see the basic home directories for termux and gnuroot, but when I try to place the code in there, I still get the permission denied error. Furthermore, I don't know what directory to even place the code in for it to work. I'm totally lost and really need help. Thanks.
I've gotten C programs running well under termux using gcc.
While compiling, compile your code using the -o option, and no -c, like this:
gcc -o helloworld helloworld.c
The object file helloworld will be created with execute permissions and you can run it with ./helloworld.
Note that the source files must be in the home directory first. If you haven't changed your environment variables, first go to your home directory with cd and then compile your source files there.
In Termux, if you use Midnight Commander or Ranger you can go back one directory from home to files, and in there you'll find the apps /etc, /bin, /usr, /etc.. directories. Maybe that is where you can find or send the files you are looking for.
Try to upgrade Termux. Simply run:
"packages upgrade" (with no quotes)
in command line.
If this don't fix the problem, run:
"packages install termux-exec" (with no quotes)
Hope this help.

What happens when we press "execute" in eclipse or "run" in IDEA InteliJ?

I'd like to customize what happens when we execute or run an android application. Currently it seems to upload the apk to a temporary location on the device, and then execute
pm install -r <temp_apk_path>
I'd like to change these options, like using installd always, or specifying -d flag to allow version downgrade. Can this be set somewhere so that it executes these commands everytime ? I can make it work with an ant build script, by making changes to the <sdk>/tools/ant/build.xml, but I'd then have to run ant build everytime. Is there a way to make it the IDE default ?
Bonus : I researched extensively, and didn't find a way to change the install location in the device directly, but if there is a way, please tell. What I mean is not changing the target to SD card by specifying target as [2], but the actual path, like say data\my_own_path

Install .apk file to Android Emulator on a Mac

I'm new to Android and I was given some .apk files (not created by me) with malware that I'm trying to run on the Android emulator for testing purposes (trying to get app's system call data using strace).I have checked several places online, but I'm stuck trying to install the .apk file. When I run the following command :
./adb install filename.apk
I'm getting this error:
Failure [INSTALL_FAILED_DEXOPT]
Any help is greatly appreciated!
Just Drag and drop apk into your Android emulator. its automatically install by it self.

Categories

Resources