ge0rg / aprsdroid

APRSdroid - Geo-Location for Radio Amateurs
https://aprsdroid.org/
GNU General Public License v2.0
504 stars 96 forks source link

Execution failed for task ':compileDebugScala'. #367

Closed na7q closed 5 months ago

na7q commented 6 months ago

Trying to compile and running into this issue. Running JDK14.0.2 and Gradle-6.3-all. Build wrapper is changed to distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-all.zip.

Being that there is virtually no real documentation on compiling I'm flying blind here. I did not install anything for Scala, as I only found one comment that says it's downloaded automatically. So then the question becomes what is this error related to?

Happens when running any of these..

./gradlew installDebug ./gradlew installRelease ./gradlew build

penguin359 commented 6 months ago

Don't try to bump version numbers. As the Scala plugin used it a bit old and currently unmaintained, things can break when versions are bumped. Stick with the original version of Gradle set in the source code and stick with JDK 1.8.x. To get a compatible version of Java on Ubuntu 22.04 LTS, I just installed the package provided by the distribution with this command:

sudo apt-get install -y openjdk-8-jdk

Second, make sure you've pulled in submodules for this project:

git submodule update --init --recursive

Otherwise, you might get an error like this one:

* What went wrong:
Execution failed for task ':compileDebugScala'.
> Couldn't follow symbolic link '/home/user/aprsdroid/src/AudioBufferProcessor.java'.

Third, as I recall, the build expects the API Key to be filled in or it can fail. You can get a free, developer key to use, but as a stop-gap to just compile, fill it in with any random value:

echo "mapsApiKey=a" > local.properties

I just did a clean-room build from Git inside a fresh Ubuntu container and was able to build without issue. After I clean up the instructions, I can attach them here for reference.

penguin359 commented 6 months ago

Here is the exact transcript I used to build aprsdroid from a scratch environment. I used Docker to ensure I was working from a completely fresh Ubuntu 22.04, however, there is no requirement that this be done in Docker or with Ubuntu Linux as long as you have the correct Android build environment installed. First, I started a new, blank Ubuntu container:

docker container run -it --name=android ubuntu:22.04

As the default Ubuntu container does not create a regular user, I added one to avoid running as root:

apt-get update && apt-get install -y sudo
useradd -m -s /bin/bash -G sudo user
(echo user; echo user) | passwd user
sudo -u user -i

I then installed a few required programs from the Ubuntu package repository:

sudo apt-get install -y git openjdk-8-jdk vim-nox wget unzip

Then, I installed the Android SDK for API level 24. You can use whatever install method or graphical interface you want, but a completely automated set of instructions to do this on Linux are as follows:

cmdline_tool_file="commandlinetools-linux-6609375_latest.zip"
export ANDROID_SDK_ROOT="$(pwd)/android"
mkdir -p "${ANDROID_SDK_ROOT}"
wget "https://dl.google.com/android/repository/${cmdline_tool_file}"
unzip "${cmdline_tool_file}" -d "${ANDROID_SDK_ROOT}/cmdline-tools"
rm -f "${cmdline_tool_file}"
export PATH="${ANDROID_SDK_ROOT}/cmdline-tools/tools/bin:${PATH}"
export PATH="${ANDROID_SDK_ROOT}/platform-tools:${PATH}"
export PATH="${ANDROID_SDK_ROOT}/emulator:${PATH}"
mkdir "${ANDROID_SDK_ROOT}/licenses"
echo 24333f8a63b6825ea9c5514f83c2829b004d1fee > "${ANDROID_SDK_ROOT}/licenses/android-sdk-license"
echo 84831b9409646a918e30573bab4c9c91346d8abd > "${ANDROID_SDK_ROOT}/licenses/android-sdk-preview-license"
sdkmanager --install emulator 'system-images;android-24;default;armeabi-v7a'

There's a lot there, but it's just the same procedure you might do from the normal installer of selecting which SDK components to install and accepting license agreements with clicks from your mouse. Once you have the SDK installed correctly with the environment variables set, then it's just cloning the repo, setting the API key, and building it:

git clone https://github.com/ge0rg/aprsdroid.git
cd aprsdroid/
git submodule update --init --recursive
echo "mapsApiKey=a" > local.properties

./gradlew assemble

This commands are all taken from a script I use regularly to do clean-room builds of aprsdroid from a scratch container so they should work as is to make a successful build.

na7q commented 5 months ago

You are a lifesaver! This works great! Thank you!!