From c0f5f8fa3807c70590cb14a65117ee513245ace1 Mon Sep 17 00:00:00 2001 From: bitsandfoxes Date: Mon, 17 Jul 2023 15:29:06 +0200 Subject: [PATCH 1/5] accepting as hook now too --- .../Android/ProguardSetup.cs | 34 +++++++++++++++++-- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/src/Sentry.Unity.Editor/Android/ProguardSetup.cs b/src/Sentry.Unity.Editor/Android/ProguardSetup.cs index b119ac01e..d2e0c700b 100644 --- a/src/Sentry.Unity.Editor/Android/ProguardSetup.cs +++ b/src/Sentry.Unity.Editor/Android/ProguardSetup.cs @@ -32,7 +32,19 @@ public void RemoveFromGradleProject() } else { - var gradleNew = Regex.Replace(gradle, @"(\s+consumerProguardFiles .*), *'" + RuleFileName + "'", "$1"); + var pattern = string.Empty; + if (gradle.Contains("consumerProguardFiles")) + { + _logger.LogDebug("Detected `consumerProguardFiles`. Adding Sentry rules."); + pattern = @"(\s+consumerProguardFiles .*), *'"; + } + else if (gradle.Contains("proguardFiles")) + { + _logger.LogDebug("Detected `proguardFiles`. Adding Sentry rules."); + pattern = @"(\s+proguardFiles .*), *'"; + } + + var gradleNew = Regex.Replace(gradle, pattern + RuleFileName + "'", "$1"); if (gradle.Length == gradleNew.Length) { throw new Exception($"Couldn't remove Proguard rule {RuleFileName} from {_gradleScriptPath}."); @@ -66,10 +78,26 @@ public void AddToGradleProject() } else { - var gradleNew = Regex.Replace(gradle, @"(\s+consumerProguardFiles [^\r\n]*)", "$1, '" + RuleFileName + "'"); + string pattern; + if (gradle.Contains("consumerProguardFiles")) + { + _logger.LogDebug("Detected `consumerProguardFiles`. Adding Sentry rules."); + pattern = @"(\s+consumerProguardFiles [^\r\n]*)"; + } + else if (gradle.Contains("proguardFiles")) + { + _logger.LogDebug("Detected `proguardFiles`. Adding Sentry rules."); + pattern = @"(\s+proguardFiles [^\r\n]*)"; + } + else + { + throw new Exception($"Failed to find 'proguard rule section' in gradle file at: {_gradleScriptPath} - no `consumerProguardFiles` or `proguardFiles` found."); + } + + var gradleNew = Regex.Replace(gradle, pattern, "$1, '" + RuleFileName + "'"); if (gradle.Length == gradleNew.Length) { - throw new Exception($"Couldn't add Proguard rule {RuleFileName} to {_gradleScriptPath} - no `consumerProguardFiles` found."); + throw new Exception($"Couldn't add Proguard rule {RuleFileName} to {_gradleScriptPath}."); } File.WriteAllText(_gradleScriptPath, gradleNew); } From 27a0f46ad821ceee10569eb501925bc33d8b0fd0 Mon Sep 17 00:00:00 2001 From: bitsandfoxes Date: Mon, 17 Jul 2023 15:29:42 +0200 Subject: [PATCH 2/5] added tests --- .../Android/ProguardSetupTests.cs | 18 ++ .../AddingProguard/build.gradle_test_1.txt | 101 ++++++++ .../build.gradle_test_1_expected.txt | 101 ++++++++ .../AddingProguard/build.gradle_test_2.txt | 228 ++++++++++++++++++ .../build.gradle_test_2_expected.txt | 228 ++++++++++++++++++ 5 files changed, 676 insertions(+) create mode 100644 test/Sentry.Unity.Editor.Tests/TestFiles/Android/AddingProguard/build.gradle_test_1.txt create mode 100644 test/Sentry.Unity.Editor.Tests/TestFiles/Android/AddingProguard/build.gradle_test_1_expected.txt create mode 100644 test/Sentry.Unity.Editor.Tests/TestFiles/Android/AddingProguard/build.gradle_test_2.txt create mode 100644 test/Sentry.Unity.Editor.Tests/TestFiles/Android/AddingProguard/build.gradle_test_2_expected.txt diff --git a/test/Sentry.Unity.Editor.Tests/Android/ProguardSetupTests.cs b/test/Sentry.Unity.Editor.Tests/Android/ProguardSetupTests.cs index 8ec480ad7..30e5fbaaa 100644 --- a/test/Sentry.Unity.Editor.Tests/Android/ProguardSetupTests.cs +++ b/test/Sentry.Unity.Editor.Tests/Android/ProguardSetupTests.cs @@ -1,5 +1,6 @@ using System; using System.IO; +using System.Reflection; using System.Text.RegularExpressions; using NUnit.Framework; using Sentry.Unity.Editor.Android; @@ -67,6 +68,23 @@ public void AddsRuleFile(bool existsBefore) Assert.GreaterOrEqual(File.ReadAllText(ruleFile).Length, 1); } + [Test] + [TestCase("AddingProguard/build.gradle_test_1")] + [TestCase("AddingProguard/build.gradle_test_2")] + public void AddsRulesToGradleScript_ContainsConsumerProguardRules_MatchesExptectedOutput(string testCaseFileName) + { + var assemblyPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); + var testCasePath = Path.Combine(assemblyPath, "TestFiles", "Android", testCaseFileName + ".txt"); + var expectedPath = Path.Combine(assemblyPath, "TestFiles", "Android", testCaseFileName + "_expected.txt"); + + var actualOutputPath = Path.Combine(_outputPath, "build.gradle"); + File.Copy(testCasePath, actualOutputPath, true); + + GetSut().AddToGradleProject(); + + StringAssert.AreEqualIgnoringCase(File.ReadAllText(expectedPath), File.ReadAllText(actualOutputPath)); + } + [Test] [TestCase("\n")] [TestCase("\r\n")] diff --git a/test/Sentry.Unity.Editor.Tests/TestFiles/Android/AddingProguard/build.gradle_test_1.txt b/test/Sentry.Unity.Editor.Tests/TestFiles/Android/AddingProguard/build.gradle_test_1.txt new file mode 100644 index 000000000..5dd54c3fe --- /dev/null +++ b/test/Sentry.Unity.Editor.Tests/TestFiles/Android/AddingProguard/build.gradle_test_1.txt @@ -0,0 +1,101 @@ +// GENERATED BY UNITY. REMOVE THIS COMMENT TO PREVENT OVERWRITING WHEN EXPORTING AGAIN + +apply plugin: 'com.android.library' +apply plugin: 'kotlin-android' + + +dependencies { + implementation ('io.sentry:sentry-android:6.25.1') { exclude group: 'androidx.core' exclude group: 'androidx.lifecycle' } + implementation fileTree(dir: 'libs', include: ['*.jar']) + implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.4.31' +} + +android { + compileSdkVersion 30 + buildToolsVersion '30.0.2' + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + defaultConfig { + minSdkVersion 19 + targetSdkVersion 30 + ndk { + abiFilters 'arm64-v8a' + } + versionCode 1 + versionName '0.1' + consumerProguardFiles 'proguard-unity.txt', 'proguard-user.txt' + } + + lintOptions { + abortOnError false + } + + aaptOptions { + noCompress = ['.ress', '.resource', '.obb'] + unityStreamingAssets.tokenize(', ') + ignoreAssetsPattern = "!.svn:!.git:!.ds_store:!*.scc:.*:!CVS:!thumbs.db:!picasa.ini:!*~" + } + + packagingOptions { + doNotStrip '*/arm64-v8a/*.so' + } +} +repositories { + mavenCentral { content { excludeGroupByRegex "io\\.sentry.*" } } +} + +def getSdkDir() { + Properties local = new Properties() + local.load(new FileInputStream("${rootDir}/local.properties")) + return local.getProperty('sdk.dir') +} + +def BuildIl2Cpp(String workingDir, String targetDirectory, String architecture, String abi, String configuration) { + exec { + commandLine(workingDir + "/src/main/Il2CppOutputProject/IL2CPP/build/deploy/netcoreapp3.1/il2cpp", + "--compile-cpp", + "--avoid-dynamic-library-copy", + "--profiler-report", + "--libil2cpp-static", + "--platform=Android", + "--architecture=" + architecture, + "--configuration=" + configuration, + "--outputpath=" + workingDir + targetDirectory + abi + "/libil2cpp.so", + "--cachedirectory=" + workingDir + "/build/il2cpp_"+ abi + "_" + configuration + "/il2cpp_cache", + "--additional-include-directories=" + workingDir + "/src/main/Il2CppOutputProject/IL2CPP/external/bdwgc/include", + "--additional-include-directories=" + workingDir + "/src/main/Il2CppOutputProject/IL2CPP/libil2cpp/include", + "--tool-chain-path=" + android.ndkDirectory, + "--map-file-parser=" + workingDir + "/src/main/Il2CppOutputProject/IL2CPP/MapFileParser/MapFileParser.exe", + "--generatedcppdir=" + workingDir + "/src/main/Il2CppOutputProject/Source/il2cppOutput", + "--baselib-directory=" + workingDir + "/src/main/jniStaticLibs/" + abi, + "--dotnetprofile=unityaot") + environment "ANDROID_SDK_ROOT", getSdkDir() + } + delete workingDir + targetDirectory + abi + "/libil2cpp.sym.so" + ant.move(file: workingDir + targetDirectory + abi + "/libil2cpp.dbg.so", tofile: workingDir + "/symbols/" + abi + "/libil2cpp.so") +} + +android { + task BuildIl2CppTask { + doLast { + BuildIl2Cpp(projectDir.toString().replaceAll('\\\\', '/'), '/src/main/jniLibs/', 'ARM64', 'arm64-v8a', 'Release'); + } + } + afterEvaluate { + if (project(':unityLibrary').tasks.findByName('mergeDebugJniLibFolders')) + project(':unityLibrary').mergeDebugJniLibFolders.dependsOn BuildIl2CppTask + if (project(':unityLibrary').tasks.findByName('mergeReleaseJniLibFolders')) + project(':unityLibrary').mergeReleaseJniLibFolders.dependsOn BuildIl2CppTask + } + sourceSets { + main { + jni.srcDirs = ["src/main/Il2CppOutputProject"] + } + } +} + + + diff --git a/test/Sentry.Unity.Editor.Tests/TestFiles/Android/AddingProguard/build.gradle_test_1_expected.txt b/test/Sentry.Unity.Editor.Tests/TestFiles/Android/AddingProguard/build.gradle_test_1_expected.txt new file mode 100644 index 000000000..c934028d1 --- /dev/null +++ b/test/Sentry.Unity.Editor.Tests/TestFiles/Android/AddingProguard/build.gradle_test_1_expected.txt @@ -0,0 +1,101 @@ +// GENERATED BY UNITY. REMOVE THIS COMMENT TO PREVENT OVERWRITING WHEN EXPORTING AGAIN + +apply plugin: 'com.android.library' +apply plugin: 'kotlin-android' + + +dependencies { + implementation ('io.sentry:sentry-android:6.25.1') { exclude group: 'androidx.core' exclude group: 'androidx.lifecycle' } + implementation fileTree(dir: 'libs', include: ['*.jar']) + implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.4.31' +} + +android { + compileSdkVersion 30 + buildToolsVersion '30.0.2' + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + defaultConfig { + minSdkVersion 19 + targetSdkVersion 30 + ndk { + abiFilters 'arm64-v8a' + } + versionCode 1 + versionName '0.1' + consumerProguardFiles 'proguard-unity.txt', 'proguard-user.txt', 'proguard-sentry-unity.pro' + } + + lintOptions { + abortOnError false + } + + aaptOptions { + noCompress = ['.ress', '.resource', '.obb'] + unityStreamingAssets.tokenize(', ') + ignoreAssetsPattern = "!.svn:!.git:!.ds_store:!*.scc:.*:!CVS:!thumbs.db:!picasa.ini:!*~" + } + + packagingOptions { + doNotStrip '*/arm64-v8a/*.so' + } +} +repositories { + mavenCentral { content { excludeGroupByRegex "io\\.sentry.*" } } +} + +def getSdkDir() { + Properties local = new Properties() + local.load(new FileInputStream("${rootDir}/local.properties")) + return local.getProperty('sdk.dir') +} + +def BuildIl2Cpp(String workingDir, String targetDirectory, String architecture, String abi, String configuration) { + exec { + commandLine(workingDir + "/src/main/Il2CppOutputProject/IL2CPP/build/deploy/netcoreapp3.1/il2cpp", + "--compile-cpp", + "--avoid-dynamic-library-copy", + "--profiler-report", + "--libil2cpp-static", + "--platform=Android", + "--architecture=" + architecture, + "--configuration=" + configuration, + "--outputpath=" + workingDir + targetDirectory + abi + "/libil2cpp.so", + "--cachedirectory=" + workingDir + "/build/il2cpp_"+ abi + "_" + configuration + "/il2cpp_cache", + "--additional-include-directories=" + workingDir + "/src/main/Il2CppOutputProject/IL2CPP/external/bdwgc/include", + "--additional-include-directories=" + workingDir + "/src/main/Il2CppOutputProject/IL2CPP/libil2cpp/include", + "--tool-chain-path=" + android.ndkDirectory, + "--map-file-parser=" + workingDir + "/src/main/Il2CppOutputProject/IL2CPP/MapFileParser/MapFileParser.exe", + "--generatedcppdir=" + workingDir + "/src/main/Il2CppOutputProject/Source/il2cppOutput", + "--baselib-directory=" + workingDir + "/src/main/jniStaticLibs/" + abi, + "--dotnetprofile=unityaot") + environment "ANDROID_SDK_ROOT", getSdkDir() + } + delete workingDir + targetDirectory + abi + "/libil2cpp.sym.so" + ant.move(file: workingDir + targetDirectory + abi + "/libil2cpp.dbg.so", tofile: workingDir + "/symbols/" + abi + "/libil2cpp.so") +} + +android { + task BuildIl2CppTask { + doLast { + BuildIl2Cpp(projectDir.toString().replaceAll('\\\\', '/'), '/src/main/jniLibs/', 'ARM64', 'arm64-v8a', 'Release'); + } + } + afterEvaluate { + if (project(':unityLibrary').tasks.findByName('mergeDebugJniLibFolders')) + project(':unityLibrary').mergeDebugJniLibFolders.dependsOn BuildIl2CppTask + if (project(':unityLibrary').tasks.findByName('mergeReleaseJniLibFolders')) + project(':unityLibrary').mergeReleaseJniLibFolders.dependsOn BuildIl2CppTask + } + sourceSets { + main { + jni.srcDirs = ["src/main/Il2CppOutputProject"] + } + } +} + + + diff --git a/test/Sentry.Unity.Editor.Tests/TestFiles/Android/AddingProguard/build.gradle_test_2.txt b/test/Sentry.Unity.Editor.Tests/TestFiles/Android/AddingProguard/build.gradle_test_2.txt new file mode 100644 index 000000000..61dbfa47a --- /dev/null +++ b/test/Sentry.Unity.Editor.Tests/TestFiles/Android/AddingProguard/build.gradle_test_2.txt @@ -0,0 +1,228 @@ +// GENERATED BY UNITY. REMOVE THIS COMMENT TO PREVENT OVERWRITING WHEN EXPORTING AGAIN + +buildscript { + repositories { + google() + jcenter() + } + + dependencies { + classpath 'com.android.tools.build:gradle:3.4.2' +} +} + +allprojects { + repositories { + google() + jcenter() + flatDir { + dirs 'libs' + } + } +} + +// Android Resolver Repos Start +([rootProject] + (rootProject.subprojects as List)).each { project -> + project.repositories { + maven { + url "https://maven.google.com" + } + maven { + url (unityProjectPath + "/Assets/GeneratedLocalRepo/Firebase/m2repository") // Assets/Firebase/Editor/AnalyticsDependencies.xml:18, Assets/Firebase/Editor/AppDependencies.xml:22 + } + maven { + url "https://android-sdk.is.com/" // Assets/IronSource/Editor/IronSourceSDKDependencies.xml:9, Assets/IronSource/Editor/ISAdColonyAdapterDependencies.xml:16, Assets/IronSource/Editor/ISAdMobAdapterDependencies.xml:16, Assets/IronSource/Editor/ISAppLovinAdapterDependencies.xml:8, Assets/IronSource/Editor/ISAPSAdapterDependencies.xml:8, Assets/IronSource/Editor/ISChartboostAdapterDependencies.xml:8, Assets/IronSource/Editor/ISFacebookAdapterDependencies.xml:16, Assets/IronSource/Editor/ISFyberAdapterDependencies.xml:16, Assets/IronSource/Editor/ISInMobiAdapterDependencies.xml:8, Assets/IronSource/Editor/ISMintegralAdapterDependencies.xml:48, Assets/IronSource/Editor/ISPangleAdapterDependencies.xml:8, Assets/IronSource/Editor/ISTapJoyAdapterDependencies.xml:8, Assets/IronSource/Editor/ISUnityAdsAdapterDependencies.xml:8, Assets/IronSource/Editor/ISVungleAdapterDependencies.xml:16 + } + maven { + url "https://maven.google.com/" // Assets/IronSource/Editor/IronSourceSDKDependencies.xml:17, Assets/IronSource/Editor/IronSourceSDKDependencies.xml:25, Assets/IronSource/Editor/ISAdColonyAdapterDependencies.xml:8, Assets/IronSource/Editor/ISAdMobAdapterDependencies.xml:8, Assets/IronSource/Editor/ISAppLovinAdapterDependencies.xml:15, Assets/IronSource/Editor/ISChartboostAdapterDependencies.xml:15, Assets/IronSource/Editor/ISFacebookAdapterDependencies.xml:8, Assets/IronSource/Editor/ISInMobiAdapterDependencies.xml:22, Assets/IronSource/Editor/ISMintegralAdapterDependencies.xml:40, Assets/IronSource/Editor/ISUnityAdsAdapterDependencies.xml:15 + } + maven { + url "https://repo.maven.apache.org/maven2/" // Assets/IronSource/Editor/ISFyberAdapterDependencies.xml:8, Assets/IronSource/Editor/ISInMobiAdapterDependencies.xml:15 + } + maven { + url "https://dl-maven-android.mintegral.com/repository/mbridge_android_sdk_oversea/" // Assets/IronSource/Editor/ISMintegralAdapterDependencies.xml:8, Assets/IronSource/Editor/ISMintegralAdapterDependencies.xml:16, Assets/IronSource/Editor/ISMintegralAdapterDependencies.xml:24, Assets/IronSource/Editor/ISMintegralAdapterDependencies.xml:32 + } + maven { + url "https://artifact.bytedance.com/repository/pangle/" // Assets/IronSource/Editor/ISPangleAdapterDependencies.xml:15 + } + maven { + url "https://sdk.tapjoy.com/" // Assets/IronSource/Editor/ISTapJoyAdapterDependencies.xml:15 + } + maven { + url "https://jitpack.io/" // Assets/IronSource/Editor/ISVungleAdapterDependencies.xml:8 + } + mavenLocal() + mavenCentral() + } +} +// Android Resolver Repos End +apply plugin: 'com.android.library' + + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + +// Android Resolver Dependencies Start + implementation 'androidx.legacy:legacy-support-v4:1.0.0' // Assets/IronSource/Editor/ISInMobiAdapterDependencies.xml:22 + implementation 'androidx.recyclerview:recyclerview:1.2.1' // Assets/IronSource/Editor/ISMintegralAdapterDependencies.xml:40 + implementation 'com.adcolony:sdk:4.8.0' // Assets/IronSource/Editor/ISAdColonyAdapterDependencies.xml:8 + // implementation 'com.android.installreferrer:installreferrer:1.0' // Assets/Panteon/Editor/PanteonDependencies.xml:43 + implementation 'com.android.installreferrer:installreferrer:2.1' // Assets/AppsFlyer/Editor/AppsFlyerDependencies.xml:10 + implementation 'com.android.support:appcompat-v7:25.3.1' // Facebook.Unity.Editor.AndroidSupportLibraryResolver.addSupportLibraryDependency + // implementation 'com.android.support:cardview-v7:[26.0.0, 27.2.0[' // Assets/OneSignal/Editor/OneSignalDependencies.xml:7 + implementation 'com.android.support:cardview-v7:25.3.1' // Facebook.Unity.Editor.AndroidSupportLibraryResolver.addSupportLibraryDependency + // implementation 'com.android.support:customtabs:[26.0.0, 27.2.0[' // Assets/OneSignal/Editor/OneSignalDependencies.xml:8 + implementation 'com.android.support:customtabs:25.3.1' // Facebook.Unity.Editor.AndroidSupportLibraryResolver.addSupportLibraryDependency + implementation 'com.android.support:multidex:1+' // Packages/com.rocket.rocketad/Runtime/RocketResources/RocketAd/Editor/RocketAdDependencies.xml:5 + // implementation 'com.android.support:support-v4:[26.0.0, 27.2.0[' // Assets/OneSignal/Editor/OneSignalDependencies.xml:6 + implementation 'com.android.support:support-v4:25.3.1' // Facebook.Unity.Editor.AndroidSupportLibraryResolver.addSupportLibraryDependency + implementation 'com.applovin:applovin-sdk:11.7.1' // Assets/IronSource/Editor/ISAppLovinAdapterDependencies.xml:15 + implementation 'com.appsflyer:adrevenue:6.9.1' // Assets/AppsFlyer/Editor/AppsFlyerAdrevenueDependencies.xml:4 + implementation 'com.appsflyer:af-android-sdk:6.10.1' // Assets/AppsFlyer/Editor/AppsFlyerDependencies.xml:6 + implementation 'com.appsflyer:af-purchaseconnector-unity:1.0.3' // Assets/AppsFlyer/Editor/AppsFlyerPurchaseConnectorDependencies.xml:5 + implementation 'com.appsflyer:purchase-connector:1.0.0' // Assets/AppsFlyer/Editor/AppsFlyerPurchaseConnectorDependencies.xml:6 + implementation 'com.appsflyer:unity-adrevenue-generic-wrapper:6.9.1' // Assets/AppsFlyer/Editor/AppsFlyerAdrevenueDependencies.xml:5 + implementation 'com.appsflyer:unity-wrapper:6.10.1' // Assets/AppsFlyer/Editor/AppsFlyerDependencies.xml:8 + implementation 'com.chartboost:chartboost-sdk:9.2.0' // Assets/IronSource/Editor/ISChartboostAdapterDependencies.xml:15 + implementation 'com.facebook.android:audience-network-sdk:6.13.7' // Assets/IronSource/Editor/ISFacebookAdapterDependencies.xml:8 + implementation 'com.facebook.android:facebook-applinks:[16.0,17)' // Assets/FacebookSDK/Plugins/Editor/Dependencies.xml:6 + implementation 'com.facebook.android:facebook-core:[16.0,17)' // Assets/FacebookSDK/Plugins/Editor/Dependencies.xml:5 + implementation 'com.facebook.android:facebook-gamingservices:[16.0,17)' // Assets/FacebookSDK/Plugins/Editor/Dependencies.xml:9 + implementation 'com.facebook.android:facebook-login:[16.0,17)' // Assets/FacebookSDK/Plugins/Editor/Dependencies.xml:7 + implementation 'com.facebook.android:facebook-share:[16.0,17)' // Assets/FacebookSDK/Plugins/Editor/Dependencies.xml:8 + implementation 'com.fyber:marketplace-sdk:8.2.2' // Assets/IronSource/Editor/ISFyberAdapterDependencies.xml:8 + implementation 'com.google.android.gms:play-services-ads:21.5.0' // Assets/IronSource/Editor/ISAdMobAdapterDependencies.xml:8 + implementation 'com.google.android.gms:play-services-ads-identifier:18.0.1' // Assets/IronSource/Editor/IronSourceSDKDependencies.xml:17 + // implementation 'com.google.android.gms:play-services-base:[10.2.1, 12.1.0[' // Assets/OneSignal/Editor/OneSignalDependencies.xml:3 + implementation 'com.google.android.gms:play-services-base:18.2.0' // Assets/Firebase/Editor/AppDependencies.xml:17 + implementation 'com.google.android.gms:play-services-basement:18.1.0' // Assets/IronSource/Editor/IronSourceSDKDependencies.xml:25 + implementation 'com.google.android.gms:play-services-location:[10.2.1, 12.1.0[' // Assets/OneSignal/Editor/OneSignalDependencies.xml:5 + implementation 'com.google.firebase:firebase-analytics:21.3.0' // Assets/Firebase/Editor/AppDependencies.xml:15 + implementation 'com.google.firebase:firebase-analytics-unity:11.1.0' // Assets/Firebase/Editor/AnalyticsDependencies.xml:18 + implementation 'com.google.firebase:firebase-app-unity:11.1.0' // Assets/Firebase/Editor/AppDependencies.xml:22 + implementation 'com.google.firebase:firebase-common:20.3.2' // Assets/Firebase/Editor/AppDependencies.xml:13 + implementation 'com.google.firebase:firebase-messaging:[10.2.1, 12.1.0[' // Assets/OneSignal/Editor/OneSignalDependencies.xml:4 + implementation 'com.inmobi.monetization:inmobi-ads:10.1.2' // Assets/IronSource/Editor/ISInMobiAdapterDependencies.xml:15 + implementation 'com.ironsource.adapters:adcolonyadapter:4.3.14' // Assets/IronSource/Editor/ISAdColonyAdapterDependencies.xml:16 + implementation 'com.ironsource.adapters:admobadapter:4.3.36' // Assets/IronSource/Editor/ISAdMobAdapterDependencies.xml:16 + implementation 'com.ironsource.adapters:applovinadapter:4.3.37' // Assets/IronSource/Editor/ISAppLovinAdapterDependencies.xml:8 + implementation 'com.ironsource.adapters:apsadapter:4.3.8' // Assets/IronSource/Editor/ISAPSAdapterDependencies.xml:8 + implementation 'com.ironsource.adapters:chartboostadapter:4.3.11' // Assets/IronSource/Editor/ISChartboostAdapterDependencies.xml:8 + implementation 'com.ironsource.adapters:facebookadapter:4.3.40' // Assets/IronSource/Editor/ISFacebookAdapterDependencies.xml:16 + implementation 'com.ironsource.adapters:fyberadapter:4.3.24' // Assets/IronSource/Editor/ISFyberAdapterDependencies.xml:16 + implementation 'com.ironsource.adapters:inmobiadapter:4.3.17' // Assets/IronSource/Editor/ISInMobiAdapterDependencies.xml:8 + implementation 'com.ironsource.adapters:mintegraladapter:4.3.13' // Assets/IronSource/Editor/ISMintegralAdapterDependencies.xml:48 + implementation 'com.ironsource.adapters:pangleadapter:4.3.17' // Assets/IronSource/Editor/ISPangleAdapterDependencies.xml:8 + implementation 'com.ironsource.adapters:tapjoyadapter:4.1.24' // Assets/IronSource/Editor/ISTapJoyAdapterDependencies.xml:8 + implementation 'com.ironsource.adapters:unityadsadapter:4.3.28' // Assets/IronSource/Editor/ISUnityAdsAdapterDependencies.xml:8 + implementation 'com.ironsource.adapters:vungleadapter:4.3.20' // Assets/IronSource/Editor/ISVungleAdapterDependencies.xml:16 + implementation 'com.ironsource.sdk:mediationsdk:7.3.0.1' // Assets/IronSource/Editor/IronSourceSDKDependencies.xml:9 + implementation 'com.mbridge.msdk.oversea:mbbanner:16.3.81' // Assets/IronSource/Editor/ISMintegralAdapterDependencies.xml:24 + implementation 'com.mbridge.msdk.oversea:mbbid:16.3.81' // Assets/IronSource/Editor/ISMintegralAdapterDependencies.xml:32 + implementation 'com.mbridge.msdk.oversea:newinterstitial:16.3.81' // Assets/IronSource/Editor/ISMintegralAdapterDependencies.xml:8 + implementation 'com.mbridge.msdk.oversea:reward:16.3.81' // Assets/IronSource/Editor/ISMintegralAdapterDependencies.xml:16 + implementation 'com.pangle.global:ads-sdk:5.0.0.8' // Assets/IronSource/Editor/ISPangleAdapterDependencies.xml:15 + implementation 'com.parse.bolts:bolts-android:1.4.0' // Assets/FacebookSDK/Plugins/Editor/Dependencies.xml:4 + implementation 'com.tapjoy:tapjoy-android-sdk:12.11.1' // Assets/IronSource/Editor/ISTapJoyAdapterDependencies.xml:15 + implementation 'com.unity3d.ads:unity-ads:4.6.1' // Assets/IronSource/Editor/ISUnityAdsAdapterDependencies.xml:15 + implementation 'com.vungle:publisher-sdk-android:6.12.1' // Assets/IronSource/Editor/ISVungleAdapterDependencies.xml:8 +// Android Resolver Dependencies End + implementation(name: 'AndroidNative', ext:'aar') + implementation(name: 'billing-5.1.0', ext:'aar') + implementation(name: 'common', ext:'aar') + implementation(name: 'facebook-android-wrapper-16.0.0', ext:'aar') + implementation(name: 'onesignal-unity', ext:'aar') + implementation(name: 'PaperPlaneToolsAlert', ext:'aar') + implementation(name: 'sentry-android-core-release', ext:'aar') + implementation(name: 'sentry-android-ndk-release', ext:'aar') + implementation project('FirebaseApp.androidlib') + implementation project('IronSource.plugin') + implementation project('RocketAd.plugin') + implementation project('RocketGMAppsFlyer.plugin') + implementation project('unity-android-resources') +} + +// Android Resolver Exclusions Start +android { + packagingOptions { + exclude ('/lib/armeabi/*' + '*') + exclude ('/lib/mips/*' + '*') + exclude ('/lib/mips64/*' + '*') + exclude ('/lib/x86/*' + '*') + exclude ('/lib/x86_64/*' + '*') + } +} +// Android Resolver Exclusions End +android { + useLibrary 'org.apache.http.legacy' + compileSdkVersion 30 + buildToolsVersion '30.0.2' + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + defaultConfig { + minSdkVersion 21 + targetSdkVersion 30 + ndk { + abiFilters 'armeabi-v7a', 'arm64-v8a' + } + versionCode 66 + versionName '1.53' + multiDexEnabled true + } + + lintOptions { + abortOnError false + disable 'MissingTranslation' + } + + aaptOptions { + noCompress = ['.ress', '.resource', '.obb'] + unityStreamingAssets.tokenize(', ') + ignoreAssetsPattern = "!.svn:!.git:!.ds_store:!*.scc:.*:!CVS:!thumbs.db:!picasa.ini:!*~" + } + + + signingConfigs { + release { + storeFile file(HOMESWEETHOME_RELEASE_STORE_FILE) + storePassword HOMESWEETHOME_RELEASE_STORE_PASSWORD + keyAlias HOMESWEETHOME_RELEASE_KEY_ALIAS + keyPassword HOMESWEETHOME_RELEASE_KEY_PASSWORD + } + } + + buildTypes { + debug { + minifyEnabled true + + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-unity.txt', 'proguard-user.txt' + jniDebuggable true + } + release { + minifyEnabled true + + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-unity.txt', 'proguard-user.txt' + signingConfig signingConfigs.release + } + } + + packagingOptions { + doNotStrip '*/armeabi-v7a/*.so' + doNotStrip '*/arm64-v8a/*.so' + } + + bundle { + language { + enableSplit = false + } + density { + enableSplit = false + } + abi { + enableSplit = true + } + } +} diff --git a/test/Sentry.Unity.Editor.Tests/TestFiles/Android/AddingProguard/build.gradle_test_2_expected.txt b/test/Sentry.Unity.Editor.Tests/TestFiles/Android/AddingProguard/build.gradle_test_2_expected.txt new file mode 100644 index 000000000..9c74660d5 --- /dev/null +++ b/test/Sentry.Unity.Editor.Tests/TestFiles/Android/AddingProguard/build.gradle_test_2_expected.txt @@ -0,0 +1,228 @@ +// GENERATED BY UNITY. REMOVE THIS COMMENT TO PREVENT OVERWRITING WHEN EXPORTING AGAIN + +buildscript { + repositories { + google() + jcenter() + } + + dependencies { + classpath 'com.android.tools.build:gradle:3.4.2' +} +} + +allprojects { + repositories { + google() + jcenter() + flatDir { + dirs 'libs' + } + } +} + +// Android Resolver Repos Start +([rootProject] + (rootProject.subprojects as List)).each { project -> + project.repositories { + maven { + url "https://maven.google.com" + } + maven { + url (unityProjectPath + "/Assets/GeneratedLocalRepo/Firebase/m2repository") // Assets/Firebase/Editor/AnalyticsDependencies.xml:18, Assets/Firebase/Editor/AppDependencies.xml:22 + } + maven { + url "https://android-sdk.is.com/" // Assets/IronSource/Editor/IronSourceSDKDependencies.xml:9, Assets/IronSource/Editor/ISAdColonyAdapterDependencies.xml:16, Assets/IronSource/Editor/ISAdMobAdapterDependencies.xml:16, Assets/IronSource/Editor/ISAppLovinAdapterDependencies.xml:8, Assets/IronSource/Editor/ISAPSAdapterDependencies.xml:8, Assets/IronSource/Editor/ISChartboostAdapterDependencies.xml:8, Assets/IronSource/Editor/ISFacebookAdapterDependencies.xml:16, Assets/IronSource/Editor/ISFyberAdapterDependencies.xml:16, Assets/IronSource/Editor/ISInMobiAdapterDependencies.xml:8, Assets/IronSource/Editor/ISMintegralAdapterDependencies.xml:48, Assets/IronSource/Editor/ISPangleAdapterDependencies.xml:8, Assets/IronSource/Editor/ISTapJoyAdapterDependencies.xml:8, Assets/IronSource/Editor/ISUnityAdsAdapterDependencies.xml:8, Assets/IronSource/Editor/ISVungleAdapterDependencies.xml:16 + } + maven { + url "https://maven.google.com/" // Assets/IronSource/Editor/IronSourceSDKDependencies.xml:17, Assets/IronSource/Editor/IronSourceSDKDependencies.xml:25, Assets/IronSource/Editor/ISAdColonyAdapterDependencies.xml:8, Assets/IronSource/Editor/ISAdMobAdapterDependencies.xml:8, Assets/IronSource/Editor/ISAppLovinAdapterDependencies.xml:15, Assets/IronSource/Editor/ISChartboostAdapterDependencies.xml:15, Assets/IronSource/Editor/ISFacebookAdapterDependencies.xml:8, Assets/IronSource/Editor/ISInMobiAdapterDependencies.xml:22, Assets/IronSource/Editor/ISMintegralAdapterDependencies.xml:40, Assets/IronSource/Editor/ISUnityAdsAdapterDependencies.xml:15 + } + maven { + url "https://repo.maven.apache.org/maven2/" // Assets/IronSource/Editor/ISFyberAdapterDependencies.xml:8, Assets/IronSource/Editor/ISInMobiAdapterDependencies.xml:15 + } + maven { + url "https://dl-maven-android.mintegral.com/repository/mbridge_android_sdk_oversea/" // Assets/IronSource/Editor/ISMintegralAdapterDependencies.xml:8, Assets/IronSource/Editor/ISMintegralAdapterDependencies.xml:16, Assets/IronSource/Editor/ISMintegralAdapterDependencies.xml:24, Assets/IronSource/Editor/ISMintegralAdapterDependencies.xml:32 + } + maven { + url "https://artifact.bytedance.com/repository/pangle/" // Assets/IronSource/Editor/ISPangleAdapterDependencies.xml:15 + } + maven { + url "https://sdk.tapjoy.com/" // Assets/IronSource/Editor/ISTapJoyAdapterDependencies.xml:15 + } + maven { + url "https://jitpack.io/" // Assets/IronSource/Editor/ISVungleAdapterDependencies.xml:8 + } + mavenLocal() + mavenCentral() + } +} +// Android Resolver Repos End +apply plugin: 'com.android.library' + + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + +// Android Resolver Dependencies Start + implementation 'androidx.legacy:legacy-support-v4:1.0.0' // Assets/IronSource/Editor/ISInMobiAdapterDependencies.xml:22 + implementation 'androidx.recyclerview:recyclerview:1.2.1' // Assets/IronSource/Editor/ISMintegralAdapterDependencies.xml:40 + implementation 'com.adcolony:sdk:4.8.0' // Assets/IronSource/Editor/ISAdColonyAdapterDependencies.xml:8 + // implementation 'com.android.installreferrer:installreferrer:1.0' // Assets/Panteon/Editor/PanteonDependencies.xml:43 + implementation 'com.android.installreferrer:installreferrer:2.1' // Assets/AppsFlyer/Editor/AppsFlyerDependencies.xml:10 + implementation 'com.android.support:appcompat-v7:25.3.1' // Facebook.Unity.Editor.AndroidSupportLibraryResolver.addSupportLibraryDependency + // implementation 'com.android.support:cardview-v7:[26.0.0, 27.2.0[' // Assets/OneSignal/Editor/OneSignalDependencies.xml:7 + implementation 'com.android.support:cardview-v7:25.3.1' // Facebook.Unity.Editor.AndroidSupportLibraryResolver.addSupportLibraryDependency + // implementation 'com.android.support:customtabs:[26.0.0, 27.2.0[' // Assets/OneSignal/Editor/OneSignalDependencies.xml:8 + implementation 'com.android.support:customtabs:25.3.1' // Facebook.Unity.Editor.AndroidSupportLibraryResolver.addSupportLibraryDependency + implementation 'com.android.support:multidex:1+' // Packages/com.rocket.rocketad/Runtime/RocketResources/RocketAd/Editor/RocketAdDependencies.xml:5 + // implementation 'com.android.support:support-v4:[26.0.0, 27.2.0[' // Assets/OneSignal/Editor/OneSignalDependencies.xml:6 + implementation 'com.android.support:support-v4:25.3.1' // Facebook.Unity.Editor.AndroidSupportLibraryResolver.addSupportLibraryDependency + implementation 'com.applovin:applovin-sdk:11.7.1' // Assets/IronSource/Editor/ISAppLovinAdapterDependencies.xml:15 + implementation 'com.appsflyer:adrevenue:6.9.1' // Assets/AppsFlyer/Editor/AppsFlyerAdrevenueDependencies.xml:4 + implementation 'com.appsflyer:af-android-sdk:6.10.1' // Assets/AppsFlyer/Editor/AppsFlyerDependencies.xml:6 + implementation 'com.appsflyer:af-purchaseconnector-unity:1.0.3' // Assets/AppsFlyer/Editor/AppsFlyerPurchaseConnectorDependencies.xml:5 + implementation 'com.appsflyer:purchase-connector:1.0.0' // Assets/AppsFlyer/Editor/AppsFlyerPurchaseConnectorDependencies.xml:6 + implementation 'com.appsflyer:unity-adrevenue-generic-wrapper:6.9.1' // Assets/AppsFlyer/Editor/AppsFlyerAdrevenueDependencies.xml:5 + implementation 'com.appsflyer:unity-wrapper:6.10.1' // Assets/AppsFlyer/Editor/AppsFlyerDependencies.xml:8 + implementation 'com.chartboost:chartboost-sdk:9.2.0' // Assets/IronSource/Editor/ISChartboostAdapterDependencies.xml:15 + implementation 'com.facebook.android:audience-network-sdk:6.13.7' // Assets/IronSource/Editor/ISFacebookAdapterDependencies.xml:8 + implementation 'com.facebook.android:facebook-applinks:[16.0,17)' // Assets/FacebookSDK/Plugins/Editor/Dependencies.xml:6 + implementation 'com.facebook.android:facebook-core:[16.0,17)' // Assets/FacebookSDK/Plugins/Editor/Dependencies.xml:5 + implementation 'com.facebook.android:facebook-gamingservices:[16.0,17)' // Assets/FacebookSDK/Plugins/Editor/Dependencies.xml:9 + implementation 'com.facebook.android:facebook-login:[16.0,17)' // Assets/FacebookSDK/Plugins/Editor/Dependencies.xml:7 + implementation 'com.facebook.android:facebook-share:[16.0,17)' // Assets/FacebookSDK/Plugins/Editor/Dependencies.xml:8 + implementation 'com.fyber:marketplace-sdk:8.2.2' // Assets/IronSource/Editor/ISFyberAdapterDependencies.xml:8 + implementation 'com.google.android.gms:play-services-ads:21.5.0' // Assets/IronSource/Editor/ISAdMobAdapterDependencies.xml:8 + implementation 'com.google.android.gms:play-services-ads-identifier:18.0.1' // Assets/IronSource/Editor/IronSourceSDKDependencies.xml:17 + // implementation 'com.google.android.gms:play-services-base:[10.2.1, 12.1.0[' // Assets/OneSignal/Editor/OneSignalDependencies.xml:3 + implementation 'com.google.android.gms:play-services-base:18.2.0' // Assets/Firebase/Editor/AppDependencies.xml:17 + implementation 'com.google.android.gms:play-services-basement:18.1.0' // Assets/IronSource/Editor/IronSourceSDKDependencies.xml:25 + implementation 'com.google.android.gms:play-services-location:[10.2.1, 12.1.0[' // Assets/OneSignal/Editor/OneSignalDependencies.xml:5 + implementation 'com.google.firebase:firebase-analytics:21.3.0' // Assets/Firebase/Editor/AppDependencies.xml:15 + implementation 'com.google.firebase:firebase-analytics-unity:11.1.0' // Assets/Firebase/Editor/AnalyticsDependencies.xml:18 + implementation 'com.google.firebase:firebase-app-unity:11.1.0' // Assets/Firebase/Editor/AppDependencies.xml:22 + implementation 'com.google.firebase:firebase-common:20.3.2' // Assets/Firebase/Editor/AppDependencies.xml:13 + implementation 'com.google.firebase:firebase-messaging:[10.2.1, 12.1.0[' // Assets/OneSignal/Editor/OneSignalDependencies.xml:4 + implementation 'com.inmobi.monetization:inmobi-ads:10.1.2' // Assets/IronSource/Editor/ISInMobiAdapterDependencies.xml:15 + implementation 'com.ironsource.adapters:adcolonyadapter:4.3.14' // Assets/IronSource/Editor/ISAdColonyAdapterDependencies.xml:16 + implementation 'com.ironsource.adapters:admobadapter:4.3.36' // Assets/IronSource/Editor/ISAdMobAdapterDependencies.xml:16 + implementation 'com.ironsource.adapters:applovinadapter:4.3.37' // Assets/IronSource/Editor/ISAppLovinAdapterDependencies.xml:8 + implementation 'com.ironsource.adapters:apsadapter:4.3.8' // Assets/IronSource/Editor/ISAPSAdapterDependencies.xml:8 + implementation 'com.ironsource.adapters:chartboostadapter:4.3.11' // Assets/IronSource/Editor/ISChartboostAdapterDependencies.xml:8 + implementation 'com.ironsource.adapters:facebookadapter:4.3.40' // Assets/IronSource/Editor/ISFacebookAdapterDependencies.xml:16 + implementation 'com.ironsource.adapters:fyberadapter:4.3.24' // Assets/IronSource/Editor/ISFyberAdapterDependencies.xml:16 + implementation 'com.ironsource.adapters:inmobiadapter:4.3.17' // Assets/IronSource/Editor/ISInMobiAdapterDependencies.xml:8 + implementation 'com.ironsource.adapters:mintegraladapter:4.3.13' // Assets/IronSource/Editor/ISMintegralAdapterDependencies.xml:48 + implementation 'com.ironsource.adapters:pangleadapter:4.3.17' // Assets/IronSource/Editor/ISPangleAdapterDependencies.xml:8 + implementation 'com.ironsource.adapters:tapjoyadapter:4.1.24' // Assets/IronSource/Editor/ISTapJoyAdapterDependencies.xml:8 + implementation 'com.ironsource.adapters:unityadsadapter:4.3.28' // Assets/IronSource/Editor/ISUnityAdsAdapterDependencies.xml:8 + implementation 'com.ironsource.adapters:vungleadapter:4.3.20' // Assets/IronSource/Editor/ISVungleAdapterDependencies.xml:16 + implementation 'com.ironsource.sdk:mediationsdk:7.3.0.1' // Assets/IronSource/Editor/IronSourceSDKDependencies.xml:9 + implementation 'com.mbridge.msdk.oversea:mbbanner:16.3.81' // Assets/IronSource/Editor/ISMintegralAdapterDependencies.xml:24 + implementation 'com.mbridge.msdk.oversea:mbbid:16.3.81' // Assets/IronSource/Editor/ISMintegralAdapterDependencies.xml:32 + implementation 'com.mbridge.msdk.oversea:newinterstitial:16.3.81' // Assets/IronSource/Editor/ISMintegralAdapterDependencies.xml:8 + implementation 'com.mbridge.msdk.oversea:reward:16.3.81' // Assets/IronSource/Editor/ISMintegralAdapterDependencies.xml:16 + implementation 'com.pangle.global:ads-sdk:5.0.0.8' // Assets/IronSource/Editor/ISPangleAdapterDependencies.xml:15 + implementation 'com.parse.bolts:bolts-android:1.4.0' // Assets/FacebookSDK/Plugins/Editor/Dependencies.xml:4 + implementation 'com.tapjoy:tapjoy-android-sdk:12.11.1' // Assets/IronSource/Editor/ISTapJoyAdapterDependencies.xml:15 + implementation 'com.unity3d.ads:unity-ads:4.6.1' // Assets/IronSource/Editor/ISUnityAdsAdapterDependencies.xml:15 + implementation 'com.vungle:publisher-sdk-android:6.12.1' // Assets/IronSource/Editor/ISVungleAdapterDependencies.xml:8 +// Android Resolver Dependencies End + implementation(name: 'AndroidNative', ext:'aar') + implementation(name: 'billing-5.1.0', ext:'aar') + implementation(name: 'common', ext:'aar') + implementation(name: 'facebook-android-wrapper-16.0.0', ext:'aar') + implementation(name: 'onesignal-unity', ext:'aar') + implementation(name: 'PaperPlaneToolsAlert', ext:'aar') + implementation(name: 'sentry-android-core-release', ext:'aar') + implementation(name: 'sentry-android-ndk-release', ext:'aar') + implementation project('FirebaseApp.androidlib') + implementation project('IronSource.plugin') + implementation project('RocketAd.plugin') + implementation project('RocketGMAppsFlyer.plugin') + implementation project('unity-android-resources') +} + +// Android Resolver Exclusions Start +android { + packagingOptions { + exclude ('/lib/armeabi/*' + '*') + exclude ('/lib/mips/*' + '*') + exclude ('/lib/mips64/*' + '*') + exclude ('/lib/x86/*' + '*') + exclude ('/lib/x86_64/*' + '*') + } +} +// Android Resolver Exclusions End +android { + useLibrary 'org.apache.http.legacy' + compileSdkVersion 30 + buildToolsVersion '30.0.2' + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + defaultConfig { + minSdkVersion 21 + targetSdkVersion 30 + ndk { + abiFilters 'armeabi-v7a', 'arm64-v8a' + } + versionCode 66 + versionName '1.53' + multiDexEnabled true + } + + lintOptions { + abortOnError false + disable 'MissingTranslation' + } + + aaptOptions { + noCompress = ['.ress', '.resource', '.obb'] + unityStreamingAssets.tokenize(', ') + ignoreAssetsPattern = "!.svn:!.git:!.ds_store:!*.scc:.*:!CVS:!thumbs.db:!picasa.ini:!*~" + } + + + signingConfigs { + release { + storeFile file(HOMESWEETHOME_RELEASE_STORE_FILE) + storePassword HOMESWEETHOME_RELEASE_STORE_PASSWORD + keyAlias HOMESWEETHOME_RELEASE_KEY_ALIAS + keyPassword HOMESWEETHOME_RELEASE_KEY_PASSWORD + } + } + + buildTypes { + debug { + minifyEnabled true + + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-unity.txt', 'proguard-user.txt', 'proguard-sentry-unity.pro' + jniDebuggable true + } + release { + minifyEnabled true + + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-unity.txt', 'proguard-user.txt', 'proguard-sentry-unity.pro' + signingConfig signingConfigs.release + } + } + + packagingOptions { + doNotStrip '*/armeabi-v7a/*.so' + doNotStrip '*/arm64-v8a/*.so' + } + + bundle { + language { + enableSplit = false + } + density { + enableSplit = false + } + abi { + enableSplit = true + } + } +} From 52d405681a87b030a005e3a40068815ea9ea095d Mon Sep 17 00:00:00 2001 From: bitsandfoxes Date: Mon, 17 Jul 2023 15:35:16 +0200 Subject: [PATCH 3/5] fixed logging --- src/Sentry.Unity.Editor/Android/ProguardSetup.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Sentry.Unity.Editor/Android/ProguardSetup.cs b/src/Sentry.Unity.Editor/Android/ProguardSetup.cs index d2e0c700b..8cd479ab6 100644 --- a/src/Sentry.Unity.Editor/Android/ProguardSetup.cs +++ b/src/Sentry.Unity.Editor/Android/ProguardSetup.cs @@ -35,12 +35,12 @@ public void RemoveFromGradleProject() var pattern = string.Empty; if (gradle.Contains("consumerProguardFiles")) { - _logger.LogDebug("Detected `consumerProguardFiles`. Adding Sentry rules."); + _logger.LogDebug("Detected `consumerProguardFiles`. Removing Sentry rules."); pattern = @"(\s+consumerProguardFiles .*), *'"; } else if (gradle.Contains("proguardFiles")) { - _logger.LogDebug("Detected `proguardFiles`. Adding Sentry rules."); + _logger.LogDebug("Detected `proguardFiles`. Removing Sentry rules."); pattern = @"(\s+proguardFiles .*), *'"; } From 10fc183bb102e75f44d2817c03ad2767a5c6a23b Mon Sep 17 00:00:00 2001 From: bitsandfoxes Date: Mon, 17 Jul 2023 15:35:29 +0200 Subject: [PATCH 4/5] forgot the tests for removing --- .../Android/ProguardSetupTests.cs | 63 ++++++++----------- 1 file changed, 25 insertions(+), 38 deletions(-) diff --git a/test/Sentry.Unity.Editor.Tests/Android/ProguardSetupTests.cs b/test/Sentry.Unity.Editor.Tests/Android/ProguardSetupTests.cs index 30e5fbaaa..43d60610f 100644 --- a/test/Sentry.Unity.Editor.Tests/Android/ProguardSetupTests.cs +++ b/test/Sentry.Unity.Editor.Tests/Android/ProguardSetupTests.cs @@ -68,23 +68,6 @@ public void AddsRuleFile(bool existsBefore) Assert.GreaterOrEqual(File.ReadAllText(ruleFile).Length, 1); } - [Test] - [TestCase("AddingProguard/build.gradle_test_1")] - [TestCase("AddingProguard/build.gradle_test_2")] - public void AddsRulesToGradleScript_ContainsConsumerProguardRules_MatchesExptectedOutput(string testCaseFileName) - { - var assemblyPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); - var testCasePath = Path.Combine(assemblyPath, "TestFiles", "Android", testCaseFileName + ".txt"); - var expectedPath = Path.Combine(assemblyPath, "TestFiles", "Android", testCaseFileName + "_expected.txt"); - - var actualOutputPath = Path.Combine(_outputPath, "build.gradle"); - File.Copy(testCasePath, actualOutputPath, true); - - GetSut().AddToGradleProject(); - - StringAssert.AreEqualIgnoringCase(File.ReadAllText(expectedPath), File.ReadAllText(actualOutputPath)); - } - [Test] [TestCase("\n")] [TestCase("\r\n")] @@ -115,33 +98,37 @@ public void AddsRuleToGradleScript(string lineSeparator) } [Test] - [TestCase(false)] - [TestCase(true)] - public void RemovesRuleFromGradleScript(bool existsBefore) + [TestCase("AddingProguard/build.gradle_test_1")] + [TestCase("AddingProguard/build.gradle_test_2")] + public void AddsRulesToGradleScript_ContainsConsumerProguardRules_MatchesExpectedOutput(string testCaseFileName) { - var gradleScript = Path.Combine(_outputPath, "build.gradle"); + var assemblyPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); + var testCasePath = Path.Combine(assemblyPath, "TestFiles", "Android", testCaseFileName + ".txt"); + var expectedPath = Path.Combine(assemblyPath, "TestFiles", "Android", testCaseFileName + "_expected.txt"); - var expectedFinalScript = @" -android { - defaultConfig { - consumerProguardFiles 'proguard-unity.txt', 'proguard-user.txt', 'other-proguard.txt' - } -} -"; + var actualOutputPath = Path.Combine(_outputPath, "build.gradle"); + File.Copy(testCasePath, actualOutputPath, true); - File.WriteAllText(gradleScript, existsBefore ? @" -android { - defaultConfig { - consumerProguardFiles 'proguard-unity.txt', 'proguard-user.txt', '" + ProguardSetup.RuleFileName + @"', 'other-proguard.txt' - } -} -" : expectedFinalScript); + GetSut().AddToGradleProject(); - var sut = GetSut(); + StringAssert.AreEqualIgnoringCase(File.ReadAllText(expectedPath), File.ReadAllText(actualOutputPath)); + } - sut.RemoveFromGradleProject(); + [Test] + [TestCase("AddingProguard/build.gradle_test_1")] + [TestCase("AddingProguard/build.gradle_test_2")] + public void RemovesRuleFromGradleScript(string testCaseFileName) + { + var assemblyPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); + var testCasePath = Path.Combine(assemblyPath, "TestFiles", "Android", testCaseFileName + "_expected.txt"); + var expectedPath = Path.Combine(assemblyPath, "TestFiles", "Android", testCaseFileName + ".txt"); - Assert.AreEqual(File.ReadAllText(gradleScript), expectedFinalScript); + var actualOutputPath = Path.Combine(_outputPath, "build.gradle"); + File.Copy(testCasePath, actualOutputPath, true); + + GetSut().RemoveFromGradleProject(); + + StringAssert.AreEqualIgnoringCase(File.ReadAllText(expectedPath), File.ReadAllText(actualOutputPath)); } } } From da3d374a16d1e2982e8c88cdae999b8fe8dd2fc2 Mon Sep 17 00:00:00 2001 From: bitsandfoxes Date: Mon, 17 Jul 2023 15:46:07 +0200 Subject: [PATCH 5/5] Updated CHANGELOG.md --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a1c1c2d37..26c4b1930 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## Unreleased +### Fixes + +- The SDK now handles proguardfiles sections indicated by both `consumerProguardFiles` and `proguardFiles` ([#1401](https://github.com/getsentry/sentry-unity/pull/1401)) + ### Dependencies - Bump CLI from v2.19.1 to v2.19.4 ([#1387](https://github.com/getsentry/sentry-unity/pull/1387), [#1388](https://github.com/getsentry/sentry-unity/pull/1388))