build(android): 配置 Android 构建模板、包名与密钥库

This commit is contained in:
2026-07-02 02:45:30 +08:00
parent 29267659b9
commit 63d755ee05
15 changed files with 427 additions and 73 deletions
+2
View File
@@ -111,3 +111,5 @@ fmod_editor.log
**/.history/*
.fake
Keystore/aibis-release-key.keystore
Keystore/keystore.bat
+3
View File
@@ -56,6 +56,9 @@
"temp/": true,
"Temp/": true
},
"files.associations": {
"**/Plugins/Android/*Template.gradle": "plaintext"
},
"dotnet.defaultSolution": "aibis-dream.sln",
"dotnet.preferCSharpExtension": true,
"cSpell.enableFiletypes": [
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 7a3c1e8f4b2d9a6051c7e3f8b4d6a2c1
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="com.unity3d.player"
xmlns:tools="http://schemas.android.com/tools">
<application>
<activity android:name="com.unity3d.player.PrivacyActivity" android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.unity3d.player.UnityPlayerActivity"
android:theme="@style/UnityThemeSelector">
<meta-data android:name="unityplayer.UnityActivity" android:value="true" />
</activity>
</application>
</manifest>
@@ -0,0 +1,32 @@
fileFormatVersion: 2
guid: 8b4d2f9a5c3e0b7162d8f4a9c5e7b3d2
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Android: Android
second:
enabled: 1
settings: {}
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 0d55c2cccb1971d42a463636459b3611
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,132 @@
package com.unity3d.player;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.webkit.WebView;
public class PrivacyActivity extends Activity implements DialogInterface.OnClickListener {
// WebView 和 Dialog 引用,用于资源管理
private WebView webView;
private AlertDialog privacyDialog;
// 隐私协议内容
final String privacyContext = "<html><body style='padding:16px;font-size:14px;line-height:1.8;'>" +
"<h3>提示</h3>" +
"欢迎使用本游戏!在使用前,请您充分阅读并理解:<br/>" +
"<b>Unity收集的信息:</b><br/>" +
"• 设备信息:Android ID、IMEI、Mac地址、设备型号、系统版本<br/>" +
"• 应用信息:应用安装列表<br/>" +
"• 传感器信息:触屏、重力、加速度传感器(用于横竖屏适配)<br/><br/>" +
"<b>收集目的:</b><br/>" +
"• 保障游戏正常运行、数据统计、和性能优化<br/><br/>" +
"<b>信息保护:</b><br/>" +
"• 我们不会将您的个人信息出售给第三方,仅在法律要求或为提供服务所必需时才会共享。<br/><br/>" +
"<b>您的权利:</b><br/>" +
"• 您有权拒绝我们收集信息,但可能导致游戏无法正常运行。<br/><br/>" +
"</body></html>";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// 如果已经同意过隐私协议则直接进入Unity Activity
if (GetPrivacyAccept()) {
EnterUnityActivity();
return;
}
// 弹出隐私协议对话框
ShowPrivacyDialog();
}
// 显示隐私协议对话框
private void ShowPrivacyDialog() {
webView = new WebView(this);
webView.loadData(privacyContext, "text/html", "utf-8");
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setCancelable(false);
builder.setView(webView);
builder.setTitle("隐私政策");
builder.setNegativeButton("拒绝", this);
builder.setPositiveButton("同意", this);
privacyDialog = builder.create();
privacyDialog.show();
}
@Override
public void onClick(DialogInterface dialogInterface, int i) {
switch (i) {
case AlertDialog.BUTTON_POSITIVE:// 点击同意按钮
SetPrivacyAccept(true);
EnterUnityActivity(); // 启动Unity Activity
break;
case AlertDialog.BUTTON_NEGATIVE:// 点击拒绝按钮,直接退出App
finish();
break;
}
}
// 启动Unity Activity
private void EnterUnityActivity() {
Intent unityAct = new Intent();
unityAct.setClassName(this, "com.unity3d.player.UnityPlayerActivity");
this.startActivity(unityAct);
// 启动Unity Activity后,finish掉PrivacyActivity,避免退出时返回到这里
this.finish();
}
// 本地存储保存同意隐私协议状态
private void SetPrivacyAccept(boolean accepted) {
SharedPreferences.Editor prefs = this.getSharedPreferences("PlayerPrefs", MODE_PRIVATE).edit();
prefs.putBoolean("PrivacyAcceptedKey", accepted);
prefs.apply();
}
// 获取是否已经同意过
private boolean GetPrivacyAccept() {
SharedPreferences prefs = this.getSharedPreferences("PlayerPrefs", MODE_PRIVATE);
return prefs.getBoolean("PrivacyAcceptedKey", false);
}
@Override
protected void onPause() {
super.onPause();
// 暂停 WebView 以节省资源
if (webView != null) {
webView.onPause();
}
}
@Override
protected void onResume() {
super.onResume();
// 恢复 WebView
if (webView != null) {
webView.onResume();
}
}
@Override
protected void onDestroy() {
super.onDestroy();
// 关闭对话框
if (privacyDialog != null && privacyDialog.isShowing()) {
privacyDialog.dismiss();
privacyDialog = null;
}
// 显式销毁 WebView 释放资源,防止内存泄漏
if (webView != null) {
webView.onPause();
webView.removeAllViews();
webView.destroy();
webView = null;
}
}
}
@@ -0,0 +1,32 @@
fileFormatVersion: 2
guid: 9c5e3a0b6d4f1c8273e9a5b0d6f8c4e3
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Android: Android
second:
enabled: 1
settings: {}
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,9 @@
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**
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: b7f5c2d3e8f4190561fbc7d2e9f0c6f5
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,57 @@
apply plugin: 'com.android.library'
**APPLY_PLUGINS**
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
// Android Resolver Dependencies Start
implementation 'com.taptap.sdk:tap-core-unity:4.10.0-beta.1' // Packages/com.taptap.sdk.core/Mobile/Editor/NativeDependencies.xml:7
implementation 'com.taptap.sdk:tap-rep:4.10.0-beta.1' // Packages/com.taptap.sdk.rep/Mobile/Editor/NativeDependencies.xml:7
// 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 {
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(', ')
ignoreAssetsPattern = "!.svn:!.git:!.ds_store:!*.scc:!CVS:!thumbs.db:!picasa.ini:!*~"
}**PACKAGING_OPTIONS**
}
**IL_CPP_BUILD_SETUP**
**SOURCE_BUILD_SETUP**
**EXTERNAL_SOURCES**
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: a6f4b1c2d7e3089450fab6c1d8e9b5f4
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,30 @@
pluginManagement {
repositories {
**ARTIFACTORYREPOSITORY**
gradlePluginPortal()
google()
mavenCentral()
}
}
include ':launcher', ':unityLibrary'
**INCLUDES**
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.PREFER_SETTINGS)
repositories {
**ARTIFACTORYREPOSITORY**
google()
mavenCentral()
// Android Resolver Repos Start
def unityProjectPath = $/file:///**DIR_UNITYPROJECT**/$.replace("\\", "/")
maven {
url "https://repo.maven.apache.org/maven2" // Packages/com.taptap.sdk.core/Mobile/Editor/NativeDependencies.xml:6, Packages/com.taptap.sdk.rep/Mobile/Editor/NativeDependencies.xml:6
}
mavenLocal()
// Android Resolver Repos End
flatDir {
dirs "${project(':unityLibrary').projectDir}/libs"
}
}
}
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: ec6752b2707a39347981bea1e817beec
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
+74 -72
View File
@@ -57,8 +57,8 @@ PlayerSettings:
iosShowActivityIndicatorOnLoading: -1
androidShowActivityIndicatorOnLoading: -1
iosUseCustomAppBackgroundBehavior: 0
allowedAutorotateToPortrait: 1
allowedAutorotateToPortraitUpsideDown: 1
allowedAutorotateToPortrait: 0
allowedAutorotateToPortraitUpsideDown: 0
allowedAutorotateToLandscapeRight: 1
allowedAutorotateToLandscapeLeft: 1
useOSAutorotation: 1
@@ -133,7 +133,7 @@ PlayerSettings:
vulkanEnableLateAcquireNextImage: 0
vulkanEnableCommandBufferRecycling: 1
loadStoreDebugModeEnabled: 0
bundleVersion: 0.5.1.1-20260430-002845
bundleVersion: 0.5.1.7-20260701-213941
preloadedAssets:
- {fileID: 11400000, guid: 0fb2bc2476953fc43a74f0ab8879077c, type: 2}
metroInputSource: 0
@@ -155,6 +155,7 @@ PlayerSettings:
androidSupportedAspectRatio: 1
androidMaxAspectRatio: 2.1
applicationIdentifier:
Android: com.Tinbird.AllOurBrokenParts
Standalone: com.Tin-Bird.Love-RobotRepair
buildNumber:
Standalone: 0
@@ -162,7 +163,7 @@ PlayerSettings:
iPhone: 0
tvOS: 0
overrideDefaultApplicationIdentifier: 1
AndroidBundleVersionCode: 1
AndroidBundleVersionCode: 23
AndroidMinSdkVersion: 22
AndroidTargetSdkVersion: 0
AndroidPreferredInstallLocation: 1
@@ -244,20 +245,20 @@ PlayerSettings:
clonedFromGUID: c19f32bac17ee4170b3bf8a6a0333fb9
templatePackageId: com.unity.template.universal-2d@2.1.2
templateDefaultScene: Assets/Scenes/SampleScene.unity
useCustomMainManifest: 0
useCustomMainManifest: 1
useCustomLauncherManifest: 0
useCustomMainGradleTemplate: 0
useCustomMainGradleTemplate: 1
useCustomLauncherGradleManifest: 0
useCustomBaseGradleTemplate: 0
useCustomGradlePropertiesTemplate: 0
useCustomGradlePropertiesTemplate: 1
useCustomGradleSettingsTemplate: 0
useCustomProguardFile: 0
AndroidTargetArchitectures: 1
AndroidTargetArchitectures: 2
AndroidTargetDevices: 0
AndroidSplashScreenScale: 0
androidSplashScreen: {fileID: 0}
AndroidKeystoreName:
AndroidKeyaliasName:
AndroidKeystoreName: '{inproject}: Keystore/aibis-release-key.keystore'
AndroidKeyaliasName: aibis-release
AndroidEnableArmv9SecurityFeatures: 0
AndroidBuildApkPerCpuArchitecture: 0
AndroidTVCompatibility: 0
@@ -265,7 +266,7 @@ PlayerSettings:
AndroidEnableTango: 0
androidEnableBanner: 1
androidUseLowAccuracyLocation: 0
androidUseCustomKeystore: 0
androidUseCustomKeystore: 1
m_AndroidBanners:
- width: 320
height: 180
@@ -287,6 +288,66 @@ PlayerSettings:
m_BuildTargetPlatformIcons:
- m_BuildTarget: Android
m_Icons:
- m_Textures: []
m_Width: 192
m_Height: 192
m_Kind: 1
m_SubKind:
- m_Textures: []
m_Width: 144
m_Height: 144
m_Kind: 1
m_SubKind:
- m_Textures: []
m_Width: 96
m_Height: 96
m_Kind: 1
m_SubKind:
- m_Textures: []
m_Width: 72
m_Height: 72
m_Kind: 1
m_SubKind:
- m_Textures: []
m_Width: 48
m_Height: 48
m_Kind: 1
m_SubKind:
- m_Textures: []
m_Width: 36
m_Height: 36
m_Kind: 1
m_SubKind:
- m_Textures: []
m_Width: 192
m_Height: 192
m_Kind: 0
m_SubKind:
- m_Textures: []
m_Width: 144
m_Height: 144
m_Kind: 0
m_SubKind:
- m_Textures: []
m_Width: 96
m_Height: 96
m_Kind: 0
m_SubKind:
- m_Textures: []
m_Width: 72
m_Height: 72
m_Kind: 0
m_SubKind:
- m_Textures: []
m_Width: 48
m_Height: 48
m_Kind: 0
m_SubKind:
- m_Textures: []
m_Width: 36
m_Height: 36
m_Kind: 0
m_SubKind:
- m_Textures: []
m_Width: 432
m_Height: 432
@@ -317,66 +378,6 @@ PlayerSettings:
m_Height: 81
m_Kind: 2
m_SubKind:
- m_Textures: []
m_Width: 192
m_Height: 192
m_Kind: 1
m_SubKind:
- m_Textures: []
m_Width: 144
m_Height: 144
m_Kind: 1
m_SubKind:
- m_Textures: []
m_Width: 96
m_Height: 96
m_Kind: 1
m_SubKind:
- m_Textures: []
m_Width: 72
m_Height: 72
m_Kind: 1
m_SubKind:
- m_Textures: []
m_Width: 48
m_Height: 48
m_Kind: 1
m_SubKind:
- m_Textures: []
m_Width: 36
m_Height: 36
m_Kind: 1
m_SubKind:
- m_Textures: []
m_Width: 192
m_Height: 192
m_Kind: 0
m_SubKind:
- m_Textures: []
m_Width: 144
m_Height: 144
m_Kind: 0
m_SubKind:
- m_Textures: []
m_Width: 96
m_Height: 96
m_Kind: 0
m_SubKind:
- m_Textures: []
m_Width: 72
m_Height: 72
m_Kind: 0
m_SubKind:
- m_Textures: []
m_Width: 48
m_Height: 48
m_Kind: 0
m_SubKind:
- m_Textures: []
m_Width: 36
m_Height: 36
m_Kind: 0
m_SubKind:
- m_BuildTarget: iPhone
m_Icons:
- m_Textures: []
@@ -774,7 +775,8 @@ PlayerSettings:
tvOS: DOTWEEN
additionalCompilerArguments: {}
platformArchitecture: {}
scriptingBackend: {}
scriptingBackend:
Android: 1
il2cppCompilerConfiguration: {}
il2cppCodeGeneration: {}
managedStrippingLevel: