Background: On Debian and Ubuntu, it's possible to install freely licensed Android SDKs that are compiled from source by running apt install android-sdk
, which apparently don't come with a restrictive EULA. There's a flutter
package in the Snap Store, but I decided to use the compiled version from the flutter.dev website for now.
I would like to use Ubuntu's freely licensed Android SDKs to compile a Flutter app for Android, but the build process is failing with the Flutter demo app.
$ sudo apt install android-sdk \
android-sdk-build-tools \
android-sdk-platform-tools \
android-sdk-helper \
android-sdk-platform-23
$ flutter config --android-sdk /usr/lib/android-sdk/
The following command prints warnings:
andrew@mercury:~$ flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.13.0, on Ubuntu 23.04 6.2.0-27-generic, locale
en_US.UTF-8)
[!] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
✗ cmdline-tools component is missing
Run `path/to/sdkmanager --install "cmdline-tools;latest"`
See https://developer.android.com/studio/command-line for more details.
✗ Android license status unknown.
Run `flutter doctor --android-licenses` to accept the SDK licenses.
See https://flutter.dev/docs/get-started/install/linux#android-setup for
more details.
[✓] Chrome - develop for the web
[✓] Linux toolchain - develop for Linux desktop
[!] Android Studio (not installed)
[✓] Connected device (2 available)
[✓] Network resources
! Doctor found issues in 2 categories.
I set the SDK version for android builds to a static version number to match the SDK version in Ubuntu: 28
(or is it 23
?).
The flutter build apk
command fails after adding > 1 GB of data to ~/.gradle
:
andrew@mercury:~/src$ flutter create demo && cd demo
...
andrew@mercury:~/src/demo$ flutter build apk
Checking the license for package Android SDK Build-Tools 30.0.3 in /usr/lib/android-sdk/licenses
Warning: License for package Android SDK Build-Tools 30.0.3 not accepted.
Checking the license for package Android SDK Platform 33 in /usr/lib/android-sdk/licenses
Warning: License for package Android SDK Platform 33 not accepted.
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine the dependencies of task ':app:lintVitalReportRelease'.
> Failed to install the following Android SDK packages as some licences have not been accepted.
platforms;android-33 Android SDK Platform 33
build-tools;30.0.3 Android SDK Build-Tools 30.0.3
To build this project, accept the SDK license agreements and install the missing components using the Android Studio SDK Manager.
All licenses can be accepted using the sdkmanager command line tool:
sdkmanager.bat --licenses
Or, to transfer the license agreements from one workstation to another, see https://developer.android.com/studio/intro/update.html#download-with-gradle
Using Android SDK: /usr/lib/android-sdk
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 1m 16s
Running Gradle task 'assembleRelease'... 76.6s
Gradle task assembleRelease failed with exit code 1
I know that F-Droid contains Flutter-based apps, so there must be a way to compile for Android using the free software Android SDKs. How can I do this too?
Update: Someone on the F-Droid forum said that the Android SDKs they use are not FOSS.