暫無描述
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

GradleProperty.cs 963B

1234567891011121314151617181920212223242526272829303132
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using System.Linq;
  5. using System.Text;
  6. using System.IO;
  7. public class UniWebViewGradlePropertyPatcher {
  8. public static void Patch(string filePath) {
  9. string[] lines = File.ReadAllLines(filePath);
  10. bool hasAndroidXProperty = lines.Any(text => text.Contains("android.useAndroidX"));
  11. bool hasJetifierProperty = lines.Any(text => text.Contains("android.enableJetifier"));
  12. StringBuilder builder = new StringBuilder();
  13. foreach(string each in lines) {
  14. builder.AppendLine(each);
  15. }
  16. if (!hasAndroidXProperty) {
  17. builder.AppendLine("android.useAndroidX=true");
  18. }
  19. if (!hasJetifierProperty && UniWebViewEditorSettings.GetOrCreateSettings().enableJetifier) {
  20. builder.AppendLine("android.enableJetifier=true");
  21. }
  22. File.WriteAllText(filePath, builder.ToString());
  23. }
  24. }