Android Studio 3.0 RunTimeException - java

I've installed Android Studio 3.0 on VirtualBox, OS Lubuntu.
During making project, there is an exception:
Error:java.util.concurrent.ExecutionException: java.lang.RuntimeException: No server to serve request. Check logs for details.
Error:Execution failed for task ':app:mergeDebugResources'.
Error: java.util.concurrent.ExecutionException: java.lang.RuntimeException: No server to serve request. Check logs for details.
I've tried oracle-jdk8 and OpenJdk. The same promlem.

Not quite sure what your compile issue is, but regardless once you get past that you will more than likely run into the issue of not being able to run the Android Studio emulator with VirtualBox. Assuming you want to run the emulator my point being you may be wasting time trying to fix your issue. See the following old post Android emulator and virtualbox cannot run at same time.
Best to run Android Studio on your host machine.

I've been able to find the root cause: The error message means that Gradle cannot connect to some worker processes. In my case, the process was for 'aapt2'. Running 'ldd aapt2' indicated that some shared libraries were missing (mainly GLIBC). Since I'm using Docker based on Alpine Linux, it comes with a reduced GLIBC (glibc-musl). The solution was to simply install glibc.
Here is the complete Dockerfile for reference, although the missing libraries might be different for your distribution.
FROM openjdk:8-alpine
LABEL maintainer="Barry Lagerweij" \
maintainer.email="b.lagerweij#carepay.co.ke" \
description="Android Builder"
COPY android-packages /tmp/android-packages
RUN apk add --no-cache wget unzip ca-certificates \
&& wget -q -O /etc/apk/keys/sgerrand.rsa.pub https://raw.githubusercontent.com/sgerrand/alpine-pkg-glibc/master/sgerrand.rsa.pub \
&& wget -q -O /tmp/glibc.apk https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.26-r0/glibc-2.26-r0.apk \
&& wget -q -O /tmp/glibc-bin.apk https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.26-r0/glibc-bin-2.26-r0.apk \
&& apk add --no-cache /tmp/glibc.apk /tmp/glibc-bin.apk \
&& wget -q -O /tmp/android-tools.zip https://dl.google.com/android/repository/sdk-tools-linux-3859397.zip \
&& mkdir -p /tmp/android-sdk/licenses \
&& unzip /tmp/android-tools.zip -d /tmp/android-sdk \
&& rm /tmp/android-tools.zip \
&& echo "d56f5187479451eabf01fb78af6dfcb131a6481e" > /tmp/android-sdk/licenses/android-sdk-license \
&& echo "84831b9409646a918e30573bab4c9c91346d8abd" > /tmp/android-sdk/licenses/android-sdk-preview-license \
&& echo "d975f751698a77b662f1254ddbeed3901e976f5a" > /tmp/android-sdk/licenses/intel-android-extra-license \
&& mkdir ~/.android; echo "count=0" >> ~/.android/repositories.cfg \
&& /tmp/android-sdk/tools/bin/sdkmanager --package_file=/tmp/android-packages \
&& apk del wget unzip ca-certificates \
&& rm -rf /tmp/android-sdk/extras /tmp/android-sdk/tools/lib/x86 /tmp/android-sdk/tools/lib/monitor-* /tmp/glibc.apk /tmp/glibc-bin.apk /etc/apk/keys/sgerrand.rsa.pub
RUN mkdir /tmp/project \
&& echo "sdk.dir=/tmp/android-sdk" > /tmp/project/local.properties
ENV ANDROID_HOME /tmp/android-sdk
WORKDIR /tmp/project
I suggest you run 'ldd build-tools/26.0.2/aapt2' to see which libraries are missing from the OS.

I had this problem on lubuntu-32 bit. easiest solution is to use lubuntu-64 bit.

Related

cloudrun failing with find_vma failed

