- 1 Transferring files
- 2 App development
- 3 Building
- 4 Flashing
- 5 Troubleshooting
- 5.1 Android Studio: Android Virtual Devices show 'failed to load'.
- 5.2 Android Studio: 'failed to create the SD card'
- 5.3 Eclipse: During Debugging "Source not found"
- 5.4 ValueError: unsupported pickle protocol
- 5.5 libGL error: failed to load driver: swrast OR AVD doesn't load and no error message displayed
- 5.6 sh: glxinfo: command not found
- 5.7 Android Emulator: no keyboard input in xfwm4
- 5.8 adb: sideload connection failed: insufficient permissions for device
There are various ways to transfer files between a computer and an Android device:
- USB cable
- special USB sticks / regular USB stick with adapter
- Arch Linux software with Android counterparts
- client or server for protocols that can be used to transfer files (eg. SSH, FTP, Samba or HTTP)
- KDE Connect ( ) – integrates your Android device with the KDE desktop (featuring synced notifications & clipboard, multimedia control, and file/URL sharing).
- cloud synchronization clients
- AUR – cross-platform file sharing
You can install it with the AUR package.
The Android Studio Setup Wizard installs the required #SDK packages and places the SDK by default in
Android SDK packages can be installed directly from upstream using #Android Studio's SDK Manager or the sdkmanager command line tool (part of the Android SDK Tools). Some Android SDK packages are also available as AUR packages, they generally install to
The required SDK packages are:
|Android SDK Package||SDK-style path||AUR package||AUR dummy||CLI tools|
|SDK Tools||tools||AUR||AUR||sdkmanager, apkanalizer, avdmanager, mksdcard, proguard|
|SDK Build-Tools||build-tools;version||AUR||AUR||apksigner, zipalign|
|SDK Platform-Tools||platform-tools||AUR||AUR||adb, #fastboot and systrace|
|SDK Platform||platforms;android-level||older versionsAUR,||unnecessary|
- Since the Android SDK contains 32-bit binaries, you must enable the multilib repository. Otherwise you will get
error: target not found: lib32-*error messages.
- If you choose to directly install SDK packages from upstream, install the AUR packages of the AUR dummy column to pull in the required dependencies.
The Android Emulator is available as the
emulator SDK package, the AUR package. And there's also a dummy package for it: AUR.
Other SDK packages in the AUR
Making /opt/android-sdk group-writeable
The AUR packages install the SDK in
/opt/android-sdk/. This directory has root permissions, so keep in mind to run sdk manager as root. If you intend to use it as a regular user, create the android-sdk users group, add your user.
# groupadd android-sdk # gpasswd -a <user> android-sdk
Set an access control list to let members of the newly created group write into the android-sdk folder. As running sdkmanager can also create new files, set the ACL as default ACL. the X in the default group entry means "allow execution if executable by the owner (or anyone else)"
# setfacl -R -m g:android-sdk:rwx /opt/android-sdk # setfacl -d -m g:android-sdk:rwX /opt/android-sdk
Re-login or as <user> log your terminal in to the newly created group:
$ newgrp android-sdk
Android Studio is the official Android development environment based on IntelliJ IDEA. Alternatively, you can use Netbeans with the NBAndroid-V2. All are described below.
Add the following URL by going to Tools > Plugins > Settings:
Then go to Available Plugins and install the Gradle-Android-support plugin.
The official, but deprecated, Eclipse ADT plugin can be installed with the AUR package.
- if you get a message about unresolvable dependencies, install Java manually and try again.
- as an alternative, you can install the ADT via eclipse's built in "add new software" command (see instructions on ADT site).
- if you are in real trouble, it is also possible to download Android SDK and use the bundled Eclipse. This usually works without problems.
- if you need to install extra SDK plugins not found in the AUR, you must change the file ownership of /opt/android-sdk first. You can do this with
# chgrp -R users /opt/android-sdk ; chmod -R 0775 /opt/android-sdk(see File Permissions for more details).
Enter the path to the Android SDK Location in Windows > Preferences > Android.
sudo eclipse -cleanonce should clear them. If the problem persists, uninstall eclipse and all the plugins, delete
/usr/share/eclipse, and reinstall everything.
Please note that these instructions are based on the official AOSP build instructions. Other Android-derived systems such as LineageOS will often require extra steps.
To build any version of Android, you need to install these packages:
- AUR AUR
TheAUR metapackage provides them all for simple installation.
Additionally, LineageOS requires the following packages:AUR, , ,
They can be installed with theAUR metapackage.
Java Development Kit
The required JDK version depends on the Android version you are building:
- For Android 7 and 8 (Nougat and Oreo), OpenJDK 8 is required, which is available with the package.
- For Android 5 and 6 (Lollipop and Marshmallow), OpenJDK 7 is required, which is available with the package.
Older versions require a working Oracle JDK installed on your build system. It will not work with OpenJDK.
- For Gingerbread through KitKat (2.3 - 4.4), Java 6 is required, which is available as AUR from the AUR.
- For Cupcake through Froyo (1.5 - 2.2), Java 5 is required, which is available as AUR from the AUR.
Set JAVA_HOME to avoid this requirement and match the Arch Linux installation path. Example:
$ export JAVA_HOME=/usr/lib/jvm/java-version-openjdkThis change will be valid only for the current terminal session.
Setting up the build environment
Install the package.
Create a directory to build.
$ mkdir ~/android $ cd ~/android
The Android build process expects
python to be python2. Prepend it to the
$ mkdir bin $ ln -s /bin/python2 bin/python $ export PATH=$PWD/bin:$PATH
Alternatively, create a python2 virtual environment and activate it:
$ virtualenv2 --system-site-packages venv $ source venv/bin/activate
- This activation is only active for the current terminal session. The virtual env will be kept in the
- Passing "--system-site-packages" to virtualenv2 points your virtual environment to your installed python2.7 modules. This should give you all python modules you need for the build, assuming you've installed the required dependencies such as python2-mako.
- If during the build you still receive errors pertaining to missing python modules a quick and dirty fix might be to symlink /usr/lib/python2.7/* to ~/android/venv/lib/python2.7/ (Change ~/android to reflect your build directory if different than above).
$ ln -s /usr/lib/python2.7/* ~/android/venv/lib/python2.7/
or (assuming build directory Data/Android_Build):
$ ln -s /usr/lib/python2.7/* /Data/Android_Build/venv/lib/python2.7/
Downloading the source code
This will clone the repositories. You only need to do this the first time you build Android, or if you want to switch branches.
-jswitch that operates similarly to the one used with
make. Since it controls the number of simultaneous downloads, you should adjust the value depending on downstream network bandwidth.
- You will need to specify a branch (release of Android) to check out with the
-bswitch. If you leave the switch out, you will get the so-called master branch.
$ repo init -u https://android.googlesource.com/platform/manifest -b master $ repo sync -j4
$ repo sync -j8 -c
-c switch will only sync the branch which is specified in the manifest, which in turn is determined by the branch specified with the
-b switch, or the default branch set by the repository maintainer.
Wait a long time. Just the uncompiled source code, along with the
.git directories that are used to keep track of it, are well over 10 GB. As of Android 6.0.1, the entire codebase totals 40 GB.
$ repo sync
Building the code
This should do what you need for AOSP:
$ source build/envsetup.sh $ lunch full-eng $ make -j4
If you run lunch without arguments, it will ask what build you want to create. Use -j with a number between one and two times number of cores/threads.
The build takes a very long time.
- Make sure you have enough RAM. Android will use the
/tmpdirectory heavily. By default the size of the partition the
/tmpfolder is mounted on is half the size of your RAM. If it fills up, the build will fail. 4GB of RAM or more is recommended. Alternatively, you can get rid of the tmpfs from fstab all together.
- From the Android Building and Running guide:
"GNU make can handle parallel tasks with a
-jN argument, and it's common to use a number of tasks N that's between 1 and 2 times the number of hardware threads on the computer being used for the build. E.g. on a dual-E5520 machine (2 CPUs, 4 cores per CPU, 2 threads per core), the fastest builds are made with commands between
make -j16 and
Testing the build
When finished, run/test the final image(s).
Creating a flashable Image
To create an image that can be flashed it is necessary to:
make -j8 updatepackage
This will create a zip image under
out/target/product/hammerhead (hammerhead being the device name) that can be flashed.
In some cases, you want to return to the stock Android after flashing custom ROMs to your Android mobile device. For flashing instructions of your device, please use XDA forums.
Fastboot (as well as ADB) is included in the package.
fastbootcan be quite tricky, but you might want to browse XDA developers forums for a stock firmware, which is mostly a
*.zipfile, but inside of it, comes with the firmware files and
flash-all.shscript. For example, Google Nexus firmwares include
flash-all.shscript or another example could be for OnePlus One - XDA thread, where you can find firmwares with included
no permissionserror or execution just hangs with
< waiting for any device >then you need to run
Samsung devices can't be flashed using Fastboot tool. Alternatives are only Heimdall and Odin (by using Windows and VirtualBox).
Arch Linux (host) preparation:
- Install VirtualBox together with its extension pack and guest additions.
- Install your preferred, but compatible with Odin, Windows operating system (with VirtualBox guest additions) into a virtual hard drive using VirtualBox.
- Open VirtualBox settings of your Windows operating system, navigate to USB, then tick (or make sure it is ticked) Enable USB 2.0 (EHCI) Controller.
- At VirtualBox running Windows operating system, click in the menu bar Devices > USB Devices, then click on your Samsung mobile device from the list, which is connected to your computer via USB.
Windows (guest) preparation:
- Install Samsung drivers.
- Install Odin.
- Download required Samsung firmware (Android) for your smartphone model.
Check if configuration is working:
- Turn your device into Download mode and connect to your Linux machine.
- In virtual machine toolbar, select Devices > USB > ...Samsung... device.
- Open Odin. The white box (a big one at the bottom-left side) named Message, should print a line similar to this:
which means that your device is visible to Odin & Windows operating system and is ready to be flashed.
Android Studio: Android Virtual Devices show 'failed to load'.
Make sure you've exported the variable
ANDROID_HOME as explained in #Android Studio.
Android Studio: 'failed to create the SD card'
If you try to run an AVD (Android Virtual Device) under x86_64 Arch and get the error above, install the multilib repository.package from the
Eclipse: During Debugging "Source not found"
Most probably the debugger wants to step into the Java code. As the source code of Android does not come with the Android SDK, this leads to an error. The best solution is to use step filters to not jump into the Java source code. Step filters are not activated by default. To activate them: Window > Preferences > Java > Debug > Step Filtering. Consider to select them all. If appropriate you can add the android.* package. See the forum post for more information: http://www.eclipsezone.com/eclipse/forums/t83338.rhtml
ValueError: unsupported pickle protocol
One fix is to issue:
$ rm ~/.repopickle_.gitconfig
If that does not work, then try this:
$ find /path/to/android-root -name .repopickle_config -delete
libGL error: failed to load driver: swrast OR AVD doesn't load and no error message displayed
Sometimes, beginning to load an AVD will cause an error message similar to this to be displayed, or the loading process will appear to finish but no AVD will load and no error message will be displayed.
The AVD loads an incorrect version of libstdc++, you can remove the folder libstdc++ from
~/.android-sdk/emulator/lib64 (for 64-bit) or
~/.android-sdk/emulator/lib (for 32-bit) , e.g.:
$ rm -r ~/.android-sdk/emulator/lib64/libstdc++
Note that in versions before Android Studio 3.0, this directory was in a different location:
$ rm -r ~/Android/Sdk/emulator/lib64/libstdc++
Alternatively you can set and export ANDROID_EMULATOR_USE_SYSTEM_LIBS in ~/.profile as:
Reference: Android Studio user guide
Fix for the .desktop file might be achieved by using env command, prefixing the Exec line Desktop entries#Modify environment variables
sh: glxinfo: command not found
Here's the full error:
Cannot launch AVD in emulator. Output: sh: glxinfo: command not found sh: glxinfo: command not found libGL error: unable to load driver: swrast_dri.so libGL error: failed to load driver: swrast X Error of failed request: BadValue (integer parameter out of range for operation) Major opcode of failed request: 154 (GLX) Minor opcode of failed request: 24 (X_GLXCreateNewContext) Value in failed request: 0x0 Serial number of failed request: 32 Current serial number in output stream: 33 QObject::~QObject: Timers cannot be stopped from another thread
You can try to install glxinfo () but if your computer has enough power you could simply use software to render graphics. To do so, go to Tools > Android > AVD Manager, edit the AVD (click the pencil icon), then select Software - GLES 2.0 for Emulated Performance > Graphics.
Android Emulator: no keyboard input in xfwm4
In xfwm4, the vertical toolbar buttons window that is on the right of the emulator takes focus from the emulator and consumes keyboard events. (bug report)
You can use the workaround described in this Stack Overflow answer:
- Open the xfwm4 settings.
- Switch to the Focus tab.
- Change the Focus Model to "Focus follow mouse".
- Disable Automatically raise windows when they receive focus option below.
adb: sideload connection failed: insufficient permissions for device
If you get the error
adb: sideload connection failed: insufficient permissions for device See  for more information adb: trying pre-KitKat sideload method... adb: pre-KitKat sideload connection failed: insufficient permissions for device See  for more information
you might solve it by restarting the adb server with sudo:
$ adb kill-server $ sudo adb start-server