Building WebView From Chromium for Android - 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

Related

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.

How to install SL4A on emulated android phone

i'm currently reading through head first python and upon reaching chapter 8 I got stuck. The book wants me to download SL4A from the link http://code.google.com/p.android-scripting however that link no longer works. So I did some searching and found the file on github. My real problem is when I try to download it on the emulated device it just says waiting for data connection and it never downloads. I am wondering if there is a way to fix this. Any help is appreciated thanks!
EDIT: to get it to work I downloaded both files from here https://github.com/kuri65536/python-for-android/blob/master/README.md
then I copied the files to the folder
C:\Users\lucas\android-sdks\platform-tools
then I opened CMD and cd to the path above.
then use the command:
adb install (filepath)
for both files and they appeared on the emulated device.
Download to your pc and push through ADB.
Download files and adb install worked for me in my installation (Windows 10, android studio 2.1.1) with minor differences:
1) adb command is located in:
C:\Users\MyUser\AppData\Local\Android\Mysdk\platform-tools
Need to add to path
2) Needed release sl4a-r6.1.1-x86-debug.apk. Downloaded it from release pages
I'm also reading through HeadFirstPython and got stuck at this stage (with the error: app not installed). I tried the abs method above and ended up with yet another problem: install_failed_no_matching_abis. After a lot of research, I got to understand that the "native libraries" of the sl4a.apk were not matching the system architecture of my emulated android. In other words, if one wants a faster emulator in android studio, he ought to use an x86 architecture android; but the problem with that is scripting layer for android is programmed to work on ARM architectures hence the 'install_failed_no_matching_abis' error.
The solution that worked for me was to go back to AVD in Android Studio, delete the downloaded emulator (which was of x80 cpu/abi) and download one with armeabiv7 cpu, recommended level=24. It took a lot of trial and error to get to this choice as other android cpu/abi were either too slow or just wouldn't allow me to install the required apps.
Edited: In the end, I was directed to use GenyMotion as that performed better in terms of speed. I was reluctant at first but, to my surprise that really is the case (It is super faster than ARM android studio alternative). Not only is it a great emulator, it also has this ARM translation tools that allows one to easily install ARM sl4a.apk on the x86 devices.

How do I run an Android app I've written in Red?

When I enter this in the Windows CMD...
red -c -t Android hello.red
...Red outputs a file called hello with no filename extension. If I transfer this file to my Android device, it doesn't know what to do with it.
What additional steps must I follow to test my Red code on my Android device?
Which of those steps, if any, must I do differently, depending on whether or not my code will attempt to use the Android bridge?
The Android port is a work in progress done in the android branch. In that branch, using:
red -t Android <script.red>
will use the APK backend for the new packaging layer that will handle the whole process of APK generation for you (provided that you have a JDK1.6+ pre-installed). If all went well, you will get an APK in your working folder.
In case you need to debug the building process, you need to edit the system/formats/APK.r file and set on line 11 the verbose word to yes.
Note: We are working on removing all the external dependencies one by one.
EDIT: The Android Red port has been moved to a private branch and actively worked on. It will be made public once beta stage is reached.
Unless you package up the executable into an .APK, then for security reasons Android throws up some walls in your path to chmod +x it and run.
I followed these directions, just with:
$ cd /data/data/jackpal.androidterm/shared_prefs
$ cat /sdcard/Download/hello.bin > hello
$ chmod 755 ./hello
$ ./hello
Without rooting or otherwise, you wind up with that weirdness like using cat instead of cp, and slipping the file into a strange directory where execution is allowed.
Tested on Nexus 5.
I've not tried yet, but check this: http://www.red-lang.org/2011/12/arm-support-released.html
Also you may know, that there is an experimental Android version here: https://github.com/red/red/tree/android
It appears the question has been answered, but for those who want more, there is an article for getting started with Red for Linux and Android in the March 2014 issue of ODROID Magazine at http://magazine.odroid.com .
There is also going to be a short how-to article in the July 2014 edition (released in the next few days) by Gregory Pecheret that will demonstrate building an .apk from scratch in Red.

How do I install APK using Android updater script

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.

Android Building From Source error: could not load boot.img

I have followed the instuctions as posted on http://source.android.com/source/index.html to build an Android Source Environment. I am using Ubuntu 10.04. The process went without problems. After hours of downloading the Source Tree (I Have tried several including 2.1 and 4.0.1) and execution of the make command all image files were created in the directory '/WORKING_DIRECTORY/out/target/product/generic' except the boot.img file. I read across the internet that it is possible to create an own boot.img file using 'mkbootimg'. However I would like to avoid this in first place and use this option only as a last resort, because I am not familiar with the process as it requires some header files I am not certain of where to find them. I am curios why the boot.img file was not created.
Is somebody facing the same issue or maybe has solved the issue?
Best Regards
You've built your image for an emulator. Thus, you not need an boot.img to run an emulator and that's why it is not in your directory. You should make build for a particular device. If this device is Google device you'll have no problems - just follow the instructions on the webpage: http://source.android.com/source/building-devices.html

Categories

Resources