166 lines
5.6 KiB
Groovy
166 lines
5.6 KiB
Groovy
plugins {
|
||
id "com.android.application"
|
||
id "kotlin-android"
|
||
id "dev.flutter.flutter-gradle-plugin"
|
||
}
|
||
|
||
def localProperties = new Properties()
|
||
def localPropertiesFile = rootProject.file('local.properties')
|
||
if (localPropertiesFile.exists()) {
|
||
localPropertiesFile.withReader('UTF-8') { reader ->
|
||
localProperties.load(reader)
|
||
}
|
||
}
|
||
|
||
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
|
||
if (flutterVersionCode == null) {
|
||
flutterVersionCode = '1'
|
||
}
|
||
|
||
def flutterVersionName = localProperties.getProperty('flutter.versionName')
|
||
if (flutterVersionName == null) {
|
||
flutterVersionName = '1.0'
|
||
}
|
||
// 打包前添加
|
||
def keystoreProperties = new Properties()
|
||
def keystorePropertiesFile = rootProject.file("key.properties")
|
||
if(keystorePropertiesFile.exists()){
|
||
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
|
||
}
|
||
|
||
|
||
android {
|
||
namespace "com.example.ar_tourism_flutter_unity"
|
||
compileSdkVersion 34
|
||
// ndkVersion flutter.ndkVersion
|
||
ndkVersion '21.3.6528147'
|
||
// ndkVersion '25.1.8577841'
|
||
// ndk {
|
||
// abiFilters 'armeabi-v7a', 'arm64-v8a'
|
||
// }
|
||
compileOptions {
|
||
sourceCompatibility JavaVersion.VERSION_1_8
|
||
targetCompatibility JavaVersion.VERSION_1_8
|
||
}
|
||
aaptOptions {
|
||
cruncherEnabled = false // 禁用PNG优化,加快构建速度
|
||
}
|
||
|
||
|
||
kotlinOptions {
|
||
jvmTarget = '1.8'
|
||
freeCompilerArgs += ['-Xopt-in=kotlin.RequiresOptIn']
|
||
}
|
||
|
||
lintOptions {
|
||
disable 'Deprecation' // 临时关闭弃用警告
|
||
abortOnError false // 防止构建失败
|
||
}
|
||
|
||
sourceSets {
|
||
main.java.srcDirs += 'src/main/kotlin'
|
||
// jniLibs.srcDirs = ['../unityLibrary/libs']
|
||
}
|
||
|
||
// configurations.all {
|
||
// resolutionStrategy {
|
||
// // 强制使用项目中的 unity-classes.jar
|
||
// force 'com.unity3d.player:unity-classes:1.0.0'
|
||
// }
|
||
// }
|
||
|
||
defaultConfig {
|
||
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
|
||
applicationId "com.example.ar_tourism_flutter_unity"
|
||
// You can update the following values to match your application needs.
|
||
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
|
||
// minSdkVersion flutter.minSdkVersion
|
||
// targetSdkVersion flutter.targetSdkVersion
|
||
minSdkVersion 22
|
||
targetSdkVersion 34
|
||
// versionCode flutterVersionCode.toInteger()
|
||
// versionName flutterVersionName
|
||
versionCode 21// 手动设置为一个比之前大的值
|
||
versionName "1.2.1"
|
||
multiDexEnabled true
|
||
|
||
}
|
||
|
||
packagingOptions {
|
||
pickFirst "**/libc++_shared.so"
|
||
}
|
||
|
||
sourceSets {
|
||
main {
|
||
// jniLibs.srcDirs = ['libs', 'src/main/jniLibs']
|
||
// 手动添加java文件
|
||
java.srcDirs += ['src/main/java']
|
||
jniLibs.srcDirs = ['src/main/jniLibs']
|
||
}
|
||
}
|
||
// 打包前添加
|
||
signingConfigs {
|
||
release {
|
||
keyAlias keystoreProperties['keyAlias']
|
||
keyPassword keystoreProperties['keyPassword']
|
||
storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']):null
|
||
storePassword keystoreProperties['storePassword']
|
||
}
|
||
}
|
||
buildTypes {
|
||
release {
|
||
shrinkResources true //可以使用shrinkResources选项来移除未使用的资源:
|
||
// TODO: Add your own signing config for the release build.
|
||
// Signing with the debug keys for now, so `flutter run --release` works.
|
||
signingConfig signingConfigs.debug
|
||
// 确保不会被混淆
|
||
minifyEnabled false
|
||
// minifyEnabled true // 启用代码混淆
|
||
shrinkResources false // 启用资源压缩
|
||
|
||
// // 指定混淆规则文件
|
||
// proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||
|
||
}
|
||
}
|
||
}
|
||
|
||
flutter {
|
||
source '../..'
|
||
}
|
||
|
||
|
||
dependencies {
|
||
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.3"
|
||
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.3"
|
||
implementation project(':unityLibrary')
|
||
implementation(name: 'unity-classes', ext: 'jar')
|
||
implementation(name: 'EasyAR', ext: 'aar')
|
||
implementation(name: 'arenginesdk-3.7.0.3', ext: 'aar')
|
||
implementation 'com.github.yalantis:ucrop:2.2.8'
|
||
|
||
// implementation(name: 'unity-classes', ext:'jar')
|
||
// implementation(name: 'arenginesdk-3.7.0.3', ext:'aar')
|
||
implementation(name: 'NatCorder', ext:'aar')
|
||
implementation(name: 'com.google.ar.core-1.23.0', ext:'aar')
|
||
implementation(name: 'com.google.ar.core-optional', ext:'aar')
|
||
implementation(name: 'AREngineInterop', ext:'aar')
|
||
implementation(name: 'permission.INTERNET', ext:'aar')
|
||
implementation(name: 'NatRender', ext:'aar')
|
||
implementation(name: 'permission.RECORD_AUDIO', ext:'aar')
|
||
implementation(name: 'permission.CAMERA', ext:'aar')
|
||
implementation(name: 'NativeShare', ext:'aar')
|
||
|
||
// implementation(name: 'EasyAR', ext:'aar')
|
||
// implementation project('xrmanifest.androidlib')
|
||
// implementation files("${project(':unityLibrary').projectDir}/libs/unity-classes.jar")
|
||
// 改为使用exclude排除重复依赖
|
||
// implementation(project(':unityLibrary')) {
|
||
// exclude group: 'com.unity3d.player', module: 'unity-classes'
|
||
// implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.0"
|
||
// }
|
||
// implementation fileTree(dir: "${project(':unityLibrary').projectDir}/libs", include: ['*.jar'])
|
||
}
|
||
|
||
|