Epic Online Service プラグインのAndroidビルド設定
Epic Online Service(略:EOS)を使ってオンラインゲームを作っている人向け。EOSプラグイン for Unityは便利なのですが、Gradleのビルド設定は自動で書いてくれないのでAndroidビルドで詰まりがち、自分の環境で成功したビルド設定を残しておきます。
参考文献
Unity 2022.3 バージョン
- Unity 2022.3.62f3
- Android Target API Level: 36
baseProjectTemplate.gradle
allprojects {
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.4.2'
classpath "com.android.tools:r8:8.1.56"
}
}
repositories {
google()
mavenCentral()
maven {
url = uri("https://storage.googleapis.com/r8-releases/raw")
}
flatDir {
dirs "${project(':unityLibrary').projectDir}/libs"
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
gradleTemplate.properties
org.gradle.jvmargs=-Xmx**JVM_HEAP_SIZE**M
org.gradle.parallel=true
unityStreamingAssets=.unity3d**STREAMING_ASSETS**
# Android Resolver Properties Start
android.useAndroidX=true
android.enableJetifier=true
# Android Resolver Properties End
**ADDITIONAL_PROPERTIES**
android.jetifier.ignorelist=annotation-experimental-1.4.0.aar
mainTemplate.gradle
apply plugin: 'com.android.library'
**APPLY_PLUGINS**
dependencies {
implementation 'androidx.credentials:credentials-play-services-auth:1.3.0'
implementation 'androidx.credentials:credentials:1.3.0'
implementation 'com.google.android.libraries.identity.googleid:googleid:1.1.1'
implementation fileTree(dir: 'libs', include: ['*.jar'])
// Android Resolver Dependencies Start
implementation 'androidx.constraintlayout:constraintlayout:2.1.4' // Assets/GoogleMobileAds/Editor/GoogleMobileAdsDependencies.xml:12
implementation 'androidx.lifecycle:lifecycle-process:2.6.2' // Assets/GoogleMobileAds/Editor/GoogleMobileAdsDependencies.xml:17
implementation 'com.google.android.gms:play-services-ads:24.5.0' // Assets/GoogleMobileAds/Editor/GoogleMobileAdsDependencies.xml:7
implementation 'com.google.android.gms:play-services-base:18.9.0' // Assets/Firebase/Editor/AppDependencies.xml:17
implementation 'com.google.android.ump:user-messaging-platform:3.2.0' // Assets/GoogleMobileAds/Editor/GoogleUmpDependencies.xml:7
implementation 'com.google.firebase:firebase-analytics:23.0.0' // Assets/Firebase/Editor/MessagingDependencies.xml:15
implementation 'com.google.firebase:firebase-analytics-unity:13.4.0' // Assets/Firebase/Editor/AnalyticsDependencies.xml:18
implementation 'com.google.firebase:firebase-app-unity:13.4.0' // Assets/Firebase/Editor/AppDependencies.xml:22
implementation 'com.google.firebase:firebase-common:22.0.1' // Assets/Firebase/Editor/AppDependencies.xml:13
implementation 'com.google.firebase:firebase-iid:21.1.0' // Assets/Firebase/Editor/MessagingDependencies.xml:17
implementation 'com.google.firebase:firebase-messaging:25.0.1' // Assets/Firebase/Editor/MessagingDependencies.xml:13
implementation 'com.google.firebase:firebase-messaging-unity:13.4.0' // Assets/Firebase/Editor/MessagingDependencies.xml:24
implementation 'com.google.flatbuffers:flatbuffers-java:1.12.0' // Assets/Firebase/Editor/MessagingDependencies.xml:19
// Android Resolver Dependencies End
**DEPS**}
// Android Resolver Exclusions Start
android {
packagingOptions {
exclude ('/lib/armeabi/*' + '*')
exclude ('/lib/armeabi-v7a/*' + '*')
exclude ('/lib/mips/*' + '*')
exclude ('/lib/mips64/*' + '*')
exclude ('/lib/x86/*' + '*')
exclude ('/lib/x86_64/*' + '*')
}
}
// Android Resolver Exclusions End
android {
namespace "com.unity3d.player"
ndkPath "**NDKPATH**"
compileSdkVersion **APIVERSION**
buildToolsVersion '**BUILDTOOLS**'
compileOptions {
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}
defaultConfig {
minSdkVersion **MINSDKVERSION**
targetSdkVersion **TARGETSDKVERSION**
ndk {
abiFilters **ABIFILTERS**
}
versionCode **VERSIONCODE**
versionName '**VERSIONNAME**'
consumerProguardFiles 'proguard-unity.txt'**USER_PROGUARD**
}
lintOptions {
abortOnError false
}
aaptOptions {
// noCompress = **BUILTIN_NOCOMPRESS** + unityStreamingAssets.tokenize(', ')
noCompress = ['.ress', '.resource', '.obb'] + unityStreamingAssets.tokenize(', ')
ignoreAssetsPattern = "!.svn:!.git:!.ds_store:!*.scc:!CVS:!thumbs.db:!picasa.ini:!*~"
}**PACKAGING_OPTIONS**
}**REPOSITORIES**
**IL_CPP_BUILD_SETUP**
**SOURCE_BUILD_SETUP**
**EXTERNAL_SOURCES**
Unity 6000.0 バージョン
- Unity 6000.0.62f1
- Android Target API Level: 36
baseProjectTemplate.gradle
allprojects {
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
- classpath 'com.android.tools.build:gradle:7.4.2'
+ classpath 'com.android.tools.build:gradle:8.10.0'
- classpath "com.android.tools:r8:8.1.56"
+ classpath "com.android.tools:r8:8.10.21"
}
}
repositories {
google()
mavenCentral()
maven {
url = uri("https://storage.googleapis.com/r8-releases/raw")
}
flatDir {
dirs "${project(':unityLibrary').projectDir}/libs"
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
gradleTemplate.properties
org.gradle.jvmargs=-Xmx**JVM_HEAP_SIZE**M
org.gradle.parallel=true
unityStreamingAssets=**STREAMING_ASSETS**
# Android Resolver Properties Start
android.useAndroidX=true
android.enableJetifier=true
# Android Resolver Properties End
**ADDITIONAL_PROPERTIES**
launcherTemplate.gradle
apply plugin: 'com.android.application'
apply from: 'setupSymbols.gradle'
apply from: '../shared/keepUnitySymbols.gradle'
dependencies {
implementation project(':unityLibrary')
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.0.4'
}
android {
namespace "**NAMESPACE**"
ndkPath "**NDKPATH**"
ndkVersion "**NDKVERSION**"
compileSdk **APIVERSION**
buildToolsVersion = "**BUILDTOOLS**"
compileOptions {
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
coreLibraryDesugaringEnabled true
}
defaultConfig {
minSdk **MINSDK**
targetSdk **TARGETSDK**
applicationId '**APPLICATIONID**'
ndk {
abiFilters **ABIFILTERS**
debugSymbolLevel **DEBUGSYMBOLLEVEL**
}
versionCode **VERSIONCODE**
versionName '**VERSIONNAME**'
}
androidResources {
noCompress = **BUILTIN_NOCOMPRESS** + unityStreamingAssets.tokenize(', ')
ignoreAssetsPattern = "!.svn:!.git:!.ds_store:!*.scc:!CVS:!thumbs.db:!picasa.ini:!*~"
}**SIGN**
lint {
abortOnError false
}
buildTypes {
debug {
minifyEnabled **MINIFY_DEBUG**
proguardFiles getDefaultProguardFile('proguard-android.txt')**SIGNCONFIG**
jniDebuggable true
}
release {
minifyEnabled **MINIFY_RELEASE**
proguardFiles getDefaultProguardFile('proguard-android.txt')**SIGNCONFIG**
}
}**PACKAGING****PLAY_ASSET_PACKS****SPLITS**
**BUILT_APK_LOCATION**
bundle {
language {
enableSplit = false
}
density {
enableSplit = false
}
abi {
enableSplit = true
}
texture {
enableSplit = true
}
}
**GOOGLE_PLAY_DEPENDENCIES**
}**SPLITS_VERSION_CODE****LAUNCHER_SOURCE_BUILD_SETUP**
mainTemplate.gradle
apply plugin: 'com.android.library'
apply from: '../shared/keepUnitySymbols.gradle'
**APPLY_PLUGINS**
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
// Android Resolver Dependencies Start
implementation 'androidx.constraintlayout:constraintlayout:2.1.4' // Assets/GoogleMobileAds/Editor/GoogleMobileAdsDependencies.xml:12
implementation 'androidx.lifecycle:lifecycle-process:2.6.2' // Assets/GoogleMobileAds/Editor/GoogleMobileAdsDependencies.xml:17
implementation 'com.google.android.gms:play-services-ads:24.5.0' // Assets/GoogleMobileAds/Editor/GoogleMobileAdsDependencies.xml:7
implementation 'com.google.android.gms:play-services-base:18.9.0' // Assets/Firebase/Editor/AppDependencies.xml:17
implementation 'com.google.android.ump:user-messaging-platform:3.2.0' // Assets/GoogleMobileAds/Editor/GoogleUmpDependencies.xml:7
implementation 'com.google.firebase:firebase-analytics:23.0.0' // Assets/Firebase/Editor/MessagingDependencies.xml:15
implementation 'com.google.firebase:firebase-analytics-unity:13.4.0' // Assets/Firebase/Editor/AnalyticsDependencies.xml:18
implementation 'com.google.firebase:firebase-app-unity:13.4.0' // Assets/Firebase/Editor/AppDependencies.xml:22
implementation 'com.google.firebase:firebase-common:22.0.1' // Assets/Firebase/Editor/AppDependencies.xml:13
implementation 'com.google.firebase:firebase-iid:21.1.0' // Assets/Firebase/Editor/MessagingDependencies.xml:17
implementation 'com.google.firebase:firebase-messaging:25.0.1' // Assets/Firebase/Editor/MessagingDependencies.xml:13
implementation 'com.google.firebase:firebase-messaging-unity:13.4.0' // Assets/Firebase/Editor/MessagingDependencies.xml:24
implementation 'com.google.flatbuffers:flatbuffers-java:1.12.0' // Assets/Firebase/Editor/MessagingDependencies.xml:19
// Android Resolver Dependencies End
**DEPS**}
// Android Resolver Exclusions Start
android {
packaging {
exclude ('/lib/armeabi/*' + '*')
exclude ('/lib/armeabi-v7a/*' + '*')
exclude ('/lib/mips/*' + '*')
exclude ('/lib/mips64/*' + '*')
exclude ('/lib/x86/*' + '*')
exclude ('/lib/x86_64/*' + '*')
}
}
// Android Resolver Exclusions End
android {
namespace "com.unity3d.player"
ndkPath "**NDKPATH**"
ndkVersion "**NDKVERSION**"
compileSdk **APIVERSION**
buildToolsVersion = "**BUILDTOOLS**"
compileOptions {
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
coreLibraryDesugaringEnabled true
}
defaultConfig {
minSdk **MINSDK**
targetSdk **TARGETSDK**
ndk {
debugSymbolLevel **DEBUGSYMBOLLEVEL**
abiFilters **ABIFILTERS**
}
versionCode **VERSIONCODE**
versionName '**VERSIONNAME**'
consumerProguardFiles 'proguard-unity.txt'**USER_PROGUARD**
**DEFAULT_CONFIG_SETUP**
}
lint {
abortOnError false
}
androidResources {
noCompress = **BUILTIN_NOCOMPRESS** + unityStreamingAssets.tokenize(', ')
ignoreAssetsPattern = "!.svn:!.git:!.ds_store:!*.scc:!CVS:!thumbs.db:!picasa.ini:!*~"
}**PACKAGING**
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
**DEPS**
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.0.4'
}
**IL_CPP_BUILD_SETUP**
**SOURCE_BUILD_SETUP**
**EXTERNAL_SOURCES**
PlatformSpecificAssets~\EOS\Android\eos_dependencies.androidlib\build.gradle
buildscript {
repositories {
google()
- jcenter()
mavenCentral()
flatDir(dirs: 'libs')
}
dependencies {
- classpath "com.android.tools.build:gradle:3.6.0"
+ classpath "com.android.tools.build:gradle:7.4.2"
}
}
apply plugin: 'com.android.library'
repositories {
google()
mavenCentral()
flatDir {
dirs 'libs'
}
}
android {
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
jniLibs.srcDirs = ['libs']
}
}
namespace 'com.pew.eos_dependencies'
compileSdkVersion 34
buildToolsVersion '36.0.0'
defaultConfig {
targetSdkVersion 34
}
- compileSdkVersion **APIVERSION**
- buildToolsVersion '**BUILDTOOLS**'
- defaultConfig {
- targetSdkVersion **TARGETSDKVERSION**
- }
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.5.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'androidx.security:security-crypto:1.0.0'
implementation 'androidx.browser:browser:1.4.0'
//api fileTree(dir: 'libs', include: ['*.aar'])
}
PlatformSpecificAssets~\EOS\Android\eos_dependencies.androidlib\AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.pew.eos_dependencies"
>
<application
android:theme="@style/Theme.AppCompat.Light.NoActionBar.FullScreen">
</application>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.DOWNLOAD_WITHOUT_NOTIFICATION" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
</manifest>
ビルドがうまくいかない人は試してみてください。
以上