Project

General

Profile

SDK » History » Version 62

Liam H, 09/24/2024 10:05 AM
update the links and write progress report

1 1 John Smith
h1. SDK
2
3 58 Denis 'GNUtoo' Carikli
{{toc}}
4 1 John Smith
5 58 Denis 'GNUtoo' Carikli
h2. Introduction
6 1 John Smith
7 58 Denis 'GNUtoo' Carikli
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.
8 1 John Smith
9 58 Denis 'GNUtoo' Carikli
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.
10 1 John Smith
11 58 Denis 'GNUtoo' Carikli
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":https://blog.replicant.us/2017/04/there-wont-be-a-replicant-6-0-sdk-because-there-is-already-something-better/ has more details about this choice.
12 1 John Smith
13 61 Denis 'GNUtoo' Carikli
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#section-7]] 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.
14 1 John Smith
15 58 Denis 'GNUtoo' Carikli
h2. GNU/Linux distributions
16 56 Denis 'GNUtoo' Carikli
17 58 Denis 'GNUtoo' Carikli
The following FSF certified distributions have Android SDKs:
18 1 John Smith
19 59 Denis 'GNUtoo' Carikli
| Distribution          | Gradle version  | Android versions   |
20
| PureOS 9 (amber)      | 4.4.1           | 6.0 (API Level 23) |
21
| PureOS 10 (byzantium) | 4.4.1           | 6.0 (API Level 23) |
22
| Trisquel 9 (etiona)   | 3.4.1           | 6.0 (API Level 23) |
23
| Trisquel 10 (nabia)   | 4.4.1           | 6.0 (API Level 23) |
24 17 John Smith
25 58 Denis 'GNUtoo' Carikli
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.
26 18 John Smith
27 58 Denis 'GNUtoo' Carikli
The following distributions are also known to have an Android SDK:
28
| Distribution         | Gradle version  | Android versions   |
29
| Debian  9 (stretch)  | 3.2.1           | 6.0 (API Level 23) |
30
| Debian 10 (buster)   |                 |                    |
31
| Debian 11 (bullseye) | 4.4.1           | 6.0 (API Level 23) |
32 20 John Smith
33 58 Denis 'GNUtoo' Carikli
The [[F-DroidAndApplications]] wiki page also has information on attempts to build Android packages with these SDKs.
34 20 John Smith
35 58 Denis 'GNUtoo' Carikli
h2. Attempts to go further than Android 6.0
36 21 John Smith
37 58 Denis 'GNUtoo' Carikli
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 2021[1]. 
38 22 John Smith
39 58 Denis 'GNUtoo' Carikli
That project also lacked a license. That led "another project by wchen342":https://github.com/wchen342/android-rebuilds to restart from scratch. 
40 22 John Smith
41 58 Denis 'GNUtoo' Carikli
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.
42 23 John Smith
43 58 Denis 'GNUtoo' Carikli
F-Droid also has a "forum post":https://forum.f-droid.org/t/call-for-help-making-free-software-builds-of-the-android-sdk/4685 that asks for help with that as they currently rely on the nonfree SDKs and they want to fix that.
44 24 John Smith
45 58 Denis 'GNUtoo' Carikli
fn1. "Android Rebuilds, how to rebuild SDK/NDK, precisely, without non-free EULA (2015-2021)" on https://www.beuc.net/
46 24 John Smith
47 62 Liam H
h2. WIP Report: FOSS Android SDK Build
48
49
**Current Status:**
50
51
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.
52
53
**New Approach:**
54
55
We have found an unofficial CMake-based build system for Android command line utilities called "android-tools":https://github.com/nmeum/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.
56
57
**Call for Help:**
58
59
We are seeking assistance in writing the necessary CMake files to support this new build system. Specifically, we are looking for help with:
60
61
* Creating CMake files for the Android SDK build process
62
* Integrating the CMake build system with the existing Android repository
63
64
h5. APKBUILD for alpine linux
65
Port the android 14 sdk to alpine linux and arch linux
66
67
<pre><code class="shell">
68
pkgname=android-sdk
69
pkgver=14.0.0
70
_pkgrev=r74
71
pkgrel=0
72
pkgdesc="android sdk without google binaries"
73
url="https://git.replicant.us/contrib/wizzard/Android/SDK-Rebuild"
74
arch="all"
75
license="APACHE"
76
makedepends="
77
bison
78
flex
79
git
80
gnupg
81
gperf
82
libx11-static
83
libxml2
84
libxslt
85
mesa-dev
86
ncurses-static
87
python3
88
repo
89
rsync
90
unzip
91
openssh
92
bash
93
"
94
source=""
95
builddir="$srcdir/"
96
options="!check net"
97
98
prepare() {
99
	git config --global user.email "you@example.com" r
100
	git config --global user.name "Your Name"
101
	sdkver="${pkgver}_${_pkgrev}"
102
	echo $sdkver
103
	# TODO maybe make init fast using this: https://android.googlesource.com/platform/sdk/+/refs/tags/android-14.0.0_r74/README.txt
104
	repo init -u https://android.googlesource.com/platform/manifest -b android-$sdkver --depth=1 </dev/null
105
	sed -i '/prebuilt/d' "$builddir"/.repo/manifests/default.xml
106
	while ! repo sync --current-branch -j"$(nproc)"; do
107
		echo "repo sync failed, retrying..."
108
	done
109
}
110
111
build() {
112
	export TARGET_RELEASE=trunk
113
	BUILD_VARIANT='eng'
114
	export BUILD_NUMBER=${BUILD_VARIANT}."${sdkver}"
115
	# needed, because otherwise conscrypt build will fail. ART and some other
116
	# dependencies need to be built from source.
117
	export ART_MODULE_BUILD_FROM_SOURCE=true
118
	export MODULE_BUILD_FROM_SOURCE=true
119
	echo "$BUILD_NUMBER"
120
121
	cd src
122
	. build/envsetup.sh
123
124
	lunch sdk-$TARGET_RELEASE-$BUILD_VARIANT
125
	make -j"$(nproc)" sdk dist sdk_repo
126
}
127
128
package() {
129
	install -Dm755 "$srcdir"/build/dist/android-sdk_linux-x86-"$BUILD_VARIANT".zip "$pkgdir"/opt/android-sdk
130
}
131
</code></pre>
132
133
The port has been tested to work on trisquel using this script:
134
<pre><code class="shell">
135
#!/bin/env bash
136
137
# Source the PKGBUILD file
138
. APKBUILD
139
140
# Set environment variables
141
if [ -z "$pkgver" ] || [ -z "$_pkgrev" ]; then
142
	echo "Error: pkgver and/or _pkgrev not set in PKGBUILD"
143
	exit 1
144
fi
145
146
# Check if required Ubuntu packages are available, install them if not
147
sudo apt-get update
148
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
149
	if ! dpkg -s $pkg &>/dev/null; then
150
		echo "Installing $pkg..."
151
		sudo apt-get install -y $pkg
152
	fi
153
done
154
155
# Run the prepare, build, and package functions
156
prepare
157
build
158
package
159
160
# Save the SHA256 of the zip
161
sha256sum=$(sha256sum "$pkgdir"/opt/android-sdk/android-sdk_linux-x86-"$BUILD_VARIANT".zip | cut -d' ' -f1)
162
echo "SHA256 of android-sdk: $sha256sum"
163
echo "$sha256sum" >android-sdk.sha256
164
165
</code></pre>
166
167
168
169
**Tooling:**
170
171
We either write the cmake files by hand or to utilize "Bear":https://github.com/rizsotto/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
172
173
**Next Steps:**
174
175
* Evaluate the feasibility of building the Android SDK with CMake
176
* Create a merge request to integrate the CMake build system into the Android repository
177
* Collaborate with the community to write the necessary CMake files
178
179
**Help Wanted:**
180
181
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.
182
183
184
185 58 Denis 'GNUtoo' Carikli
h2. Replicant SDK
186 23 John Smith
187 58 Denis 'GNUtoo' Carikli
See [[ReplicantSDKUsage]] for more details about SDKs up to Replicant 4.2.