my dockerfile for cloud run is as below.
FROM alpine:3.10.5
USER root
RUN apk update \
&& apk upgrade \
&& apk add --no-cache bash \
&& apk add --no-cache --virtual=build-dependencies unzip \
&& apk add --no-cache curl \
&& apk add --no-cache openjdk8-jre
RUN apk add --no-cache python3 \
&& python3 -m ensurepip \
&& pip3 install --upgrade pip setuptools wheel \
&& rm -r /usr/lib/python*/ensurepip && \
if [ ! -e /usr/bin/pip ]; then ln -s pip3 /usr/bin/pip ; fi && \
if [[ ! -e /usr/bin/python ]]; then ln -sf /usr/bin/python3 /usr/bin/python; fi
WORKDIR /opt/bin
RUN pip install Flask 'gunicorn>=20.0.1,<21' sqlalchemy pg8000 logger
COPY <some jar files>.jar /opt/bin/
COPY *.py /opt/bin/
RUN rm -r /root/.cache
CMD exec gunicorn --bind :$PORT --workers 2 --threads 8 --worker-tmp-dir /dev/shm --timeout 30 http_test
when I run the docker image on cloudrun, i get the following error when I send a GET request to the URL given by Cloudrun:
020-05-04 13:22:14.551 ISTContainer Sandbox: Unsupported syscall membarrier(0x10,0x0,0x0,0x8,0x3e57651d89a0,0x3e57651d8a30). It is very likely that you can safely ignore this message and that this is not the cause of any error you might be troubleshooting. Please, refer to https://gvisor.dev/c/linux/amd64/membarrier for more information.
2020-05-04 13:22:14.603 ISTOpenJDK 64-Bit Server VM warning: Can't detect primordial thread stack location - find_vma failed
Have tried different alpine images, switched to gunicorn20.0.1 to avoid libc issues, no avail. Any suggestions, help would be much appreciated.
while deploying the docker image in cloud run change the Execution environment to the second generation
Second generation PREVIEW
File system access, full Linux compatibility, faster performance.
had the same issue and I have fixed it, Hope it helps.

Dockerfile & installation -> Package 'openjdk-8-jre-headless' has no installation candidate

I'm trying to install openjdk-8-jre vie DockerFile, as I build the docker images for my composer. But I'm hitting this error message.
Error message:
Package openjdk-8-jre-headless is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
E: Package 'openjdk-8-jre-headless' has no installation candidate
Here is the part from Dockerfile:
# Install openjdk and java cacerts
RUN apt-get update && apt-get install -y openjdk-8-jre-headless ca-certificates-java
If I install java directly from the console, by using exact same command without RUN, no problem with the package. But as I try installing it from the Dockerfile, I hit the error. I have understood that Docker uses same repos as the machine where docker is running? Ubuntu is version 16.04.
Or how I check available installation packages on Dockerfile? java - v gives an error..
Seems like you are using FROM python:3.8 as base and as mentioned by #masseyb in the comment under your question it does not have openjdk-8jre-headless package.
This may help you.
FROM python:3.7-alpine as base
RUN apk update \
&& apk upgrade \
&& apk add --no-cache bash \
&& apk add --no-cache --virtual=build-dependencies unzip \
&& apk add --no-cache curl \
&& apk add --no-cache openjdk8-jre
RUN apk add --no-cache python3 \
&& python3 -m ensurepip \
&& pip3 install --upgrade pip setuptools \
&& rm -r /usr/lib/python*/ensurepip && \
if [ ! -e /usr/bin/pip ]; then ln -s pip3 /usr/bin/pip ; fi && \
if [[ ! -e /usr/bin/python ]]; then ln -sf /usr/bin/python3 /usr/bin/python; fi && \
rm -r /root/.cache
RUN pip install --trusted-host pypi.python.org flask
This example Dockerfile can get you Java python and flask

How can I set up and run a very simple php-apache server in a docker container that's already using another image?

