dotnet / android

.NET for Android provides open-source bindings of the Android SDK for use with .NET managed languages such as C#
MIT License
1.93k stars 530 forks source link

[build] make all in xamarin-android repo produce an error ```MSB3073: The command ""/root/android-toolchain/jdk-17/bin/javac" src/test/resources/com/microsoft/android/Outer.java" exited with code 1``` #8586

Open makeProjectGreatAgain opened 11 months ago

makeProjectGreatAgain commented 11 months ago

Android application type

.NET Android (net7.0-android, net8.0-android, etc.)

Affected platform version

debian:bookworm-slim, NET 8.0

Description

The command make prepare works ok.
However, when commands make or make jenkins ALL_HOST_ABIS="$(uname)" ALL_AOT_ABIS="" are executed they display an error:  error MSB3073: The command ""/root/android-toolchain/jdk-17/bin/javac" src/test/resources/com/microsoft/android/Outer.java" exited with code 1.  

Steps to Reproduce

  1. use fresh debian:bookworm-slim
  2. clone the xamarin-android repo ( last commit for now is 4eb515499d623fd26b636d95db95f241c696f2f4)
  3. install all necessary dependencies mentioned in dependecies.md
  4. make prepare
  5. make or make jenkins ALL_HOST_ABIS="`uname`" ALL_AOT_ABIS=""

Reproduce via Dockerfile

Another way to reproduce the issue is to use Dockerfile below (it is feasible to attach to a container and debug the build inside the container with Visual Studio Code):

FROM debian:bookworm-slim AS xamarin-android

ARG DOTNET_SDK_VERSION="8.0"
ARG TZ="UTC"
ENV TZ=${TZ}

# to avoid "failed to fetch" errors during apt update ...
RUN echo 'Acquire::http::Timeout "900";\nAcquire::ftp::Timeout "900";\nAcquire::Retries "10";\nAcquire::Queue-Mode "access";' > /etc/apt/apt.conf.d/99timeout

RUN apt-get update \
    && apt-get install -y --no-install-recommends \
        ca-certificates \
        curl \
        git \
        wget \
    && rm -rf /var/lib/apt/lists/*

RUN apt-get update && apt-get install -y --fix-missing \
    libncurses-dev \
    autoconf \
    autotools-dev \
    automake \
    ccache \
    cmake \
    build-essential \
    cli-common-dev \
    curl \
    devscripts \
    gcc \
    g++ \
    git \
    libtool \
    linux-libc-dev \
    make \
    ninja-build \
    p7zip-full \
    sqlite3 \
    vim-common \
    zlib1g-dev \
    lib32stdc++6 \
    lib32z1 \
    libtool-bin \
    libncurses5-dev \
    && rm -rf /var/lib/apt/lists/*

RUN <<EOF
    set -e
    wget https://packages.microsoft.com/config/debian/11/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
    dpkg -i packages-microsoft-prod.deb
    rm packages-microsoft-prod.deb
    apt-get update
    apt-get install -y dotnet-sdk-${DOTNET_SDK_VERSION}
    rm -rf /var/lib/apt/lists/*
EOF

RUN <<EOF
    set -e
    git clone https://github.com/xamarin/xamarin-android.git
    cd xamarin-android
    make prepare
    # make # produce an error: "The command ""/root/android-toolchain/jdk-17/bin/javac" src/test/resources/com/microsoft/android/Outer.java" exited with code 1."
EOF

Commands to run inside container:

cd xamarin-android
make

(make prepare already applied)

Did you find any workaround?

No

Relevant log output

"/xamarin-android/Xamarin.Android.sln" (default target) (1:2) ->
       "/xamarin-android/external/Java.Interop/tools/java-source-utils/java-source-utils.csproj" (default target) (50:8) ->
       (_CompileTestResources target) ->
         /xamarin-android/external/Java.Interop/tools/java-source-utils/java-source-utils.targets(51,5): error MSB3073: The command ""/root/android-toolchain/jdk-17/bin/javac" src/test/resources/com/microsoft/android/Outer.java" exited with code 1. [/xamarin-android/external/Java.Interop/tools/java-source-utils/java-source-utils.csproj]

    466 Warning(s)
    1 Error(s)
jonathanpeppers commented 11 months ago

error MSB3073: The command ""/root/android-toolchain/jdk-17/bin/javac" src/test/resources/com/microsoft/android/Outer.java" exited with code 1.

Can you share a .binlog of the build failure? We need to see the stdout/stderr output of javac.

You could just try building this one project that failed (add -bl to get an msbuild.binlog).

makeProjectGreatAgain commented 11 months ago

Can you share a .binlog of the build failure? We need to see the stdout/stderr output of javac. You could just try building this one project that failed (add -bl to get an msbuild.binlog).

msbuild.binlog.zip

cd /xamarin-android/external/Java.Interop/tools/java-source-utils
dotnet build -bl  
jonathanpeppers commented 11 months ago

Hmm, weird?

    src/test/resources/com/microsoft/android/Outer.java:42: error: unmappable character (0xE2) for encoding US-ASCII
         * Just an example annotation, for use later???
                                                    ^
    src/test/resources/com/microsoft/android/Outer.java:42: error: unmappable character (0x80) for encoding US-ASCII
         * Just an example annotation, for use later???
                                                     ^
    src/test/resources/com/microsoft/android/Outer.java:42: error: unmappable character (0xA6) for encoding US-ASCII
         * Just an example annotation, for use later???
                                                      ^

Maybe @grendello or @jonpryor would know what would cause this on Linux, but I think Java expects these files to be utf8 without a byte-order mark?