Skip to content

Commit

Permalink
Merge pull request gree#340 from gree/feature/android_build_steps
Browse files Browse the repository at this point in the history
Feature/android build steps
  • Loading branch information
KojiNakamaru authored Aug 9, 2018
2 parents d50c286 + d989f60 commit 0dc023a
Show file tree
Hide file tree
Showing 7 changed files with 92 additions and 195 deletions.
29 changes: 26 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# unity-webview

unity-webview is a plugin for Unity 5 that overlays WebView components
on Unity view. It works on Android, iOS, Unity Web Player, and OS X
on Unity view. It works on Android, iOS, Unity Web Player, and Mac
(Windows is not supported for now).

unity-webview is derived from keijiro-san's
Expand All @@ -19,7 +19,7 @@ below:

## Platform Specific Notes

### OS X (Editor)
### Mac (Editor)

#### Auto Graphics API

Expand All @@ -33,7 +33,7 @@ and specify OpenGLCore as below.
Since Unity 5.3.0, Unity.app is built with ATS (App Transport
Security) enabled and non-secured connection (HTTP) is not
permitted. If you want to open `http://foo/bar.html` with this plugin
on Unity OS X Editor, you need to open
on Unity Mac Editor, you need to open
`/Applications/Unity5.3.4p3/Unity.app/Contents/Info.plist` with a text
editor and add the following,

Expand Down Expand Up @@ -111,6 +111,29 @@ implementation will adjust Unity's SurfaceView z order. Please refer
and `plugins/Android/src/net/gree/unitywebview/CUnityPlayer.java` if
you already have your own activity implementation.

#### How to build WebViewPlugin.jar

The following steps are for Mac but you can follow similar ones for Windows.

1. Install [Android Studio](https://developer.android.com/studio/install).
2. Open Android Studio and select "Configure/SDK Manager", select the followings with "Show Package Details",
and click OK.
* SDK Platforms
* Android 6.0 (Marshmallow)
* Android SDK Platform 23
* SDK Tools
* Android SDK Build Tools
* 28.0.2
3. Open Terminal.app and perform the followings. You should find
`unity-webview/build/Packager/Assets/Plugins/Android/WebViewPlugin.jar` if successful.

```bash
$ export ANDROID_HOME=~/Library/Android/sdk
$ export PATH=$PATH:~/Library/Android/sdk/platform-tools/bin:~/Library/Android/sdk/tools:~/Library/Android/sdk/tools/bin
$ cd unity-webview/plugins/Android
$ ./install.sh
```

### Web Player

The implementation utilizes IFRAME so please put both
Expand Down
85 changes: 0 additions & 85 deletions plugins/Android/build.xml

This file was deleted.

2 changes: 1 addition & 1 deletion plugins/Android/gradle_build/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ dependencies {

android {
compileSdkVersion 23
buildToolsVersion "24.0.0"
buildToolsVersion "28.0.2"

defaultConfig {
minSdkVersion 16
Expand Down
File renamed without changes.
88 changes: 65 additions & 23 deletions plugins/Android/install.sh
Original file line number Diff line number Diff line change
@@ -1,29 +1,71 @@
#!/bin/sh

# OS specific support. $var _must_ be set to either true or false.
cygwin=false
case "`uname`" in
CYGWIN*) cygwin=true;;
esac

# For Cygwin, ensure paths are in UNIX format
if $cygwin; then
[ -n "$ANT_HOME" ] && ANT_HOME=`cygpath --unix "$ANT_HOME"`
fi
# required command
JAR_CMD=`which jar`

# directories
CWD=`dirname $0`
CWD=`cd $CWD && pwd -P`

BUILD_DIR="${CWD}/gradle_build"
LIBS_DIR="${BUILD_DIR}/libs"
JAVA_DIR="${BUILD_DIR}/src/main/java"
BIN_DIR="${CWD}/bin"

# options
MODE="Release"
SCRIPTING_BACKEND="il2cpp"
UNITY="/Applications/Unity"

for OPT in $*; do
case $OPT in
'--release' )
MODE="Release";;
'--develop' )
MODE="Develop";;
'--il2cpp' )
SCRIPTING_BACKEND="il2cpp";;
'--mono' )
SCRIPTING_BACKEND="mono";;
'--unity' )
UNITY=$2
shift 2
;;
esac
shift
done

UNITY_JAVA_LIB="${UNITY}/PlaybackEngines/AndroidPlayer/Variations/${SCRIPTING_BACKEND}/${MODE}/Classes/classes.jar"

# clean
rm -rf ${JAVA_DIR}/*
rm -rf ${LIB_DIR}
rm -f ${BUILD_DIR}/src/main/AndroidManifest.xml

if $cygwin; then
UNITYLIBS=`find -L "/cygdrive/c/Program Files/Unity5" | grep classes.jar | tail -1`
pushd $CWD

# copy unity library
DEST_DIR='../../build/Packager/Assets/Plugins/Android'

mkdir -p ${LIBS_DIR}
mkdir -p ${BIN_DIR}
mkdir -p ${DEST_DIR}
mkdir -p ${JAVA_DIR}

cp ${UNITY_JAVA_LIB} ${LIBS_DIR}
cp -r src/net ${JAVA_DIR}
cp AndroidManifest.xml ${BUILD_DIR}/src/main

# build
./gradlew assembleRelease

if [ ${JAR_CMD} = "" ];then
echo "jar command does not exist"
else
UNITYLIBS=`find -L /Applications/Unity | grep classes.jar | tail -1`
jar cvf ${CWD}/bin/WebViewPlugin.jar -C ${BUILD_DIR}/build/intermediates/classes/release net
cp -a ${BIN_DIR}/WebViewPlugin.jar ${DEST_DIR}
fi

DSTDIR="../../build/Packager/Assets/Plugins/Android"
export ANT_OPTS=-Dfile.encoding=UTF8
android update project -t android-23 -p .
mkdir -p libs
cp "$UNITYLIBS" libs
ant "-Djava.compilerargs=-Xlint:deprecation" release
mkdir -p "$DSTDIR"
cp -a bin/classes.jar "$DSTDIR/WebViewPlugin.jar"
ant clean
rm -rf libs res proguard-project.txt
./gradlew clean

popd # $BUILD_DIR
71 changes: 0 additions & 71 deletions plugins/Android/install_gradle.sh

This file was deleted.

12 changes: 0 additions & 12 deletions plugins/Android/project.properties

This file was deleted.

0 comments on commit 0dc023a

Please sign in to comment.