Project

General

Profile

Actions

SDK

Introduction

The Android SDK as released by Google is distributed under a non-free license and suggests installing non-free plug-ins such as the Google APIs.

Replicant 4.2 and earlier provided its own SDK, built from source. The ReplicantSDK page holds a list of the previously released Replicant SDK builds.

With Replicant 6.0, Replicant didn't invest time into releasing an SDK since several FSF certified distributions already shipped an Android 6.0 compatible SDK. The associated blog post has more details about this choice.

There is a new project to rebuild SDK in https://codeberg.org/Starfish/SDK-Rebuilds. It can build Imagepipe and TinyWeatherForecastGermany that are being review in F-DroidAndApplications and that have fully free source code and no external dependencies. The SDK build scripts are tested and kept up to date. So at the time of writing are currently trying to organize to build the Android SDK with these scripts and publish them. The author of these script also told us that he can respond to bug reports about freedom for instance in cases where nonfree code is found inside the SDK source code. He can also add support for FSDG compliant distributions if users test them. Since we're organizing to to setup builds for the SDK we'll most likely use Trisquel to build them to have Trisquel automatically supported.

GNU/Linux distributions

The following FSF certified distributions have Android SDKs:

Distribution Gradle version Android versions
PureOS 9 (amber) 4.4.1 6.0 (API Level 23)
PureOS 10 (byzantium) 4.4.1 6.0 (API Level 23)
Trisquel 9 (etiona) 3.4.1 6.0 (API Level 23)
Trisquel 10 (nabia) 4.4.1 6.0 (API Level 23)

At the time of writing, Guix, Hyperbola, Parabola don't have an SDK, and the other FSF certified distributions weren't checked but are unlikely to have packages for an Android SDK.

The following distributions are also known to have an Android SDK:
Distribution Gradle version Android versions
Debian 9 (stretch) 3.2.1 6.0 (API Level 23)
Debian 10 (buster)
Debian 11 (bullseye) 4.4.1 6.0 (API Level 23)

The F-DroidAndApplications wiki page also has information on attempts to build Android packages with these SDKs.

Attempts to go further than Android 6.0

At some point there was an Android Rebuilds project that provided free SDKs at https://android-rebuilds.beuc.net/ but the author mentions that the project ended in 20211.

That project also lacked a license. That led another project by wchen342 to restart from scratch.

Wchen342's reimplementation is tested ungoogled-chromium-android and uses debian 12 (bookworm) through docker. It might be possible to use PureOS instead when the equivalent PureOS version is released.

F-Droid also has a forum post that asks for help with that as they currently rely on the nonfree SDKs and they want to fix that.

1 "Android Rebuilds, how to rebuild SDK/NDK, precisely, without non-free EULA (2015-2021)" on https://www.beuc.net/

WIP Report: FOSS Android SDK Build

Current Status:

We have successfully created a pkgbuild/APKBUILD for the android-sdk based on the Rebuild-SDK, which again was based on the android rebuilds, which builds without errors for Android 14. However, upon further investigation, we discovered that the Android repository includes over 187 binary dependencies, such as Go and Rust, in the prebuilt repository, that are downloaded using the repo tool. Patching these dependencies manually is a tedious task, as there are many build scripts that rely on these binaries.

New Approach:

We have found an unofficial CMake-based build system for Android command line utilities called android-tools, which is already used in many Linux distributions. Our next step is to evaluate the possibility of creating a merge request to build the Android SDK using CMake.

Call for Help:

We are seeking assistance in writing the necessary CMake files to support this new build system. Specifically, we are looking for help with:

  • Creating CMake files for the Android SDK build process
  • Integrating the CMake build system with the existing Android repository