I'm tasked with creating a very simple, web browser accessible gui that can run a specific java file within a docker container. To do this I've chosen to set up a php-apache server that serves an index.php document with the gui. The Dockerfile looks like this:
FROM php:7.0-apache
COPY src /var/www/html
EXPOSE 80
This gets the gui (index.php is inside the src folder) I've written up and running no problem, but it cannot access and run the required java files (obviously, since this creates a separate container).
The Question:
How can I set up a php-apache server inside the existing Dockerfile (provided below) doing the same thing as the Dockerfile above? My aim is to run the java file using php scripts and display the result to the user.
FROM openjdk:8-jre-slim
WORKDIR /usr/src/app
COPY ["./build/libs/*.jar", "./fooBar.jar"]
ENV JAVA_OPTS=${FOO_JAVA_OPTS}
CMD ["/usr/bin/tail", "-f", "/dev/null"]
I have not written the java file myself, only being tasked with running specific commands using it.
As it is Debian based images. one way of doing it, install packages in the container and create the new images from that.
root#310c94d8d75f:/usr/src/app# cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 9 (stretch)"
NAME="Debian GNU/Linux"
VERSION_ID="9"
VERSION="9 (stretch)"
2: root#310c94d8d75f:/usr/src/app# apt update
3- root#310c94d8d75f:/usr/src/app# apt install apache2
4- root#310c94d8d75f:/usr/src/app# apt install php
finally run : docker commit
after this, you will get a new image with the mentioned name.
Ref: https://docs.docker.com/engine/reference/commandline/commit/
2: you can add the same command in Dockerfile and rebuild.
FROM openjdk:8-jre-slim
WORKDIR /usr/src/app
COPY ["./build/libs/*.jar", "./fooBar.jar"]
ENV JAVA_OPTS=${FOO_JAVA_OPTS}
CMD ["/usr/bin/tail", "-f", "/dev/null"]
RUN apt update && apt install apache2 -y && apt install php -y
There appears to be no easy way of merging images like I initially hoped (You cannot have multiple FROM statements in your Dockerfile). What I eventually ended up doing was to manually merge the two images (openjdk and php) into something like this:
FROM php:7.0-apache
ENV LANG C.UTF-8
RUN { \
echo '#!/bin/sh'; \
echo 'set -e'; \
echo; \
echo 'dirname "$(dirname "$(readlink -f "$(which javac || which java)")")"'; \
} > /usr/local/bin/docker-java-home \
&& chmod +x /usr/local/bin/docker-java-home
RUN ln -svT "/usr/lib/jvm/java-8-openjdk-$(dpkg --print-architecture)" /docker-java-home
ENV JAVA_HOME /docker-java-home/jre
ENV JAVA_VERSION 8u212
ENV JAVA_DEBIAN_VERSION 8u212-b01-1~deb9u1
RUN set -ex; \
if [ ! -d /usr/share/man/man1 ]; then \
mkdir -p /usr/share/man/man1; \
fi; \
apt-get update; \
apt-get install -y --no-install-recommends openjdk-8-jre-headless="$JAVA_DEBIAN_VERSION"; \
rm -rf /var/lib/apt/lists/*; \
[ "$(readlink -f "$JAVA_HOME")" = "$(docker-java-home)" ]; \
update-alternatives --get-selections | awk -v home="$(readlink -f "$JAVA_HOME")" 'index($3, home) == 1 { $2 = "manual"; print | "update-alternatives --set-selections" }'; \
update-alternatives --query java | grep -q 'Status: manual'
COPY ["./build/libs/*.jar", "./FooBar.jar"]
ENV JAVA_OPTS=${FOO_JAVA_OPTS}
COPY gui/src /var/www/html
EXPOSE 80
Both are Debian based images so the merging were relatively easy (I also removed much of the cluttering comments from the original image source) and since the openjdk image were simpler, I added it on top of the php image instead of the other way around.

Check if Onion URL is live

I am making an Android application in Java. There is an onion Url that I want to check is live or not. Basically, Onion Url is mapped to an IP-address, so is there any Java library or API that can assist in determining this check?
Any help in this regard will be appreciated.
Thanks.
You need to have a server on which the tor will work and already give from it either the desired status or the page that you need. For the site tor-sites.link we did the proxying of the tor through the tor launched into the container and the express.js server. You can see how it works at previewer. Schematically, it looks like this:
HTTP request
express.js server
request to tor
returning a response to the client
This way you can get data from the onino site.
Dockerfile:
FROM node:slim
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD true
RUN apt-get update && apt-get install gnupg wget -y && \
wget --quiet --output-document=- https://dl-ssl.google.com/linux/linux_signing_key.pub | gpg --dearmor > /etc/apt/trusted.gpg.d/google-archive.gpg && \
sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' && \
apt-get update && \
apt-get install google-chrome-stable -y --no-install-recommends && \
apt-get install tor -y --no-install-recommends && \
apt-get install torsocks -y --no-install-recommends && \
apt-get install curl gnupg && \
rm -rf /var/lib/apt/lists/*
WORKDIR /usr/src/app
RUN mkdir src
RUN mkdir tmp
COPY ./src ./src
COPY ./package.json \
./ecosystem.config.js \
./tsconfig.json \
./
RUN npm i -g pm2 npm#9.2.0
RUN yarn && yarn build
RUN rm -rf src
#HEALTHCHECK --start-period=150s --interval=300s --retries=99999 --timeout=120s CMD curl --fail http://localhost:3000/healthcheck || kill 1
EXPOSE 3000
CMD ["pm2-runtime", "start", "ecosystem.config.js"]

Docker alpine + oracle java: cannot find java

I've been trying to create an alpine-based docker image with Oracle Java (rather than openjdk). I have been specifically asked to create our own image here.
This is the Dockerfile I've come up with:
FROM alpine:3.6
RUN apk add --no-cache curl wget
RUN mkdir /opt/ && \
wget -c --header "Cookie: oraclelicense=accept-securebackup-cookie"\
http://download.oracle.com/otn-pub/java/jdk/8u131-b11/d54c1d3a095b4ff2b6607d096fa80163/jdk-8u131-linux-x64.tar.gz && \
tar xvf jdk-8u131-linux-x64.tar.gz -C /opt/ && \
rm jdk-8u131-linux-x64.tar.gz && \
ln -s /opt/jdk1.8.0_131 /opt/jdk
ENV JAVA_HOME /opt/jdk
ENV PATH $PATH:/opt/jdk/bin
RUN echo $JAVA_HOME && \
echo $PATH
RUN which java
RUN java -version
There are some unnecessary commands (like echoing the JAVA_HOME dir) which were added to help with debugging, but now I'm stuck: RUN which java returns /opt/jdk/bin/java as expected, but RUN java -version returns /bin/sh: java: not found.
I've tried a few things, including symlinking the executable(s) into /usr/bin, to no avail.
What am I missing?
EDIT:
Final output from docker is:
The command '/bin/sh -c java -version' returned a non-zero code: 127
Final edit:
Thanks to diginoise for putting me on to MUSL vs libc. I found adding the following to my Dockerfile allowed me to build a working image:
RUN apk --no-cache add ca-certificates && \
wget -q -O /etc/apk/keys/sgerrand.rsa.pub https://raw.githubusercontent.com/sgerrand/alpine-pkg-glibc/master/sgerrand.rsa.pub && \
wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.25-r0/glibc-2.25-r0.apk && \
apk add glibc-2.25-r0.apk
Found at: https://github.com/sgerrand/alpine-pkg-glibc
You cannot achieve what you want
Alpine Linux uses MUSL as a Standard C library.
Oracle's Java for linux depends on GNU Standard C library (gclib).
Here is a bit more detailed info and official stance from Oracle on the topic
the JDK source code has not yet been ported to Alpine Linux, or more specifically, the musl C library. That is, it turns out that the thing about Alpine Linux that sticks out/is different from a JDK source code perspective is the C library.
The solution
If you looking for small Java Docker images, use OpenJDK ones.
openjdk:11-jre-slim image is only 77MB.
If you insist, on your head be it...
There is theoretical way, but it is not as trivial as you think.
You can find many examples of Alpine images running with OracleJDK like here or see expert's answer to this question as well.
They add the missing Standard GNU C library.
Be warned however...
All of these solutions could be in breach of Oracle's license agreement stating that the license is non-transferable, and the distributable is non-modifiable.
In the Dockerfiles you will find however:
Cookie: oraclelicense=accept-securebackup-cookie"
and many entries similar to
rm -rf ${JAVA_HOME}/*src.zip
For further details about legality of prepackaged Oracle's JRE or JDK Docker images see this article.
In case anyone needs fresh version of JDK I maintain Alpine Oracle JDK images https://hub.docker.com/r/expert/docker-java-minimal
Sources
https://github.com/unoexperto/docker-java-minimal/
I found an answer that works finally. All is needed is just the GlibC; huge thanks to S. Gerrand, this is such a big help.
Here's how to get the old JDK 8 running in Alpine 1.13:
FROM alpine:3.13
RUN apk --no-progress --purge --no-cache upgrade \
&& apk --no-progress --purge --no-cache add --upgrade \
curl \
wget \
openssh \
&& apk --no-progress --purge --no-cache upgrade \
&& rm -vrf /var/cache/apk/* \
&& curl --version
# Install vanilla GLibC: https://github.com/sgerrand/alpine-pkg-glibc
RUN curl -o /etc/apk/keys/sgerrand.rsa.pub https://alpine-pkgs.sgerrand.com/sgerrand.rsa.pub \
&& curl -LO https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.32-r0/glibc-2.32-r0.apk \
&& apk add glibc-2.32-r0.apk
RUN wget -c --header "Cookie: oraclelicense=accept-securebackup-cookie" \
http://download.oracle.com/otn-pub/java/jdk/8u131-b11/d54c1d3a095b4ff2b6607d096fa80163/jdk-8u131-linux-x64.tar.gz \
&& tar xvf jdk-8u131-linux-x64.tar.gz -C /opt \
&& rm jdk-8u131-linux-x64.tar.gz \
&& ln -s /opt/jdk1.8.0_131 /opt/jdk
ENV JAVA_HOME /opt/jdk
ENV PATH $PATH:/opt/jdk/bin
RUN echo $JAVA_HOME && \
echo $PATH
RUN which java
RUN java -version
ENTRYPOINT [ "java" ]
# To test run: docker run -t khalifahks/alpine-java -version
# docker export <container-id> | docker import - khalifahks/alpine-java:exported
# quick interative termnal: docker run -it --entrypoint=sh khalifahks/alpine-java sh

Categories

Resources