OxygenCobalt / Auxio

A simple, rational music player for android
GNU General Public License v3.0
1.78k stars 117 forks source link

Auxio build fails at assembleFfmpeg on macOS #742

Closed unrenowned closed 1 month ago

unrenowned commented 2 months ago

Describe the Bug/Crash

When I try to build Auxio on macOS, Gradle fails at the task assembleFfmpeg.

Steps to Reproduce:

  1. Clone the Auxio repository on a macOS system
  2. Navigate to the repository and run ./gradlew assembleRelease

Describe the intended behavior

The task should succeed and produce an APK in app/build/outputs/apk/release.

What macOS version do you use?

macOS Sonoma 14.2.1

What device model do you use?

MacBook Air M1 2020

Logs

I've uploaded 2 logfiles:

  1. The output of ./gradlew assembleRelease --stacktrace: gradle-log.txt
  2. The logfile generated when you build decoder_ffmpeg: config.log

Let me know if you need more (or less) detail. I think the key portion is here (in config.log):

WARNING: /Users/[removed for privacy]/Library/Android/sdk/ndk/25.2.9519653/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi21-pkg-config not found, library detection may fail.
mktemp -u XXXXXX
9YImwz
test_ld cc
test_cc
BEGIN /var/folders/45/1wggmmf93997x_5s8qwp2xvw0000gp/T//ffconf.iRO1iKKL/test.c
    1   int main(void){ return 0; }
END /var/folders/45/1wggmmf93997x_5s8qwp2xvw0000gp/T//ffconf.iRO1iKKL/test.c
/Users/[removed for privacy]/Library/Android/sdk/ndk/25.2.9519653/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi21-clang -march=armv7-a -mfloat-abi=softfp -march=armv7-a -c -o /var/folders/45/1wggmmf93997x_5s8qwp2xvw0000gp/T//ffconf.iRO1iKKL/test.o /var/folders/45/1wggmmf93997x_5s8qwp2xvw0000gp/T//ffconf.iRO1iKKL/test.c
./configure: line 974: /Users/[removed for privacy]/Library/Android/sdk/ndk/25.2.9519653/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi21-clang: No such file or directory
C compiler test failed.

Duplicates

Possible Cause

It looks like assembleFfmpeg is looking for clang in the wrong place: on macOS the folder under prebuilt will be darwin-x86_64, not linux-x86_64. This might come from the OS check you added in your fork of media3:

def host = ""
if (Os.isFamily(Os.FAMILY_UNIX)) {
    host = "linux-x86_64"
} else if (Os.isFamily(Os.FAMILY_MAC)) {
    host = "darwin-x86_64"
} else {
    throw UnsupportedOperationException(
            "Building with Windows is not supported. " +
                    "Please use WSL or a unix-based operating system.")
}

Based on the Apache Ant documentation and some quick tests I did, it looks like Os.FAMILY_UNIX matches all Unix-like OSs, including macOS. So on macOS this conditional would set host to linux-x86_64 instead of the correct darwin-x86_64. When I swap the order of the Unix and Mac checks the build seems to run okay.

OxygenCobalt commented 1 month ago

Oh, what a stupid mistake! If you want to make a PR for this, that would be great @unrenowned!

unrenowned commented 1 month ago

Sounds good to me. I'll double check my fix doesn't break anything then open a PR in the media3 repo.