Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[windows] Docker APK build #1338

Open
kennardconsulting opened this issue Jul 22, 2019 · 33 comments
Open

[windows] Docker APK build #1338

kennardconsulting opened this issue Jul 22, 2019 · 33 comments
Labels
bug Something isn't working question Further information is requested

Comments

@kennardconsulting
Copy link

Describe the bug
I ran:

  • docker pull debian:latest
  • docker build -f android.Dockerfile -t exokit .
  • docker run exokit cat exokit.apk >exokit.apk

As instructed.

The full error log was:

Step 1/12 : FROM debian:latest
---> 00bf7fdd8baf
Step 2/12 : RUN apt-get update -y && apt-get install -y build-essential wget python git unzip default-jdk
---> Using cache
---> 84a026d7b00a
Step 3/12 : RUN groupadd -g 999 appuser && useradd -r -u 999 -g appuser appuser
---> Using cache
---> 0431fe293649
Step 4/12 : ENV HOME /home/appuser
---> Using cache
---> e03eb1e0a52e
Step 5/12 : ADD . $HOME/app
---> b8c07fba40aa
Step 6/12 : WORKDIR $HOME/app
---> Running in 0a86d0caa1f0
Removing intermediate container 0a86d0caa1f0
---> 5a17f368f268
Step 7/12 : RUN echo $HOME
---> Running in f81a11f8cf5e
/home/appuser
Removing intermediate container f81a11f8cf5e
---> fa9f3c4f46a9
Step 8/12 : RUN chown -R appuser:appuser $HOME && chmod -R 777 $HOME
---> Running in 32b96fb9fd76
Removing intermediate container 32b96fb9fd76
---> 32ff829c0b8a
Step 9/12 : USER appuser
---> Running in 80d2cdae055c
Removing intermediate container 80d2cdae055c
---> 0e3717eef25a
Step 10/12 : RUN wget "https://nodejs.org/dist/v11.6.0/node-v11.6.0-linux-x64.tar.gz" -O node.tar.gz -q && tar -zxf node.tar.gz > /dev/null && rm node.tar.gz && mv node-v11.6.0-linux-x64 node
---> Running in 2c028081b16a
Removing intermediate container 2c028081b16a
---> 0b58a7e3cf41
Step 11/12 : RUN wget https://dl.google.com/android/repository/sdk-tools-linux-4333796.zip -q && unzip sdk-tools-linux-4333796.zip > /dev/null && rm sdk-tools-linux-4333796.zip && mkdir android-sdk && export ANDROID_HOME=$(pwd)/android-sdk && mv tools android-sdk/tools && yes | $ANDROID_HOME/tools/bin/sdkmanager --licenses > /dev/null && $ANDROID_HOME/tools/bin/sdkmanager "platform-tools" "platforms;android-28" > /dev/null && $ANDROID_HOME/tools/bin/sdkmanager "ndk-bundle" > /dev/null && export PATH="$PATH:$(pwd)/node/bin" && scripts/make-toolchain-android.sh && scripts/build-android.sh
---> Running in ac614095cdca
Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema
at com.android.repository.api.SchemaModule$SchemaModuleVersion.(SchemaModule.java:156)
at com.android.repository.api.SchemaModule.(SchemaModule.java:75)
at com.android.sdklib.repository.AndroidSdkHandler.(AndroidSdkHandler.java:81)
at com.android.sdklib.tool.sdkmanager.SdkManagerCli.main(SdkManagerCli.java:73)
at com.android.sdklib.tool.sdkmanager.SdkManagerCli.main(SdkManagerCli.java:48)
Caused by: java.lang.ClassNotFoundException: javax.xml.bind.annotation.XmlSchema
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
... 5 more
The command '/bin/sh -c wget https://dl.google.com/android/repository/sdk-tools-linux-4333796.zip -q && unzip sdk-tools-linux-4333796.zip > /dev/null && rm sdk-tools-linux-4333796.zip && mkdir android-sdk && export ANDROID_HOME=$(pwd)/android-sdk && mv tools android-sdk/tools && yes | $ANDROID_HOME/tools/bin/sdkmanager --licenses > /dev/null && $ANDROID_HOME/tools/bin/sdkmanager "platform-tools" "platforms;android-28" > /dev/null && $ANDROID_HOME/tools/bin/sdkmanager "ndk-bundle" > /dev/null && export PATH="$PATH:$(pwd)/node/bin" && scripts/make-toolchain-android.sh && scripts/build-android.sh' returned a non-zero code: 1

@avaer
Copy link
Member

avaer commented Jul 22, 2019

Thanks Kennard,

Is this build using the latest code? We do not currently use debian:latest https://github.com/exokitxr/exokit/blob/master/android.Dockerfile#L1

@avaer avaer added bug Something isn't working question Further information is requested labels Jul 22, 2019
@kennardconsulting
Copy link
Author

Hi - thanks for your help.

Yes I downloaded the Windows EXE release and found docs/guides/exportOculusAPK.md in there. That's what I was following.

Should I just download github.com/exokitxr/exokit/archive/master.zip directly instead? If I do that, where can I find the docs/guides folder?

@avaer
Copy link
Member

avaer commented Jul 23, 2019

That documentation comes from old releases, which are out of date. That is why this documentation was removed in master.

The way we currently build is to run this script: https://github.com/exokitxr/exokit/blob/master/scripts/oculusmobile/build-android.sh

This is done on CI with the following Dockerfile environment: https://github.com/exokitxr/exokit/blob/master/android.Dockerfile

Other references from older code are likely to not work, because there has been an incompatible Debian version released in the last short while.

@kennardconsulting
Copy link
Author

Okay trying that we get:

the docker image was successful but the build it self had a problem

FAILURE: Build failed with an exception.

* What went wrong:
Gradle build daemon disappeared unexpectedly (it may have been killed or may have crashed)

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

Is that normal?

@avaer
Copy link
Member

avaer commented Jul 23, 2019

Yes that might indeed be working. The ci extracts the apk from the build here: https://github.com/exokitxr/exokit/blob/master/.travis.yml#L37

@kennardconsulting
Copy link
Author

Hmmm. APK fails to install (using SideQuest on Quest):

INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION: Failed to parse /data/app/vmdl244302174.tmp/base.apk: AndroidManifest.xml

@avaer
Copy link
Member

avaer commented Jul 23, 2019

Thanks, are you able to extract the apk (it is a zip file) and post the AndroidManifest.xml from inside of it?

@kennardconsulting
Copy link
Author

Thanks for sticking with me. I appreciate all your help. I actually can't seem to unzip the APK. I assume because it didn't build correctly (possibly because of the error I mentioned above). Would you like me to upload the whole APK somewhere? Do you have a built one I can try?

@avaer
Copy link
Member

avaer commented Jul 23, 2019

Sure, I can provide an APK if no frontend is needed and the intent is to access from ADB command line args.

@avaer
Copy link
Member

avaer commented Jul 23, 2019

Could you upload the built APK on your end somewhere like https://transfer.sh?

@kennardconsulting
Copy link
Author

@avaer
Copy link
Member

avaer commented Jul 23, 2019

Perfect, thank you!

@kennardconsulting
Copy link
Author

Yes I am happy to try running it from ADB command line args. How would I do that?

adb install -r ...my apk... ...some other magic that points to a URL...

Or something?

@avaer
Copy link
Member

avaer commented Jul 23, 2019

Here's the install script:

"$ANDROID_HOME/platform-tools/adb" install -r ./app/build/outputs/apk/debug/app-debug.apk

Additionally, all launches need to be via passing arguments to node:

# "$ANDROID_HOME/platform-tools/adb" shell am start -n com.webmr.exokit/android.app.NativeActivity -e ARGS "'node --inspect-brk /package /package/examples/tutorial.html'"

@avaer
Copy link
Member

avaer commented Jul 23, 2019

@kennardconsulting I managed to successfully build with Docker and extract with our existing scripts. I see that the APK provided was corrupted.

Can you provide the system setup you are using for Docker, and the full Docker log files? I'd like to understand why it's failing on that system.

@avaer
Copy link
Member

avaer commented Jul 23, 2019

Here is a master build APK from today: https://transfer.sh/ErXjp/app-debug.apk

Since this isn't a release, there are no guarantees or support.

@kennardconsulting
Copy link
Author

"Can you provide the system setup you are using for Docker, and the full Docker log files?"

Sure. Here is the Docker setup:

Display system-wide information
PS D:\downloads\exokit-master> docker info
Containers: 8
 Running: 1
 Paused: 0
 Stopped: 7
Images: 19
Server Version: 18.06.1-ce
Storage Driver: overlay2
 Backing Filesystem: extfs
 Supports d_type: true
 Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
 Volume: local
 Network: bridge host macvlan null overlay
 Log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 468a545b9edcd5932818eb9de8e72413e616e86e
runc version: 69663f0bd4b60df09991c08812a60108003fa340
init version: fec3683
Security Options:
 seccomp
  Profile: default
Kernel Version: 4.9.93-linuxkit-aufs
Operating System: Docker for Windows
OSType: linux
Architecture: x86_64
CPUs: 2
Total Memory: 1.934GiB
Name: linuxkit-00155d273609
ID: LZYC:2O42:3QUP:WAY5:VU4S:YN3F:KARV:OGO3:HTYI:6RFR:NZRS:KAAD
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): true
 File Descriptors: 35
 Goroutines: 68
 System Time: 2019-07-24T00:52:45.1941423Z
 EventsListeners: 1
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
 127.0.0.0/8
Live Restore Enabled: false

@kennardconsulting
Copy link
Author

Also this may be of interest:

image

@avaer
Copy link
Member

avaer commented Jul 24, 2019

I see, I suspect Windows does not support cat out of Docker; the APK posted was a corrupted zip but had the right size.

There are probably other ways to extract files out out of the Windows container, but we do all of our builds on Linux.

@kennardconsulting
Copy link
Author

Console log of (Windows) build:
log.txt

@chrislatorres
Copy link
Contributor

FAILURE: Build failed with an exception.

* What went wrong:
Gradle build daemon disappeared unexpectedly (it may have been killed or may have crashed)

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

It is possible that gradle is crashing here during the build. https://github.com/exokitxr/exokit/blob/master/scripts/oculusmobile/build-android.sh#L70

@avaer
Copy link
Member

avaer commented Jul 24, 2019

That's entirely possible. I don't have experience with the vagaries of Windows Docker and what resource limits it imposes.

I do know what gradle is resource intensive and prone to errors on unexpected file properties. If we end up supporting the build process, it probably won't include Docker on Windows.

@avaer
Copy link
Member

avaer commented Jul 24, 2019

The alternative might be to repurpose the android build script to run on windows and use the Android SDK native toolchain in something like Powershell.

Would welcome a PR that does this.

@kennardconsulting
Copy link
Author

Okay I was able to upload the APK you provided but I'm unclear how to run it with a website address? I tried:

adb shell am start -n com.webmr.exokit/android.app.NativeActivity -e ARGS "'node --inspect-brk https://webvr.info https://webvr.info/samples/03-vr-presentation.html'"
Starting: Intent { cmp=com.webmr.exokit/android.app.NativeActivity (has extras) }

But I just got a black screen inside the headset

@avaer
Copy link
Member

avaer commented Jul 24, 2019

You can check the logs with adb logcat.

@kennardconsulting
Copy link
Author

I see. But is that the correct syntax?

--inspect-brk <website domain> <website full address>

@avaer
Copy link
Member

avaer commented Jul 24, 2019

The arguments are passed straight through to node.

So those arguments will probably pause node and prevent anything from loading, due to --inspect-brk. The result will probably be an infinite black screen as experienced.

Additionally, there is not multiple arguments accepted for the domain/address. The first argument is the node main JS file to load, and the second argument is the URL passed to it.

@avaer avaer changed the title Latest exokit does not build (with docker) [windows] Docker APK build Jul 24, 2019
@avaer
Copy link
Member

avaer commented Jul 24, 2019

An example start command I use:

.\adb.exe shell am start -n com.webmr.exokit/android.app.NativeActivity -e ARGS "'node --experimental-vm-modules /package -x webvr https://aframe.io/aframe/examples/boilerplate/hello-world/'"

