update: 更新 AndroidProjectMod 以修复打包时报错和各种问题
--story=1020956 --user=yufei.hu 【中台】【Android】构建插件 API 升级 34 验证 https://www.tapd.cn/33527076/s/1160300dev
							parent
							
								
									314aaaa88b
								
							
						
					
					
						commit
						3555b70ea7
					
				|  | @ -0,0 +1,31 @@ | ||||||
|  | allprojects { | ||||||
|  |     buildscript { | ||||||
|  |         repositories {**ARTIFACTORYREPOSITORY** | ||||||
|  |             google() | ||||||
|  |             jcenter() | ||||||
|  |             mavenCentral() | ||||||
|  |         } | ||||||
|  |          | ||||||
|  |         dependencies { | ||||||
|  |             // If you are changing the Android Gradle Plugin version, make sure it is compatible with the Gradle version preinstalled with Unity | ||||||
|  |             // See which Gradle version is preinstalled with Unity here https://docs.unity3d.com/Manual/android-gradle-overview.html | ||||||
|  |             // See official Gradle and Android Gradle Plugin compatibility table here https://developer.android.com/studio/releases/gradle-plugin#updating-gradle | ||||||
|  |             // To specify a custom Gradle version in Unity, go do "Preferences > External Tools", uncheck "Gradle Installed with Unity (recommended)" and specify a path to a custom Gradle version | ||||||
|  | //             classpath 'com.android.tools.build:gradle:4.0.1' | ||||||
|  |             classpath 'com.android.tools.build:gradle:7.4.2' | ||||||
|  |             **BUILD_SCRIPT_DEPS** | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     repositories {**ARTIFACTORYREPOSITORY** | ||||||
|  |         google() | ||||||
|  |         jcenter() | ||||||
|  |         flatDir { | ||||||
|  |             dirs "${project(':unityLibrary').projectDir}/libs" | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | task clean(type: Delete) { | ||||||
|  |     delete rootProject.buildDir | ||||||
|  | } | ||||||
|  | @ -0,0 +1,3 @@ | ||||||
|  | fileFormatVersion: 2 | ||||||
|  | guid: 210888b84fe449e88319129ae097514d | ||||||
|  | timeCreated: 1722245010 | ||||||
|  | @ -2,7 +2,6 @@ org.gradle.jvmargs=-Xmx**JVM_HEAP_SIZE**M | ||||||
| org.gradle.parallel=true | org.gradle.parallel=true | ||||||
| org.gradle.daemon=true | org.gradle.daemon=true | ||||||
| org.gradle.caching=true | org.gradle.caching=true | ||||||
| android.enableR8=**MINIFY_WITH_R_EIGHT** |  | ||||||
| unityStreamingAssets=**STREAMING_ASSETS** | unityStreamingAssets=**STREAMING_ASSETS** | ||||||
| # Android Resolver Properties Start | # Android Resolver Properties Start | ||||||
| android.useAndroidX=true | android.useAndroidX=true | ||||||
|  |  | ||||||
|  | @ -0,0 +1,41 @@ | ||||||
|  | apply plugin: 'com.android.library' | ||||||
|  | **APPLY_PLUGINS** | ||||||
|  | 
 | ||||||
|  | dependencies { | ||||||
|  |     implementation fileTree(dir: 'libs', include: ['*.jar']) | ||||||
|  | **DEPS**} | ||||||
|  | 
 | ||||||
|  | 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(', ') | ||||||
|  |         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,132 @@ | ||||||
|  | -keep class com.unity3d.plugin.* { *; } | ||||||
|  | 
 | ||||||
|  | #proguard-adjust.pro | ||||||
|  | -keep public class com.adjust.sdk.** { *; } | ||||||
|  | -keep class com.amazon.device.ads.** { *; }  | ||||||
|  | -keep class com.amazon.aps.** { *; }  | ||||||
|  | -keep class com.google.android.gms.ads.identifier.AdvertisingIdClient { | ||||||
|  |     com.google.android.gms.ads.identifier.AdvertisingIdClient$Info getAdvertisingIdInfo(android.content.Context); | ||||||
|  | } | ||||||
|  | -keep class com.google.android.gms.ads.identifier.AdvertisingIdClient$Info { | ||||||
|  |     java.lang.String getId(); | ||||||
|  |     boolean isLimitAdTrackingEnabled(); | ||||||
|  | } | ||||||
|  | -keep public class com.android.installreferrer.** { *; } | ||||||
|  | -keepclassmembers class com.ironsource.sdk.controller.IronSourceWebView$JSInterface { | ||||||
|  |     public *; | ||||||
|  | } | ||||||
|  | -keepclassmembers class * implements android.os.Parcelable { | ||||||
|  |     public static final android.os.Parcelable$Creator *; | ||||||
|  | } | ||||||
|  | -keep public class com.google.android.gms.ads.** { | ||||||
|  |     public *; | ||||||
|  | } | ||||||
|  | -keep class com.ironsource.adapters.** { *; } | ||||||
|  | -dontwarn com.ironsource.mediationsdk.** | ||||||
|  | -dontwarn com.ironsource.adapters.** | ||||||
|  | -keepattributes JavascriptInterface | ||||||
|  | -keepclassmembers class * { | ||||||
|  |     @android.webkit.JavascriptInterface <methods>; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | -keep class dalvik.system.VMRuntime { | ||||||
|  |     java.lang.String getRuntime(); | ||||||
|  | } | ||||||
|  | -keep class android.os.Build { | ||||||
|  |     java.lang.String[] SUPPORTED_ABIS; | ||||||
|  |     java.lang.String CPU_ABI; | ||||||
|  | } | ||||||
|  | -keep class android.content.res.Configuration { | ||||||
|  |     android.os.LocaleList getLocales(); | ||||||
|  |     java.util.Locale locale; | ||||||
|  | } | ||||||
|  | -keep class android.os.LocaledList { | ||||||
|  |     java.util.Locale get(int); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | #proguard-facebook.pro | ||||||
|  | -keep class com.facebook.** { *; } | ||||||
|  | -keepattributes Signature | ||||||
|  | -keep,allowobfuscation @interface com.facebook.common.internal.DoNotStrip | ||||||
|  | -keep @com.facebook.common.internal.DoNotStrip class * | ||||||
|  | -keep class com.facebook.stetho.** { *; } | ||||||
|  | -keepclassmembers class * { | ||||||
|  |     @com.facebook.common.internal.DoNotStrip *; | ||||||
|  | } | ||||||
|  | -keepclassmembers class * { | ||||||
|  |     native <methods>; | ||||||
|  | } | ||||||
|  | -dontwarn okio.** | ||||||
|  | -dontwarn javax.annotation.** | ||||||
|  | -dontwarn com.android.volley.toolbox.** | ||||||
|  | 
 | ||||||
|  | -keep class com.bytedance.sdk.** { *; } | ||||||
|  | -keep class com.pgl.sys.ces.* { *; } | ||||||
|  | -keep class com.facebook.** { *; } | ||||||
|  | -keep class com.google.android.play.core.** { *; } | ||||||
|  | -keep class com.google.games.bridge.** { *; } | ||||||
|  | -keep class com.google.android.gms.** { *; } | ||||||
|  | -keep class com.google.android.gms.games.leaderboard.** { *; } | ||||||
|  | -keep class com.google.android.gms.games.snapshot.** { *; } | ||||||
|  | -keep class com.google.android.gms.games.achievement.** { *; } | ||||||
|  | -keep class com.google.android.gms.games.event.** { *; } | ||||||
|  | -keep class com.google.android.gms.games.stats.** { *; } | ||||||
|  | -keep class com.google.android.gms.games.video.** { *; } | ||||||
|  | -keep class com.google.android.gms.games.* { *; } | ||||||
|  | -keep class com.google.android.gms.common.api.ResultCallback { *; } | ||||||
|  | -keep class com.google.android.gms.signin.** { *; } | ||||||
|  | -keep class com.google.android.gms.dynamic.** { *; } | ||||||
|  | -keep class com.google.android.gms.dynamite.** { *; } | ||||||
|  | -keep class com.google.android.gms.tasks.** { *; } | ||||||
|  | -keep class com.google.android.gms.security.** { *; } | ||||||
|  | -keep class com.google.android.gms.base.** { *; } | ||||||
|  | -keep class com.google.android.gms.actions.** { *; } | ||||||
|  | -keep class com.google.android.gms.common.ConnectionResult { *; } | ||||||
|  | -keep class com.google.android.gms.common.GooglePlayServicesUtil { *; } | ||||||
|  | -keep class com.google.android.gms.common.api.** { *; } | ||||||
|  | -keep class com.google.android.gms.common.data.DataBufferUtils { *; } | ||||||
|  | -keep class com.google.android.gms.games.quest.** { *; } | ||||||
|  | -keep class com.google.android.gms.nearby.** { *; } | ||||||
|  | -keep class com.google.android.gms.ads.** { *; } | ||||||
|  | 
 | ||||||
|  | -keep class com.pubmatic.sdk.** { *; } | ||||||
|  | -keep class com.applovin.** { *; } | ||||||
|  | -keep class com.chartboost.** { *; } | ||||||
|  | 
 | ||||||
|  | -keep class com.guru.** { *; } | ||||||
|  | -keep class guru.core.** { *; } | ||||||
|  | 
 | ||||||
|  | -keep class com.onevcat.uniwebview.* { *; } | ||||||
|  | -keep class com.iab.omid.* { *; } | ||||||
|  | 
 | ||||||
|  | -keep public class com.tradplus.** { *; } | ||||||
|  | -keep class com.tradplus.ads.** { *; } | ||||||
|  | -keep class com.applovin.mediation.adapters.** { *; } | ||||||
|  | 
 | ||||||
|  | -keep public class com.applovin.sdk.AppLovinSdk{ *; } | ||||||
|  | -keep public class com.applovin.sdk.AppLovin* { | ||||||
|  |     public protected *; | ||||||
|  | } | ||||||
|  | -keep public class com.applovin.nativeAds.AppLovin* { | ||||||
|  |     public protected *; | ||||||
|  | } | ||||||
|  | -keep public class com.applovin.adview.* { | ||||||
|  |     public protected *; | ||||||
|  | } | ||||||
|  | -keep public class com.applovin.mediation.* { | ||||||
|  |     public protected *; | ||||||
|  | } | ||||||
|  | -keep public class com.applovin.mediation.ads.* { | ||||||
|  |     public protected *; | ||||||
|  | } | ||||||
|  | -keep public class com.applovin.impl.*.AppLovin { | ||||||
|  |     public protected *; | ||||||
|  | } | ||||||
|  | -keep public class com.applovin.impl.**.*Impl { | ||||||
|  |     public protected *; | ||||||
|  | } | ||||||
|  | -keepclassmembers class com.applovin.sdk.AppLovinSdkSettings { | ||||||
|  |     private java.util.Map localSettings; | ||||||
|  | } | ||||||
|  | -keep class com.applovin.mediation.adapter.** { *; } | ||||||
|  | -keep class com.applovin.mediation.unity.** { *; } | ||||||
|  | @ -0,0 +1,3 @@ | ||||||
|  | fileFormatVersion: 2 | ||||||
|  | guid: a08608d11bf7483fa4c49df80ebab657 | ||||||
|  | timeCreated: 1722245439 | ||||||
|  | @ -0,0 +1,60 @@ | ||||||
|  | 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://verve.jfrog.io/artifactory/verve-gradle-release" // Packages/com.guru.unity.max/Mediation/Verve/Editor/Dependencies.xml:7 | ||||||
|  |         } | ||||||
|  |         maven { | ||||||
|  |             url (unityProjectPath + "/Assets/GeneratedLocalRepo/Firebase/m2repository") // Packages/com.google.firebase.firestore/Firebase/Editor/FirestoreDependencies.xml:20, Packages/com.google.firebase.app/Firebase/Editor/AppDependencies.xml:22, Packages/com.google.firebase.auth/Firebase/Editor/AuthDependencies.xml:20, Packages/com.google.firebase.messaging/Firebase/Editor/MessagingDependencies.xml:24, Packages/com.google.firebase.crashlytics/Firebase/Editor/CrashlyticsDependencies.xml:20, Packages/com.google.firebase.dynamic-links/Firebase/Editor/DynamicLinksDependencies.xml:20, Packages/com.google.firebase.installations/Firebase/Editor/InstallationsDependencies.xml:20, Packages/com.google.firebase.remote-config/Firebase/Editor/RemoteConfigDependencies.xml:20, Packages/com.google.firebase.analytics/Firebase/Editor/AnalyticsDependencies.xml:18 | ||||||
|  |         } | ||||||
|  |         maven { | ||||||
|  |             url "https://aws.oss.sonatype.org/content/repositories/releases/" // Packages/com.guru.unity.max/Amazon/Scripts/Editor/AmazonDependencies.xml:10 | ||||||
|  |         } | ||||||
|  |         maven { | ||||||
|  |             url "https://artifactory.bidmachine.io/bidmachine" // Packages/com.guru.unity.max/Mediation/BidMachine/Editor/Dependencies.xml:8 | ||||||
|  |         } | ||||||
|  |         maven { | ||||||
|  |             url "https://artifact.bytedance.com/repository/pangle" // Packages/com.guru.unity.max/Mediation/ByteDance/Editor/Dependencies.xml:8 | ||||||
|  |         } | ||||||
|  |         maven { | ||||||
|  |             url "https://cboost.jfrog.io/artifactory/chartboost-ads/" // Packages/com.guru.unity.max/Mediation/Chartboost/Editor/Dependencies.xml:8 | ||||||
|  |         } | ||||||
|  |         maven { | ||||||
|  |             url "https://android-sdk.is.com/" // Packages/com.guru.unity.max/Mediation/IronSource/Editor/Dependencies.xml:8 | ||||||
|  |         } | ||||||
|  |         maven { | ||||||
|  |             url "https://dl-maven-android.mintegral.com/repository/mbridge_android_sdk_oversea" // Packages/com.guru.unity.max/Mediation/Mintegral/Editor/Dependencies.xml:8 | ||||||
|  |         } | ||||||
|  |         maven { | ||||||
|  |             url "https://maven.ogury.co" // Packages/com.guru.unity.max/Mediation/OguryPresage/Editor/Dependencies.xml:8 | ||||||
|  |         } | ||||||
|  |         maven { | ||||||
|  |             url "https://s3.amazonaws.com/smaato-sdk-releases/" // Packages/com.guru.unity.max/Mediation/Smaato/Editor/Dependencies.xml:8 | ||||||
|  |         } | ||||||
|  |         maven { | ||||||
|  |             url "https://repo.pubmatic.com/artifactory/public-repos" // Packages/com.guru.unity.max/OpenWrapSDK/Editor/OpenWrapSDKDependencies.xml:18, Packages/com.guru.unity.max/OpenWrapSDK/Mediation/AppLovinMAX/Editor/ALOpenWrapMediationDependencies.xml:7 | ||||||
|  |         } | ||||||
|  |         mavenLocal() | ||||||
|  | // Android Resolver Repos End | ||||||
|  |         flatDir { | ||||||
|  |             dirs "${project(':unityLibrary').projectDir}/libs" | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | @ -0,0 +1,3 @@ | ||||||
|  | fileFormatVersion: 2 | ||||||
|  | guid: 4f7213bbbc8741bd89b3bd17a7bea43e | ||||||
|  | timeCreated: 1722240718 | ||||||
|  | @ -10,27 +10,43 @@ namespace Guru.Editor | ||||||
|      |      | ||||||
|     public class AndroidProjectMod |     public class AndroidProjectMod | ||||||
|     { |     { | ||||||
|         private static readonly int TargetSDKVersion = 33; |         private const int TargetSDKVersion = 34; | ||||||
|  |         private const string K_ANRDROID_PLUGINS_NAME = "Plugins/Android"; | ||||||
|          |          | ||||||
|         private static readonly string LauncherName = "launcherTemplate"; |         private const string LauncherName = "launcherTemplate"; | ||||||
|         private static string LauncherFullPath = Path.Combine(Application.dataPath, $"Plugins/Android/{LauncherName}.gradle"); |         private static string LauncherFullPath = Path.Combine(Application.dataPath, $"{K_ANRDROID_PLUGINS_NAME}/{LauncherName}.gradle"); | ||||||
|          |          | ||||||
|         private static readonly string MainName = "mainTemplate"; |         private const string MainName = "mainTemplate"; | ||||||
|         private static string MainFullPath = Path.Combine(Application.dataPath,  $"Plugins/Android/{MainName}.gradle"); |         private static string MainFullPath = Path.Combine(Application.dataPath,  $"{K_ANRDROID_PLUGINS_NAME}/{MainName}.gradle"); | ||||||
|          |          | ||||||
|         private static readonly string PropertiesName = "gradleTemplate"; |         private const string BaseProjectName = "baseProjectTemplate"; | ||||||
|         private static string PropertiesFullPath = Path.Combine(Application.dataPath,  $"Plugins/Android/{PropertiesName}.properties"); |         private static string BaseProjectFullPath = Path.Combine(Application.dataPath,  $"{K_ANRDROID_PLUGINS_NAME}/{BaseProjectName}.gradle"); | ||||||
|  |          | ||||||
|  |         private const string PropertiesName = "gradleTemplate"; | ||||||
|  |         private const string K_ENABLE_R8 = "android.enableR8"; | ||||||
|  |         private static string PropertiesFullPath = Path.Combine(Application.dataPath,  $"{K_ANRDROID_PLUGINS_NAME}/{PropertiesName}.properties"); | ||||||
|  |          | ||||||
|  |         private const string SettingsName = "settingsTemplate"; | ||||||
|  |         private static string SettingsFullPath = Path.Combine(Application.dataPath,  $"Plugins/Android/{SettingsName}.gradle"); | ||||||
|  |         private const string K_LINE_UNITYPROJECT = "def unityProjectPath"; | ||||||
|  |          | ||||||
|  |          | ||||||
|  |         private const string ProguardUserName = "proguard-user"; | ||||||
|  |         private static string ProguardUserFullPath = Path.Combine(Application.dataPath,  $"{K_ANRDROID_PLUGINS_NAME}/{ProguardUserName}.txt"); | ||||||
|          |          | ||||||
|         public static void Apply() |         public static void Apply() | ||||||
|         { |         { | ||||||
|             FixLauncher(); |             ApplyLauncher(); | ||||||
|             FixMain(); |             ApplyBaseProjectTemplates(); | ||||||
|             FixProperties(); |             ApplyMainTemplates(); | ||||||
|             CheckTargetSDKVersion(); |             ApplyGradleTemplate(); | ||||||
|  |             ApplySettings(); | ||||||
|  |             ApplyProguardUser(); | ||||||
|  |             CheckTargetSDKVersion();  // 强制修复构建版本号 | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|         private static void FixLauncher() |         private static void ApplyLauncher() | ||||||
|         { |         { | ||||||
|             if (!File.Exists(LauncherFullPath)) |             if (!File.Exists(LauncherFullPath)) | ||||||
|             { |             { | ||||||
|  | @ -64,7 +80,7 @@ namespace Guru.Editor | ||||||
|             File.WriteAllLines(LauncherFullPath, lines); |             File.WriteAllLines(LauncherFullPath, lines); | ||||||
| 
 | 
 | ||||||
|         } |         } | ||||||
|         private static void FixMain() |         private static void ApplyMainTemplates() | ||||||
|         { |         { | ||||||
|             if (!File.Exists(MainFullPath)) |             if (!File.Exists(MainFullPath)) | ||||||
|             { |             { | ||||||
|  | @ -72,13 +88,99 @@ namespace Guru.Editor | ||||||
|                 CopyFile($"{MainName}.txt", MainFullPath); |                 CopyFile($"{MainName}.txt", MainFullPath); | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|         private static void FixProperties() |          | ||||||
|  |         private static void ApplyBaseProjectTemplates() | ||||||
|  |         { | ||||||
|  |             if (!File.Exists(BaseProjectFullPath)) | ||||||
|  |             { | ||||||
|  |                 Debug.Log($"[MOD] --- Copy file to: {BaseProjectFullPath}"); | ||||||
|  |                 CopyFile($"{BaseProjectName}.txt", BaseProjectFullPath); | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |          | ||||||
|  |          | ||||||
|  |          | ||||||
|  |         private static void ApplyGradleTemplate() | ||||||
|         { |         { | ||||||
|             if (!File.Exists(PropertiesFullPath)) |             if (!File.Exists(PropertiesFullPath)) | ||||||
|             { |             { | ||||||
|                 Debug.Log($"[MOD] --- Copy file to: {PropertiesFullPath}"); |                 Debug.Log($"[MOD] --- Copy file to: {PropertiesFullPath}"); | ||||||
|                 CopyFile($"{PropertiesName}.txt", PropertiesFullPath); |                 CopyFile($"{PropertiesName}.txt", PropertiesFullPath); | ||||||
|             } |             } | ||||||
|  | 
 | ||||||
|  |             if (TargetSDKVersion > 33) | ||||||
|  |             { | ||||||
|  |                 FixGradleTemplate(PropertiesFullPath); | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         private static void FixGradleTemplate(string filePath) | ||||||
|  |         { | ||||||
|  |             if (File.Exists(filePath)) | ||||||
|  |             { | ||||||
|  |                 bool isDirty = false; | ||||||
|  |                 var lines = File.ReadAllLines(filePath); | ||||||
|  | 
 | ||||||
|  |                 for (int i = 0; i < lines.Length; i++) | ||||||
|  |                 { | ||||||
|  |                     if (lines[i].StartsWith(K_ENABLE_R8)) | ||||||
|  |                     { | ||||||
|  |                         lines[i] = $"# {lines[i]}"; // 禁用R8 | ||||||
|  |                         isDirty = true; | ||||||
|  |                         break; | ||||||
|  |                     } | ||||||
|  |                 } | ||||||
|  | 
 | ||||||
|  |                 if (isDirty) File.WriteAllLines(filePath, lines); | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  |         /// <summary> | ||||||
|  |         /// 写入所有的配置文件 | ||||||
|  |         /// </summary> | ||||||
|  |         private static void ApplySettings() | ||||||
|  |         { | ||||||
|  |             if (!File.Exists(SettingsFullPath)) | ||||||
|  |             { | ||||||
|  |                 CopyFile($"{SettingsName}.txt", SettingsFullPath); | ||||||
|  |             } | ||||||
|  |             FixProjectPathInSettings(SettingsFullPath); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  |         private static void FixProjectPathInSettings(string settingsPath) | ||||||
|  |         { | ||||||
|  |             bool isDirty = false; | ||||||
|  |             if (File.Exists(settingsPath)) | ||||||
|  |             { | ||||||
|  |                 string projectPath = Path.GetFullPath($"{Application.dataPath}/../").Replace("\\", "/"); | ||||||
|  |                 var lines = File.ReadAllLines(settingsPath); | ||||||
|  |                 for (int i = 0; i < lines.Length; i++) | ||||||
|  |                 { | ||||||
|  |                     if (lines[i].Contains(K_LINE_UNITYPROJECT)) | ||||||
|  |                     { | ||||||
|  |                         lines[i] = $"        def unityProjectPath = $/file:////{projectPath}/$.replace(\"\\\\\", \"/\")"; | ||||||
|  |                         isDirty = true; | ||||||
|  |                         break; | ||||||
|  |                     } | ||||||
|  |                 } | ||||||
|  |                  | ||||||
|  |                 if(isDirty) | ||||||
|  |                     File.WriteAllLines(settingsPath, lines); | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |          | ||||||
|  |          | ||||||
|  |         /// <summary> | ||||||
|  |         /// 写入所有的配置文件 | ||||||
|  |         /// </summary> | ||||||
|  |         private static void ApplyProguardUser() | ||||||
|  |         { | ||||||
|  |             if (!File.Exists(ProguardUserFullPath)) | ||||||
|  |             { | ||||||
|  |                 CopyFile($"{ProguardUserName}.txt", ProguardUserFullPath); | ||||||
|  |             } | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         private static void CheckTargetSDKVersion() |         private static void CheckTargetSDKVersion() | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue