exokitxr / exokit

Native VR/AR/XR engine for JavaScript 🦖
MIT License
997 stars 117 forks source link

APK does not compile #1413

Closed Filyus closed 5 years ago

Filyus commented 5 years ago

Describe the bug What happened, and what did you expect to happen? I am trying to compile an apk but nothing happens.

To Reproduce Steps or commands ran to reproduce the behavior:

  1. Enable "Windows Subsystem for Linux" component
  2. Restart Windows
  3. Install "Ubuntu" from Microsoft Store
  4. Execute commands from Ubuntu bash:
    
    sudo su

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.0/install.sh | bash bash --login nvm install 12.2.0

apt-get update apt-get install -y \ build-essential wget python libglfw3-dev libglew-dev libfreetype6-dev libfontconfig1-dev uuid-dev libxcursor-dev libxinerama-dev libxi-dev libasound2-dev libexpat1-dev

sudo apt update && sudo apt install -y android-sdk export ANDROID_HOME="/usr/lib/android-sdk/" export PATH="${PATH}:${ANDROID_HOME}tools/:${ANDROID_HOME}platform-tools/"

mkdir /mnt/c/android_ndk cd /mnt/c/android_ndk wget -c https://dl.google.com/android/repository/android-ndk-r20-linux-x86_64.zip unzip android-ndk-r20-linux-x86_64.zip export PATH=${PATH}:/mnt/c/android_ndk/android-ndk-r20

cd /mnt/c git clone https://github.com/exokitxr/exokit.git cd /mnt/c/exokit npm install


5. getting error: npm ERR! native-audio-deps@0.0.65 postinstall: `node postinstall.js`
6. Execute from Windows console in C:\exokit folder:
`npm install native-audio-deps`

7. Execute commands from Ubuntu bash:

cd /mnt/c/exokit npm install nvm install 11.15.0 /mnt/c/exokit/scripts/oculusmobile/build-android.sh



8. Console output after the last command:
<details>
  <summary>Click to expand</summary>
/mnt/c/exokit /mnt/c/exokit/scripts/oculusmobile
npm info it worked if it ends with ok
npm verb cli [ '/root/.nvm/versions/node/v11.15.0/bin/node',
npm verb cli   '/root/.nvm/versions/node/v11.15.0/bin/npm',
npm verb cli   'install',
npm verb cli   '--verbose',
npm verb cli   '--devdir=/mnt/c/exokit/.node-gyp',
npm verb cli   '--arch=aarch64',
npm verb cli   '--target_arch=aarch64',
npm verb cli   '--no-optional' ]
npm info using npm@6.7.0
npm info using node@v11.15.0
npm verb npm-session 855894a7e46539b4
npm info lifecycle exokit@0.0.525~preinstall: exokit@0.0.525
npm timing stage:loadCurrentTree Completed in 732ms
npm timing stage:loadIdealTree:cloneCurrentTree Completed in 4ms
npm timing stage:loadIdealTree:loadShrinkwrap Completed in 341ms
npm timing stage:loadIdealTree:loadAllDepsIntoIdealTree Completed in 339ms
npm timing stage:loadIdealTree Completed in 810ms
npm timing stage:generateActionsToTake Completed in 88ms
npm verb correctMkdir /root/.npm/_locks correctMkdir not in flight; initializing
npm verb lock using /root/.npm/_locks/staging-81e5209b332c8c19.lock for /mnt/c/exokit/node_modules/.staging
npm verb unlock done using /root/.npm/_locks/staging-81e5209b332c8c19.lock for /mnt/c/exokit/node_modules/.staging
npm timing stage:executeActions Completed in 48ms
npm timing stage:rollbackFailedOptional Completed in 0ms
npm info linkStuff exokit@0.0.525
npm info lifecycle exokit@0.0.525~install: exokit@0.0.525
npm WARN lifecycle exokit@0.0.525~install: cannot run in wd exokit@0.0.525 node ./scripts/preinstall.js && node-gyp configure --msvs_version=2017 && node-gyp rebuild (wd=/mnt/c/exokit)
npm info lifecycle exokit@0.0.525~postinstall: exokit@0.0.525
npm info lifecycle exokit@0.0.525~prepublish: exokit@0.0.525
npm info lifecycle exokit@0.0.525~prepare: exokit@0.0.525
npm timing stage:runTopLevelLifecycles Completed in 1805ms
npm verb saving []
npm verb shrinkwrap skipping write for package.json because there were no changes.
npm info lifecycle undefined~preshrinkwrap: undefined
npm info lifecycle undefined~shrinkwrap: undefined
npm verb shrinkwrap skipping write for package-lock.json because there were no changes.
npm info lifecycle undefined~postshrinkwrap: undefined
npm WARN base64-arraybuffer-es6@0.5.0 requires a peer of core-js-bundle@^3.1.3 but none is installed. You must install peer dependencies yourself.
npm WARN typeson@5.13.0 requires a peer of core-js-bundle@^3.1.3 but none is installed. You must install peer dependencies yourself.
npm WARN typeson@5.13.0 requires a peer of regenerator-runtime@^0.13.2 but none is installed. You must install peer dependencies yourself.

npm timing audit submit Completed in 1430ms
npm http fetch POST 200 https://registry.npmjs.org/-/npm/v1/security/audits/quick 1431ms
npm timing audit body Completed in 1ms
audited 1602 packages in 3.188s
found 3 vulnerabilities (1 moderate, 2 high)
  run `npm audit fix` to fix them, or `npm audit` for details
npm verb exit [ 0, true ]
npm timing npm Completed in 3578ms
npm info ok
find: �build/Release/obj.target�: No such file or directory
xargs: /usr/lib/android-sdk//ndk-bundle/toolchain/bin/aarch64-linux-android-ar: No such file or directory
</details>

**System information:**

 - OS: Windows 10

 - Exokit Version: 0.0.525

 - Node versions: 12.2.0, 11.15.0

 - Is your Exokit downloaded or built? built
avaer commented 5 years ago

Note that the build script already does npm install of android modules. You could try wiping node_modules and do not npm install; only run the build script.

Filyus commented 5 years ago

Thanks, Avaer!

Finally the working sequence:

  1. Enable "Windows Subsystem for Linux" component
  2. Restart Windows
  3. Install "Ubuntu" from Microsoft Store
  4. Create the file install-sdk-ndk.sh and copy it to C:\exokit\scripts\:
    
    #!/bin/bash

Installing Android SDK

cd /opt echo "Downloading Android SDK..." wget https://dl.google.com/android/repository/sdk-tools-linux-4333796.zip unzip sdk-tools-linux-4333796.zip -d android-sdk rm sdk-tools-linux-4333796.zip

echo "Updating Android SDK..." cd android-sdk/tools/bin echo y | ./sdkmanager --update

cd /opt/android-sdk/tools/bin mkdir -p ~/.android touch ~/.android/repositories.cfg

echo "Installing platform tools from 21 to latest" ./sdkmanager "platform-tools" for platform in $(./sdkmanager --list | grep platforms | cut -d'|' -f1); do if [ "$(echo $platform | cut -d'-' -f2)" -ge "21" ]; then ./sdkmanager "$platform" fi done

echo "Installing build tools" for build in $(./sdkmanager --list | grep build-tools | cut -d'|' -f1); do ./sdkmanager "$build" done

echo "Installing extra repositories" for repository in $(./sdkmanager --list | grep extras | cut -d'|' -f1); do ./sdkmanager "$repository" done

Installing Android NDK

cd /opt echo "Downloading Android NDK..." wget https://dl.google.com/android/repository/android-ndk-r20-linux-x86_64.zip unzip android-ndk-r20-linux-x86_64.zip mv android-ndk-r20 android-ndk rm android-ndk-r20-linux-x86_64.zip

echo "Creating system variables" export ANDROID_HOME=/opt/android-sdk export ANDROID_NDK_HOME=/opt/android-ndk export ANDROID_TOOLS=/opt/android-sdk/tools/bin export ANDROID_PLATFORM_TOOLS=/opt/android-sdk/platform-tools export PATH=$PATH:$ANDROID_HOME:$ANDROID_TOOLS:$ANDROID_PLATFORM_TOOLS:$ANDROID_NDK_HOME

echo "export ANDROID_HOME=/opt/android-sdk" >> ~/.bashrc echo "export ANDROID_NDK_HOME=/opt/android-ndk" >> ~/.bashrc echo "export ANDROID_TOOLS=/opt/android-sdk/tools/bin" >> ~/.bashrc echo "export ANDROID_PLATFORM_TOOLS=/opt/android-sdk/platform-tools" >> ~/.bashrc echo "export PATH=$PATH:$ANDROID_HOME:$ANDROID_TOOLS:$ANDROID_PLATFORM_TOOLS:$ANDROID_NDK_HOME" >> ~/.bashrc

echo "New system variables: ANDROID_HOME, ANDROID_NDK_HOME, ANDROID_TOOLS, ANDROID_PLATFORM_TOOLS"


5. Fix pathes in C:\exokit\scripts\oculusmobile\build-android.sh:

TOOLCHAIN="$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64" cd "$(dirname "$0")"

export TOOLCHAIN_USR="$TOOLCHAIN/sysroot/usr" export TOOLCHAIN_LIB=$TOOLCHAIN/sysroot/usr/lib export TOOLCHAIN_LIB_CXX=$TOOLCHAIN_LIB/aarch64-linux-android/lib export TOOLCHAIN_LIB_64=$TOOLCHAIN_LIB/aarch64-linux-android/lib64

export TOOLCHAIN_INCLUDE_LIB=$TOOLCHAIN/include/c++/4.9.x

export TOOLCHAIN_INCLUDE_SYSROOT=$TOOLCHAIN/sysroot/usr/include export LD_LIBRARY_PATH="./Release:.:$LD_LIBRARY_PATH"

export CC_target="aarch64" export GYP_CROSSCOMPILE=1 export CLANG_CXX_LIBRARY="libstdc++" export CC="$TOOLCHAIN/bin/aarch64-linux-android21-clang" export CXX="$TOOLCHAIN/bin/aarch64-linux-android21-clang++" export LINK="$TOOLCHAIN/bin/aarch64-linux-android21-clang++" export AR="$TOOLCHAIN/bin/aarch64-linux-android-ar" export LD="$TOOLCHAIN/bin/aarch64-linux-android-ld"


6. Execute commands from Ubuntu bash:

sudo su

apt-get update apt-get install -y \ build-essential wget python libglfw3-dev libglew-dev libfreetype6-dev libfontconfig1-dev uuid-dev libxcursor-dev libxinerama-dev libxi-dev libasound2-dev libexpat1-dev

sudo apt update sudo apt-get install -y openjdk-8-jdk sudo update-alternatives --config java

press a number for the java-8

export JAVA_HOME=$(readlink -f /usr/bin/javac | sed "s:/bin/javac::") echo "export JAVA_HOME=$JAVA_HOME" >> ~/.bashrc

/mnt/c/exokit/scripts/install-sdk-ndk.sh yes | sdkmanager --licenses

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.0/install.sh | bash bash --login nvm install 11.15.0

/mnt/c/exokit/scripts/oculusmobile/build-android.sh