I am trying to install it on an Android operating system (I have a Samsung Galaxy tablet). I would like to install both R and RStudio.
I've been online to try and find out about this but most of the articles are quite old (going back to 2013) and don't make much sense to me.
I have both R and R studio installed on my personal laptop (with a windows OS) and found these both very straightforward to set up, but having some trouble figuring out how to do this on a tablet.
If anyone has done it recently and been successful please let me know.
Install GNURoot from Google Play
Install Gnuroot Wheezy from Google Play. See http://www.linux-magazine.com/
Online/Blogs/Productivity-Sauce/GNURoot-Linux-on-Android-No-Root-Required
for more help.
Update the package repositories (twice!):
apt-get update
apt-get update
Block updates to system Perl:
apt-mark hold perl-base
Install R:
apt-get install r-base
Install all available cran packages from the Debian repositories:
apt-get install r-cran*
Start R from the command line:
R
source
http://www.r-ohjelmointi.org/?p=1434
Rstudio-server didn't work in a non-rooted device, installed in ubuntu in termux. Related links: rstudio in android - rooted, non-root rstudio discussion.
I found two workarounds in a non-rooted device. Working on browser or VNC Viewer.
1. The browser (jupyter) approach
(tested in yoga book with Android 7.1 and Huawei phone with Android 8 - size with ggplot 1.66 Gb)
install termux (google play) (As termux didn't run jupyter-IRkernel, I had to install ubuntu)
install ubuntu in termux (MFDGaming or Neo-Oli).
run this in ubuntu:
apt update && apt upgrade
apt-get install apt-transport-https software-properties-common
# add R repository
add-apt-repository 'deb https://cloud.r-project.org/bin/linux/ubuntu disco-cran35/'
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9
apt update && apt upgrade
apt install nodejs
apt install npm # absence of this causes non-editable cells in jupyter
apt install gfortran
apt install liblapack-dev
apt install libopenblas-dev
# install R
apt install r-base-dev # or r-base or r-base-core
# install python package manager
apt-get install python3-pip
# install jupyter
pip3 install jupyterlab
# open R
R
Inside R:
# Package necessary for jupyter
install.packages("IRkernel")
IRkernel::installspec()
q()
In ubuntu, run the jupyter lab
jupyter lab --allow-root
# as you will see you have to paste something like this in your internet browser
http://127.0.0.1:8889/?token=1a0f9b3d472d155bb4d46df119b937646d6192f569c9d635
You would need to disable the automatic hibernation of termux in battery settings.
Note: In termux app (google play) is possible to install R, see Conor link; the important setupclang-gfort-8 step can be accomplished after installing make and gcc-8 and using the new package names in the output of the (outdated) Conor protocol. The problem appears if you want GUI. An option is the Rcmdr package, but as termux has not tcl-tk, as you can see inside R using capabilities(), I ended installing ubuntu in termux
2. The VNC approach
As in the browser approach install termux and ubuntu
In ubuntu install aterm
After installing R in ubuntu (see above), install R Commander GUI package:
#in R:
install.packages("Rcmdr")
In ubuntu install vnc4server
In Android install VNC Viewer (google play).
Launch the VNC server in ubuntu:
tigervncserver -xstartup aterm
In VNC Viewer connect to 127.0.0.1:5901 which corresponds to the :1 display (showing the aterm in white), open R in aterm, then library(Rcmdr).
After ploting, see ggplot example, I had to write (blindly) dev.off() because there is no other way to return to the script window.
require(ggplot2)
ggplot(diamonds) + geom_point(aes(x=carat, y=price, color=cut)) + geom_smooth(aes(x=carat, y=price, color=cut))
Notes:I also installed X11 in ubuntu, but didn't seem to improve the GUI experience of Rcmdr. In a yoga book with android the #Ajay answer didn't work.
Not exactly R Studio but still pretty cool... follow this Installing R on Android via Termux guide from Conor Anderson's blog.
Step 1: Install Termux from F-Droid (or Google Play Store)
Install from F-Droid
Step 2: Add the its-pointless package repository
Enter the commands below one at a time:
pkg install curl gnupg
mkdir -p "$PREFIX/etc/apt/sources.list.d/"
echo "deb https://its-pointless.github.io/files/24 termux extras" > "$PREFIX/etc/apt/sources.list.d/pointless.list"
curl "https://its-pointless.github.io/pointless.gpg" | apt-key add
Step 3: Install required .deb packages
Install the following packages. It might be wise to install each individually to monitor the warnings, I think some of these packages may be deprecated at this point in time.
pkg install r-base \
make \
clang \
gcc-9 \
libgfortran3 \
openssl \
libcurl \
libicu \
libxml2
Step 4: Configure your compiler
setupclang-gfort-9
Step 5: Launch R by typing an upper case R
R
Step 6: Further customize with Nvim-R or whatever else you like
Here is a summary of my experiments, as of October 2021. Long story short: I have a fully working R (complete with tidyverse) on my tablet, and I can access it from jupyter (which is not my first choice in general, but is probably appropriate for this platform and my use - I'm not planning to develop on Android, merely to try code snippets etc).
This draws mostly from the present article as well as from How do I install Jupyter notebook on an Android device? , and links therein.
Also, caveat reader: I'm not an expert in Linux, even less so on Android, and my understanding of Python is minimal. Sorry for any mistake or imprecise statement.
Including trial and errors, the whole process took me some 5 hours. Now I know what to do, I'd probably manage in 1 or 2.
Introduction
Android is a linux in disguise, so in principle it is possible to install all or most linux apps. There are, however, several caveats:
You normally do not have root access to your device (unless it is rooted, which is another can of worms);
When compiling binaries, they must be compiled for this specific architecture.
For these reasons, you can not always use ordinary .deb or .rpm packages and need to go through a somewhat convoluted route.
Also, it appears that R-studio cannot be installed without root privileges (either because it requires root itself, or because it relies on libraries that cannot be installed by a normal user).
Assuming you do not want to go the root route, you can still manage quite a few things.
You will need some basic familiarity with linux commands (cd, ls, chmod, ln...), and at least a basic idea of how packages are installed and managed in linux (apt-get or pkg), in R (install.packages() ) and in python (pip install). Also, it will not harm if you know what a compiler is (gcc), and if you realize that some R/python packages rely on compiled code (binaries) that typically resides somewhere else on the system.
Termux
Termux is "an Android terminal emulator and Linux environment app", a portable Linux distro running on Android (more or less).
Unfortunately the version currently on G-play is not the most recent one, so you want to use the f-droid version. So, install f-droid and then, from f-droid, install termux.
Configure termux
You will need basic tools (compiler etc) up and running on termux. This will require installing packages and in turn, you need packages compiled for this platform. In termux, many packages are maintained by "its-pointless" who also runs the relevant repository. So, in termux :
# basic utilities
pkg install curl gnupg
# Configure its-pointless repo
mkdir -p "$PREFIX/etc/apt/sources.list.d/"
echo "deb https://its-pointless.github.io/files/24 termux extras" > "$PREFIX/etc/apt/sources.list.d/pointless.list"
curl "https://its-pointless.github.io/pointless.gpg" | apt-key add
Now you can install more utilities, from its-pointless repo:
pkg install make \
clang \
gcc-9 \
libgfortran3 \
openssl \
libcurl \
libicu \
libxml2
And configure your compiler
setupclang-gfort-9
R !
Still in termux, run
pkg install r-base
At that stage, you should have a working R on your system (although purely text-based, but you can still use an external editor and source() your scripts).
Something nicer ?
You maybe want a GUI, or more pakages (tidyverse). Shortly, the main problem you will face is that many R packages in linux rely on system libraries, that need to be installed from linux. In principle you should be able to install the full libraries (the binaries as well as the R code) from install.packages(), that launches gcc to compile whatever code is needed; but practically, the compilation seems to fail more often than not. Probably the Android gcc has its quirks...
So the general idea will be to install from termux (or its-pointless) repo the R packages you need, or at least the library they rely on. The same is true for python libs, by the way.
Installing R packages
From within R, try to install what you need with the usual install.packages() command. If something needs to be compiled, it will probably fail. Read carefully the error - eventually you will find a line that says something like "missing libpango.so". This tells you, in this case, that you need to install pango, which happens to belong to the pango package : in termux, run pkg install pango, then return to R and try again.
Also, updating your packages to the latest version (pkg upgrade all) will do no harm...
On stack overflow, you will find various references to zlib, libpng, etc... read and interpret the error message.
In one case (R package repr, that needed base64, itself relying on libicu) I had a version issue - one of the termux packages was (incorrectly) requiring an old version of libicuuc (libicuuc.so.68), whereas the same termux had installed libicuuc.so.69 on my system. In this case, the cure was to create a symbolic link in the approriate directory, as follows
ln -s libicuuc.so.69 libicuuc.so.68
.. and the system happily followed the link :-)
By playing around with this, I managed to install tidyverse, as well as IRkernel that is required to establish a connection between R and jupyter. IRkernel needs to be configured from within R: IRkernel::installspec()
VNC
One user at Installing R on Android refers to the possibility of installing VNC, to obtain Rcmdr. I haven't tried.
Jupyter
It is also possible to install jupyter or jupyter-labs (which is not my favourite IDE under normal circumstances, but is probably an appropriate platform on a Android device).
Jupyter is python based, so you will need to play the same game with Python and python packages. Python packages are installed using pip (from the linux command line), and you will have the same issue with compiled binaries. Fortunately the most tricky python packages are packaged by its-pointless for termux, so here too, you will end up installing quite a few things outside of pip.
Installing R on Android suggests installing ubuntu on top of termux, and then installing jupyter from within ubuntu. I found it unnecessary (How do I install Jupyter notebook on an Android device?)
Termux will need more packages:
pkg install python fftw libzmq freetype libpng pkg-config libcrypt
There are also references to modejs, liblapack-dev and libopenblas-dev, I cannot remember whether they were required or not in the end (or already installed by something else). Also sometimes the relevant code moved out of the dev package to a stable one (so it would be liblapack)
Then, you need to install python stuff. Web sources suggest
LDFLAGS="-lm -lcompiler_rt" pip install jupyter
or/and, depending on the version you want to use
LDFLAGS="-lm -lcompiler_rt" pip install jupyter-lab
and (not required but useful to have in jupyter) :
LDFLAGS="-lm -lcompiler_rt" pip install numpy matplotlib
I'm not sure why we need LDFLAGS...
As previously, some of the "hybrid" packages are best installed from termux, for instance scipy (technically a python package, should be installed with pip install scipy) is easier to install (or must be installed?) using the termux version, so pkg install scipy
Again, some debugging will be required. Read the pip output, try to find out which package failed to install, see what you can do from termux, try again. Sometimes I found that dropping the LMFLAGS helped (or installing packages one by one), for instance a plain pip install cffi and pip install pyzmq worked better than having them installed as dependencies to jupyter. No idea why.
In the end, I launched jupyter (type jupyter notebook, or jupyter lab in termux console, copy the url, open in a browser)... only to have R crash on the first command. Back in termux I could see that it was still missing a library somewhere, which I tracked down and installed from termux (I think it was pango, this time).
So in short: Read the Friendly Error Messages !
Related
I am running android emulator in ubuntu-19.10 and I have attempted following solutions with no results,
Link-1
Link-2
Link-3
Error,
1:10 PM Emulator: pulseaudio: pa_context_connect() failed
1:10 PM Emulator: pulseaudio: Reason: Connection refused
1:10 PM Emulator: pulseaudio: Failed to initialize PA contextaudio: Could not init `pa' audio driver
Some notes on solution I tried,
When trying Link-1 i don't see "Qemu-system" in settings. Also created many different versions of AVDs but does seem to work.
After trying Link-2 pulseaudio -D command errors out.
I have also tried Link-3 which looks like widely suggested solution in multiple blog posts. But still I find the same error on emulator startup. I would like to note that I am not smart enough understand this solution.
Thanks in advance for helping out.
Same problem in Ubuntu 20.04, with Android Studio installed from Ubuntu Software. Tried everything (paprefs, this), nothing worked. Uninstall Android Studio Snap and reinstall from tar package downloaded from Android Studio website, works perfect.
I was having a similar issue on Ubuntu 20.04 but I fixed it by uninstalling the store version of Android Studio and following the installation instructions on the Official Android Studio website here: https://developer.android.com/studio/install
If you are running a 64-bit version of Ubuntu, you need to install some 32-bit libraries with the following command:
sudo apt-get install libc6:i386 libncurses5:i386 libstdc++6:i386
lib32z1 libbz2-1.0:i386
To install Android Studio on Linux, proceed as follows:
Unpack the .zip file you downloaded to an appropriate location for your applications, such as within /usr/local/ for your user profile, or /opt/ for shared users.
If you're using a 64-bit version of Linux, make sure you first install the required libraries for 64-bit machines.
To launch Android Studio, open a terminal, navigate to the android-studio/bin/ directory, and execute studio.sh.
Select whether you want to import previous Android Studio settings or not, then click OK.
The Android Studio Setup Wizard guides you through the rest of the setup, which includes downloading Android SDK components that are required for development.
I had the same issue, runing Intellij on Ubuntu 20.04. I solved it by adapting a solution from this link
I run this:
sudo ln -s /run/user/1000/pulse/native /run/user/1000/snap.intellij-idea-community/pulse
If you're using Android studio, just try to find "snap.intellij-idea-community" will be named differently, referring to your android studio installation.
On Ubuntu, is possible open the emulator with terminal and change the sound in System Preferences. Works with the instant version of Android Studio. It works with the snap version of Android Studio.
First is needed to add the emulator command to the PATH.
This can be done by editing .bashrc or .zshrc. Preferably these lines should be placed at the end of the file.
export ANDROID_SDK_PATH=$HOME/Android/Sdk
export ANDROID_NDK_PATH=$HOME/Android/Sdk/ndk
export PATH="$PATH:$HOME/Android/Sdk/platform-tools"
export PATH="$PATH:$HOME/Android/Sdk/emulator"
The PATH variable needs to be reloaded. This can be done manually, as shown below, or simply by opening another terminal:
source ~/.bashrc
# OR
source ~/.zshrc
Another way is to add adb and android-sdk-platform-tools-common packages to have the emulator command available. Package names may vary depending on the Ubuntu version.
After that, the emulator command can be used to list available emulators:
emulator -list-avds
Example of output:
Pixel_4_API_30
Pixel_C_API_30
Then can be opened one of the available emulators:
emulator #Pixel_4_API_30
Finally, the emulator probably will appear at the System Preferences:
If this is a Snap it's got strict requirements as far as i/o; that said, if the requirements are similar to those of running Androidx86 using Vbox on Debian (I realize Qemu is a different environment, however, this may be of use for both Jbaba as well as future reference. Step one: make sure that you belong to the group Qemu (or the equivalent for Ubuntu/Snap?). Step two: make sure you belong to the group pulseaudio. Step three: make sure that Qemu is explicitly permitted to access whatever your audio output device is and that it's the device that pulseaudio is configured to output to. There should be a fairly intuitive way of seeing this using Qemu (it's been awhile, so I am not able to tell you where to find it). As for pulseaudio; its GUI will show you.
I got crazy while trying to solve this issue but finally, it was solved. I figured out that we have to enable multiple simultaneous audio outputs in order to hear both sounds the emulator and the OS.
The solution is by installing paprefs small app as the following.
1- Install it:
$ sudo apt install paprefs
2- Open it:
$ paprefs
3- Go to the last tab Simultaneous Output and click on the only option there in order to enable the Simultaneous Output.
4- Restart it:
$ pulseaudio -k
5- If it fails then you have to restart the daemon
$ pulseaudio -D
6- Almost finished, go to the system settings and navigate to Sounds options and change the output sounds to the newly added one as below.
OS : Ubuntu 20.04.
Android studio (snap).
I tried all the methods, none worked for me.
By installing these libs, the sound works now.
sudo apt-get install libc6:i386 libncurses5:i386 libstdc++6:i386 lib32z1 libbz2-1.0:i386
as Gigi mentionned before
I installed jupyter notebook on android via Termux, but I still can't open my .ipynb or .py, because I can't open directories neither upload a file.
This is my jupyter for opening files page:
I get this when I'm trying to upload file:
Jupyter must be started from the directory containing the notebooks. Maybe this is the information you need.
I could not successfully install Jupyter on Termux on my Android devices (phone and tablet) due to errors when trying to install numpy.
So, I turned to an alternate solution which did work perfectly with no hassle:
I installed Pydroid 3, a Python 3.6 IDE for Android. Then, I pip installed within the IDE the required libraries (numpy, pandas, jupyter) without any difficulty.
To start Jupyter, I launched a terminal using the relevant Pydroid menu.
And finally, I changed the directory to the one where I had dowloaded a whole bunch of Jupyter notebooks and launched Jupiter which automatically open the notebook tree in my browser:
Fully executable notebook:
To install jupyter notebook into termux Android, you need to copy paste these codes one by one into termux terminal. (Note: for python programming language)
pkg remove game-repo
pkg remove science-repo
pkg update
apt install python
pkg install libzmq
pip install jupyter
After you have completed all these, just type jupiter notebook on termux terminal to open the jupyter every time. An url like "http://localhost:8870/?token=d2845af71c0d9b0ea3b43......abansk" (not complete real url, just an example) will come out and you will need to copy and paste into your browser.
Using Ubuntu 16.04, Android Studio and Genymotion (latest versions).
Genymotion works perfectly when run directly, but does not work from Android Studio with the Genymotion plug-in installed. The error I get from Genymotion is "In order to work, Genymotion requires VirtualBox to be installed on your computer. You can download the latest version of VirtualBox from www.virtualbox.org/wiki/Downloads.".
Of course VirtualBox is installed. Even tried removing it and installing again (v. 5.1).
There is an odd issue with the Genymotion Android Studio plugin, which makes it impossible to start a device. This often manifests with genymotion.log containing error messages such as:
Output command: "/usr/lib/virtualbox/VBoxManage: ./libssl.so.1.0.0: version 'OPENSSL_1.0.2' not found (required by /usr/lib/x86_64-linux-gnu/libcurl.so.4)"
It comes from the fact that Android Studio defines LD_LIBRARY_PATH to be /android/studio/install/dir/bin:$LD_LIBRARY_PATH which becomes /android/studio/install/dir/bin: if LD_LIBRARY_PATH is not set. This causes VBoxManage to try to load the libssl.so shipped by Genymotion, which is too old for Ubuntu 16.04 (because when LD_LIBRARY_PATH ends with ":", the linker looks for libraries in the current directory)
You can do one of the following:
Edit studio.sh to stop adding a trailing ":" at the end of LD_LIBRARY_PATH (I can provide more details if needed)
Remove libssl.so and libcrypto.so from Genymotion install directory
Define LD_LIBRARY_PATH to some random value before starting Android Studio so that the LD_LIBRARY_PATH defined by studio.sh does end with ":"
Note that this has been fixed in Android Studio 3.1.
After visiting the Genymotion site, it might have something to do with the dkms package:
Make sure that the dkms package is installed and that it compiles VirtualBox kernel modules each time a new kernel update is available.
To do so, run sudo /etc/init.d/vboxdrv status.
You should get the message "VirtualBox kernel modules (vboxdrv, vboxnetflt, vboxnetadp, vboxpci) are loaded".
If not, force VirtualBox kernel modules compilation by running sudo /etc/init.d/vboxdrv setup.
Make also sure that you are part of the vboxusers group.
If not, run sudo usermod -a -G vboxusers <login>.
Maybe it is caused because of the dkms package is not updated, so you are not able to use Genymotion from Android Studio but only running it directly.
ok this took me some quality time to figure out take this step
locate your etc folder
cd into init.d
run virtualbox status:
if it tells you that you need to install dkms package. then on a new terminal
sudo apt-get install linux-headers-uname -r
sudo dpkg-reconfigure virtualbox-dkms
6.enter a password and renenter
then reboot and load to MOK(Your will get a blue screen that will ask to reload to MOK before rebooting)
Ok
your machine by now is rebooted
start your terminal go to etc/init.d
run virtualbox staus
I believe no errors
on a new terminal cd to your directory with genymotion
13.cd into genymotion
run ./genymotion
congrats
Update
After doing some more experiments, I have to reformulate my question completely as I was fooled by my terminal. It just didn't showed the error message when I issued sudo ./adb.
If I cd into the ANDOID_SDK/platform-tools directory and run ./adb, I get:
command not found: ./adb
Here the output ls -l adb in the same directory:
-rwxrwxr-x 1 myuser myuser 159620 2011-12-20 19:30 adb
Running which adb gives me:
./adb
The same happens for all other binary executable files in that directory like aapt, aidl, dexdump, etc.
I could just imagine that this has something to do with me trying to run it on a 64bit Ubuntu, but the ELF header or something similar not being recognised. However, the android tool in ANDOID_SDK/tools is running fine (besides failing to execute adb after downloading new packages).
Really strange...
Original question
I downloaded the latest Android SDK. If I try running adb as an ordinary user, I get "command not found". I must run it as "sudo ./adb" and it works. Why is that and how do I fix it? I'm running Ubuntu 64 11.10.
I used the SDK on older Ubuntu versions and there, I could run it as ordinary user without problems. Any ideas?
I found the solution. I investigated again if I really got ia32-libs installed. On a first glance, it looked fine in aptitude. However, on a second glance I noticed that the ia32-libs package was installed, but not all dependencies. I was not able to resolve that with aptitude, but instead I had to remove ia32-libs with KDE package manager and install it again. Now, all missing 88 dependencies were installed, too. adb is now working fine.
I'm not 100% sure why aptitude failed here, but I suspect that it is suffering from this bug on my installation, too: https://bugs.launchpad.net/ubuntu/+source/aptitude/+bug/831768 I also have duplicate entries in aptitude for all entries.
Add platform-tools to environmental variable,for that
Append the following line to last of the /home/yourUserName/.bashrc file in your home folder..
export PATH="your/path/android-sdk-linux/platform-tools/:${PATH}"
Run 'chown' on the android sdk folder to make your user account the owner of the folder. It sounds like it's owned by the root user at the moment. I can't remember the syntax, but there'll be plenty of examples online.
I need help on setting up my system to develop the Android OS (not apps the OS). I have an Ubuntu machine running 10.10, but I'm stuck on preparing my system and actually getting the code. What programs do I use? And what kind of things do I need to type to write the code?
This handy guide will walk you through setting up your system.
In general, you will need to install:
Git
Python 2.4
JDK 5 (froyo or older) or JDK 6 (gingerbread or newer)
What programs do I use?
Eclipse seems to be the most popular IDE for working with Android. Personally, I like using a plain old editor (emacs, vi, kate, etc.) and a terminal window.
Here is my setup:
Android SDK unzipped to ~/sdk/
Add ~/sdk/android-sdk-linux_x86/tools and ~/sdk/android-sdk-linux_x86/platform-tools to your path:
echo "PATH=$PATH:~/sdk/android-sdk-linux_x86/tools:~/sdk/android-sdk-linux_x86/platform-tools" >> ~/.profile
install sun-java6-jdk. first enable the partner repository.
sudo apt-get install sun-java6-jdk
install ant
sudo apt-get install ant
you'll have to choose an editor. if you like gedit, I suggest adding the ubuntu-on-rails ppa (http://www.webupd8.org/2010/12/get-textmate-features-and-styles-in.html) and installing gedit-gmate. if you're a vim person, I suggest install vim-scripts
To support your real phone you may need to create a udev rules file. Google 'android ubuntu udev your-phone-model' for help. For instance, for a nexus one you would:
- add /etc/udev/rules.d/51-android.rules with one line:
SUBSYSTEM=="usb", SYSFS{idVendor}=="18D1", MODE="0666"
After all of that, http://android.developer.com is your best friend.