APKBUILD for alpine linux
Port the android 14 sdk to alpine linux and arch linux
pkgname=android-sdk
pkgver=14.0.0
_pkgrev=r74
pkgrel=0
pkgdesc="android sdk without google binaries" 
url="https://git.replicant.us/contrib/wizzard/Android/SDK-Rebuild" 
arch="all" 
license="APACHE" 
makedepends=" 
bison
flex
git
gnupg
gperf
libx11-static
libxml2
libxslt
mesa-dev
ncurses-static
python3
repo
rsync
unzip
openssh
bash
" 
source="" 
builddir="$srcdir/" 
options="!check net" 

prepare() {
    git config --global user.email "you@example.com" r
    git config --global user.name "Your Name" 
    sdkver="${pkgver}_${_pkgrev}" 
    echo $sdkver
    # TODO maybe make init fast using this: https://android.googlesource.com/platform/sdk/+/refs/tags/android-14.0.0_r74/README.txt
    repo init -u https://android.googlesource.com/platform/manifest -b android-$sdkver --depth=1 </dev/null
    sed -i '/prebuilt/d' "$builddir"/.repo/manifests/default.xml
    while ! repo sync --current-branch -j"$(nproc)"; do
        echo "repo sync failed, retrying..." 
    done
}

build() {
    export TARGET_RELEASE=trunk
    BUILD_VARIANT='eng'
    export BUILD_NUMBER=${BUILD_VARIANT}."${sdkver}" 
    # needed, because otherwise conscrypt build will fail. ART and some other
    # dependencies need to be built from source.
    export ART_MODULE_BUILD_FROM_SOURCE=true
    export MODULE_BUILD_FROM_SOURCE=true
    echo "$BUILD_NUMBER" 

    cd src
    . build/envsetup.sh

    lunch sdk-$TARGET_RELEASE-$BUILD_VARIANT
    make -j"$(nproc)" sdk dist sdk_repo
}

package() {
    install -Dm755 "$srcdir"/build/dist/android-sdk_linux-x86-"$BUILD_VARIANT".zip "$pkgdir"/opt/android-sdk
}

The port has been tested to work on trisquel using this script:

#!/bin/env bash

# Source the PKGBUILD file
. APKBUILD

# Set environment variables
if [ -z "$pkgver" ] || [ -z "$_pkgrev" ]; then
    echo "Error: pkgver and/or _pkgrev not set in PKGBUILD" 
    exit 1
fi

# Check if required Ubuntu packages are available, install them if not
sudo apt-get update
for pkg in bison flex git gnupg gperf libx11-dev libxml2 libxslt1-dev libgl1-mesa-dev libncurses5-dev python3 repo rsync unzip openssh-client; do
    if ! dpkg -s $pkg &>/dev/null; then
        echo "Installing $pkg..." 
        sudo apt-get install -y $pkg
    fi
done

# Run the prepare, build, and package functions
prepare
build
package

# Save the SHA256 of the zip
sha256sum=$(sha256sum "$pkgdir"/opt/android-sdk/android-sdk_linux-x86-"$BUILD_VARIANT".zip | cut -d' ' -f1)
echo "SHA256 of android-sdk: $sha256sum" 
echo "$sha256sum" >android-sdk.sha256

Tooling:

We either write the cmake files by hand or to utilize Bear, a tool that generates a compilation database for clang tooling, to aid in the creation of the CMake files. Bear can generate a JSON compilation database during the build process when make is called, which will help us to port the build process to cmake, as the JSON complilation database will contain all the files, that where required for building the sdk

Next Steps:

  • Evaluate the feasibility of building the Android SDK with CMake
  • Create a merge request to integrate the CMake build system into the Android repository
  • Collaborate with the community to write the necessary CMake files

Help Wanted:

If you have experience with CMake and Android build systems, we would appreciate your help in writing the CMake files and integrating the new build system. Your contributions will be invaluable in helping us create a FOSS version of the Android SDK.

Replicant SDK

See ReplicantSDKUsage for more details about SDKs up to Replicant 4.2.

Updated by Liam H 21 days ago ยท 62 revisions

Also available in: PDF HTML TXT