How to import Unity module to Android project
This post introduces how to import Unity module to Android project.
Before start, I assume you have Android module exported from Unity already.
1. Copy module folder into Android Project folder.
2. Add Unity Module name in settings.gradle
pluginManagement {
repositories {
jcenter()
google()
mavenCentral()
gradlePluginPortal()
}
}
include ':unityLibrary' //Add this line
project(':unityLibrary').projectDir=newFile('../unityLibrary') //Add this line
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
jcenter()
google()
mavenCentral()
flatDir {
dirs "${project(':unityLibrary').projectDir}/libs" //Add this line
}
}
}
rootProject.name = "MLCChat"
include ':app'
The "unityLibrary" is replaced if you have another module name.
3. Add Unity module and jar files which Unity module have in build.gradle (Module :app)
dependencies {
implementation projcet(':unityLibrary')
implementation fileTree(dir: project(':unityLibrary').getProjectDir().toString() + ('\\libs'), include: ['*.jar'])
}
4. Represent abiFilters in build.gradle(Module: app)
android {
namespace 'ai.mlc.mlcchat'
compileSdk 34
defaultConfig {
applicationId "ai.mlc.mlcchat"
minSdk 26
targetSdk 33
versionCode 1
versionName "1.0"
ndk {
abiFilters "armeabi-v7a", "arm64-v8a", "x86", "x86_64" //Add this line
}
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
useSupportLibrary true
}
}
...
}
✋ abiFilters must be same with Unity abiFilters setting.
5. Copy the options in gradle.properties from Unity module to app's gradle.properties
example)
org.gradle.jvmargs=-Xmx4096M
org.gradle.parallel=true
unityStreamingAssets=
unityTemplateVersion=5
org.gradle.jvmargs=-Xmx4096M -Dfile.encoding=UTF-8
android.useAndroidX=true
kotlin.code.style=official
android.nonTransitiveRClass=true
unityStreamingAssets=zepeto_streamingassets/ZEPETO-INTERNAL
unityTemplateVersion=5
6. Sync Now!
7. Add ndk path in local.properties
## This file must *NOT* be checked into Version Control Systems,
# as it contains information specific to your local configuration.
#
# Location of the SDK. This is only used by Gradle.
# For customization when using a Version Control System, please read the
# header note.
#Tue Mar 19 16:58:42 KST 2024
sdk.dir=C\:\\Users\\07062301\\AppData\\Local\\Android\\Sdk
ndk.dir=C\:\\Users\\07062301\\AppData\\Local\\Android\\Sdk\\ndk\\25.1.8937393
8. Import Unity Module Finish!!
You can find Unity module in left side Android panel.
댓글 없음:
댓글 쓰기