@kennardconsulting
Copy link
Author

Hurrah that works! Thanks.

Just to confirm, I understand Exokit is not a browser, but can it display a non-VR HTML 'landing page' with a button that you click to start VR?

@avaer
Copy link
Member

avaer commented Jul 24, 2019

That is the browser frontend we were discussing, which is at https://github.com/exokitxr/exokit-frontend/tree/white.

That behaves much more like a multi-page browser environment, with 2D page support as well.

@kennardconsulting
Copy link
Author

Oh awesome. Okay hurry up and release that :)

@kennardconsulting
Copy link
Author

FYI: linux build crashed too (running linux on AWS). Log here:

* What went wrong:
Execution failed for task ':app:externalNativeBuildDebug'.
> Build command failed.
  Error while executing process /home/appuser/app/android-sdk/cmake/3.6.4111459/bin/cmake with arguments {--build /home/appuser/app/android/app/.externalNativeBuild/cmake/debug/arm64-v8a --target native-main}
  [1/3] Building C object CMakeFiles/native-main.dir/home/appuser/app/android-sdk/ndk-bundle/sources/android/native_app_glue/android_native_app_glue.c.o
  [2/3] Building CXX object CMakeFiles/native-main.dir/home/appuser/app/main.cpp.o
  [3/3] Linking CXX shared library ../../../../build/intermediates/cmake/debug/obj/arm64-v8a/libnative-main.so
  FAILED: : && /home/appuser/app/android-sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++  --target=aarch64-none-linux-android21 --gcc-toolchain=/home/appuser/app/android-sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64 --sysroot=/home/appuser/app/android-sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/sysroot -fPIC -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -fno-addrsig -Wa,--noexecstack -Wformat -Werror=format-security  -std=c++11 -std=gnu++11 -Wall -Werror -O0 -fno-limit-debug-info  -Wl,--exclude-libs,libgcc.a -Wl,--exclude-libs,libatomic.a -static-libstdc++ -Wl,--build-id -Wl,--warn-shared-textrel -Wl,--fatal-warnings -Wl,--no-undefined -Qunused-arguments -Wl,-z,noexecstack -shared -Wl,-soname,libnative-main.so -o ../../../../build/intermediates/cmake/debug/obj/arm64-v8a/libnative-main.so CMakeFiles/native-main.dir/home/appuser/app/main.cpp.o CMakeFiles/native-main.dir/home/appuser/app/android-sdk/ndk-bundle/sources/android/native_app_glue/android_native_app_glue.c.o  -landroid -llog -lEGL -lGLESv1_CM -lGLESv2 -lGLESv3 ../../../../../../node_modules/native-oculus-mobile-deps/lib/android/arm64-v8a/libvrapi.so ../../../../../../build/libexokit/libexokit.a ../../../../../../node_modules/libnode.a-android/libnode.a ../../../../../../node_modules/native-canvas-deps/lib2/android/libskia.a ../../../../../../node_modules/native-audio-deps/lib2/magicleap/libLabSound.a ../../../../../../node_modules/native-video-deps/lib2/magicleap/libavformat.a ../../../../../../node_modules/native-video-deps/lib2/magicleap/libavcodec.a ../../../../../../node_modules/native-video-deps/lib2/magicleap/libavutil.a ../../../../../../node_modules/native-video-deps/lib2/magicleap/libavdevice.a ../../../../../../node_modules/native-video-deps/lib2/magicleap/libswscale.a ../../../../../../node_modules/native-video-deps/lib2/magicleap/libswresample.a ../../../../../../node_modules/native-video-deps/lib2/magicleap/libopus.a ../../../../../../node_modules/native-webrtc-deps/lib2/magicleap/libwebrtc.a -lOpenSLES -latomic -lm && :
  clang++: error: unable to execute command: Killed
  clang++: error: linker command failed due to signal (use -v to see invocation)
  ninja: build stopped: subcommand failed.

@avaer
Copy link
Member

avaer commented Jul 25, 2019

That’s interesting; looks like clang++ is being killed by the system (out of memory?)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants