Reputation: 1
I've been working on this issue for awhile now. Following this tutorial: https://www.youtube.com/watch?v=46g4x9Z-xxQ
I got the basic remote container running with just the simple default app, but when I use my own code it gives me incompatitble java version issues.
main issue: Flutter Fix
Dockerfile:
FROM ubuntu:20.04
ENV UID=1000
ENV GID=1000
ENV USER="developer"
ENV JAVA_VERSION="11"
ENV ANDROID_TOOLS_URL="https://dl.google.com/android/repository/commandlinetools-linux-6858069_latest.zip"
ENV ANDROID_VERSION="29"
ENV ANDROID_BUILD_TOOLS_VERSION="29.0.3"
ENV ANDROID_ARCHITECTURE="x86_64"
ENV ANDROID_SDK_ROOT="/home/$USER/android"
ENV FLUTTER_CHANNEL="dev"
ENV FLUTTER_VERSION="2.3.0-16.0.pre"
ENV FLUTTER_URL="https://storage.googleapis.com/flutter_infra/releases/$FLUTTER_CHANNEL/linux/flutter_linux_$FLUTTER_VERSION-$FLUTTER_CHANNEL.tar.xz"
ENV FLUTTER_HOME="/home/$USER/flutter"
ENV FLUTTER_WEB_PORT="8090"
ENV FLUTTER_DEBUG_PORT="42000"
ENV FLUTTER_EMULATOR_NAME="flutter_emulator"
ENV PATH="$ANDROID_SDK_ROOT/cmdline-tools/tools/bin:$ANDROID_SDK_ROOT/emulator:$ANDROID_SDK_ROOT/platform-tools:$ANDROID_SDK_ROOT/platforms:$FLUTTER_HOME/bin:$PATH"
# install all dependencies
ENV DEBIAN_FRONTEND="noninteractive"
RUN apt-get update \
&& apt-get install --yes --no-install-recommends openjdk-$JAVA_VERSION-jdk curl unzip sed git bash xz-utils libglvnd0 ssh xauth x11-xserver-utils libpulse0 libxcomposite1 libgl1-mesa-glx sudo \
&& rm -rf /var/lib/{apt,dpkg,cache,log}
# create user
RUN groupadd --gid $GID $USER \
&& useradd -s /bin/bash --uid $UID --gid $GID -m $USER \
&& echo $USER ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USER \
&& chmod 0440 /etc/sudoers.d/$USER
USER $USER
WORKDIR /home/$USER
# android sdk
RUN mkdir -p $ANDROID_SDK_ROOT \
&& mkdir -p /home/$USER/.android \
&& touch /home/$USER/.android/repositories.cfg \
&& curl -o android_tools.zip $ANDROID_TOOLS_URL \
&& unzip -qq -d "$ANDROID_SDK_ROOT" android_tools.zip \
&& rm android_tools.zip \
&& mkdir -p $ANDROID_SDK_ROOT/cmdline-tools/tools \
&& mv $ANDROID_SDK_ROOT/cmdline-tools/bin $ANDROID_SDK_ROOT/cmdline-tools/tools \
&& mv $ANDROID_SDK_ROOT/cmdline-tools/lib $ANDROID_SDK_ROOT/cmdline-tools/tools \
&& yes "y" | sdkmanager "build-tools;$ANDROID_BUILD_TOOLS_VERSION" \
&& yes "y" | sdkmanager "platforms;android-$ANDROID_VERSION" \
&& yes "y" | sdkmanager "platform-tools" \
&& yes "y" | sdkmanager "emulator" \
&& yes "y" | sdkmanager "system-images;android-$ANDROID_VERSION;google_apis_playstore;$ANDROID_ARCHITECTURE"
# flutter
RUN curl -o flutter.tar.xz $FLUTTER_URL \
&& mkdir -p $FLUTTER_HOME \
&& tar xf flutter.tar.xz -C /home/$USER \
&& rm flutter.tar.xz \
&& flutter config --no-analytics --enable-web \
&& flutter precache \
&& yes "y" | flutter doctor --android-licenses \
&& flutter doctor \
&& flutter emulators --create \
&& flutter update-packages
COPY entrypoint.sh /usr/local/bin/
COPY chown.sh /usr/local/bin/
COPY flutter-android-emulator.sh /usr/local/bin/flutter-android-emulator
COPY flutter-web.sh /usr/local/bin/flutter-web
ENTRYPOINT [ "/usr/local/bin/entrypoint.sh" ]
devcontainer.json
{
"name": "Flutter",
"image": "matspfeiffer/flutter",
"customizations": {
"extensions": ["dart-code.dart-code", "dart-code.flutter"]
}
}
I tried updating the java version to 11 but it still doesn't compile(was previously 8). also had to run flutter upgrade bc of incompatible dart sdk versions.
also tried running flutter doctor --android-licenses but it's saying sdk manager is not found.
I've been working on this for awhile and have no documentation on any help
any help would be greatly appreciated!
Upvotes: 0
Views: 94