RPGツクールPKG -> APK化まとめ
PWA化するぜーっていう話じゃなくてRPGツクールを横展したいという要望を会社から受けたので調べてみた。
材料
- Cordova@9.0.0 (cordova-lib@9.0.1)
- Java(JDK)
- java version "1.8.0_211"
- Java(TM) SE Runtime Environment (build 1.8.0_211-b12)
- Java HotSpot(TM) 64-Bit Server VM (build 25.211-b12, mixed mode)
- Android Studio for MAC@3.4
- Grandle@5.1.1 (bundled)
準備
- Cordova インストール
- JDK(Java development kit) インストール
- https://www.oracle.com/technetwork/java/javaee/downloads/jdk8-downloads-2133151.html
- 最新版(12)だとcordovaが対応していないのでJDK8_u211(2019/4/23現在)をインストール
-
JAVA_HOME設定 (MACのみ)
$ vim ~/.bash_profile #以下を書き足す export JAVA_HOME=`/usr/libexec/java_home -v 1.8` $ source ~/.bash_profile #即時反映
https://www.javadrive.jp/start/install/index4.html (未検証) -
- Android Studio ( or Grandle 単体 )インストール
https://developer.android.com/studio (Grandle単体は未検証) - grandle向け環境PATH設定
- 必要に応じてgrandleのパーミッションの修正(EACCESエラーが出たときのみ)
https://qiita.com/bathtimefish/items/7304f11ba4bbb36fd02d
- 必要に応じてgrandleのパーミッションの修正(EACCESエラーが出たときのみ)
ビルド
-
アプリ新規作成
$ cordova create <app-name> $ cd <app-name> # /www配下にアプリ化したいゲームのアセットをすべてぶちこむ。 # その際に/js/index.jsを上書きしないように注意
-
プラットフォームの追加
$ cordova platform add android
-
ビルド事前チェック
$ cordova requirements
errorがでなければ次へ
-
apkビルド
$ sudo cordova build android #パーミッションでエラーが起きる可能性があるので管理者権限(もしくはsudo)でビルド
-
完成
こんな感じのPATHにビルドされたapkが出てくる
/Users/*****/develop/cord/MyApp/platforms/android/app/build/outputs/apk/debug/app-debug.apk -
サーバーアップロード
FTPサーバーにapkファイルをおいてAndroidからアクセスしてDL
(参考)ビルドログ
ukei1986:MyApp *****$ sudo cordova build android
Checking Java JDK and Android SDK versions
ANDROID_SDK_ROOT=undefined (recommended setting)
ANDROID_HOME=/Users/*****/Library/Android/sdk (DEPRECATED)
Welcome to Gradle 5.1.1!
Here are the highlights of this release:
- Control which dependencies can be retrieved from which repositories
- Production-ready configuration avoidance APIs
For more details see https://docs.gradle.org/5.1.1/release-notes.html
Starting a Gradle Daemon (subsequent builds will be faster)
BUILD SUCCESSFUL in 4s
1 actionable task: 1 executed
Subproject Path: CordovaLib
Subproject Path: app
Downloading https://services.gradle.org/distributions/gradle-4.10.3-all.zip
................................................................................................................
Welcome to Gradle 4.10.3!
Here are the highlights of this release:
- Incremental Java compilation by default
- Periodic Gradle caches cleanup
- Gradle Kotlin DSL 1.0-RC6
- Nested included builds
- SNAPSHOT plugin versions in the `plugins {}` block
For more details see https://docs.gradle.org/4.10.3/release-notes.html
Starting a Gradle Daemon (subsequent builds will be faster)
> Task :app:preBuild UP-TO-DATE
> Task :CordovaLib:preBuild UP-TO-DATE
> Task :CordovaLib:preDebugBuild UP-TO-DATE
> Task :CordovaLib:checkDebugManifest
> Task :CordovaLib:processDebugManifest
> Task :app:preDebugBuild
> Task :CordovaLib:compileDebugAidl NO-SOURCE
> Task :app:compileDebugAidl NO-SOURCE
> Task :CordovaLib:packageDebugRenderscript NO-SOURCE
> Task :app:compileDebugRenderscript
> Task :app:checkDebugManifest
> Task :app:generateDebugBuildConfig
> Task :app:prepareLintJar
> Task :app:generateDebugSources
> Task :CordovaLib:compileDebugRenderscript
> Task :CordovaLib:generateDebugBuildConfig
> Task :CordovaLib:generateDebugResValues
> Task :CordovaLib:generateDebugResources
> Task :CordovaLib:packageDebugResources
> Task :CordovaLib:generateDebugRFile
> Task :CordovaLib:prepareLintJar
> Task :CordovaLib:generateDebugSources
> Task :CordovaLib:javaPreCompileDebug
> Task :CordovaLib:compileDebugJavaWithJavac
Note: /Users/*****/develop/cord/MyApp/platforms/android/CordovaLib/src/org/apache/cordova/engine/SystemCookieManager.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
> Task :CordovaLib:processDebugJavaRes NO-SOURCE
> Task :CordovaLib:transformClassesAndResourcesWithPrepareIntermediateJarsForDebug
> Task :app:javaPreCompileDebug
> Task :app:mainApkListPersistenceDebug
> Task :app:generateDebugResValues
> Task :app:generateDebugResources
> Task :app:mergeDebugResources
> Task :app:createDebugCompatibleScreenManifests
> Task :app:processDebugManifest
> Task :app:processDebugResources
> Task :app:compileDebugJavaWithJavac
> Task :app:compileDebugNdk NO-SOURCE
> Task :app:compileDebugSources
> Task :app:mergeDebugShaders
> Task :app:compileDebugShaders
> Task :app:generateDebugAssets
> Task :CordovaLib:mergeDebugShaders
> Task :CordovaLib:compileDebugShaders
> Task :CordovaLib:generateDebugAssets
> Task :CordovaLib:packageDebugAssets
> Task :app:mergeDebugAssets
> Task :app:validateSigningDebug
> Task :app:signingConfigWriterDebug
> Task :app:transformClassesWithDexBuilderForDebug
> Task :app:transformDexArchiveWithExternalLibsDexMergerForDebug
> Task :app:transformDexArchiveWithDexMergerForDebug
> Task :app:mergeDebugJniLibFolders
> Task :CordovaLib:compileDebugNdk NO-SOURCE
> Task :CordovaLib:mergeDebugJniLibFolders
> Task :CordovaLib:transformNativeLibsWithMergeJniLibsForDebug
> Task :CordovaLib:transformNativeLibsWithIntermediateJniLibsForDebug
> Task :app:transformNativeLibsWithMergeJniLibsForDebug
> Task :app:processDebugJavaRes NO-SOURCE
> Task :app:transformResourcesWithMergeJavaResForDebug
> Task :app:packageDebug
> Task :app:assembleDebug
> Task :app:cdvBuildDebug
BUILD SUCCESSFUL in 1m 33s
42 actionable tasks: 42 executed
Built the following apk(s):
/Users/*****/develop/cord/MyApp/platforms/android/app/build/outputs/apk/debug/app-debug.apk