From 086993946a4295dbcf516df66eed04ca99f035e8 Mon Sep 17 00:00:00 2001 From: Jonathan Peppers Date: Tue, 4 Sep 2018 21:40:22 -0500 Subject: [PATCH] WIP tests But the app project fails to build with: obj\Debug\android\src\mono\io\fabric\sdk\android\services\events\EventsStorageListenerImplementor.java(8,40): error: package io.fabric.sdk.android.services.events does not exist io.fabric.sdk.android.services.events.EventsStorageListener [C:\Users\jopepper\Desktop\Git\xamarin-android\bin\TestDebug\temp\ExtraAaptManifest\UnnamedProject.csproj] --- .../Xamarin.Android.Build.Tests/BuildTest.cs | 34 ++++++++++++ .../Android/KnownPackages.cs | 54 +++++++++++++++++++ 2 files changed, 88 insertions(+) diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest.cs index 437a3a67f49..6eac2595b07 100644 --- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest.cs +++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest.cs @@ -1853,6 +1853,40 @@ public void ApplicationIdPlaceholder () builder.Dispose (); } + [Test] + public void ExtraAaptManifest () + { + var proj = new XamarinAndroidApplicationProject (); + proj.MainActivity = proj.DefaultMainActivity.Replace ("base.OnCreate (bundle);", "base.OnCreate (bundle);\nCrashlytics.Crashlytics.HandleManagedExceptions();"); + var packages = proj.PackageReferences; + packages.Add (KnownPackages.Android_Arch_Core_Common_26_1_0); + packages.Add (KnownPackages.Android_Arch_Lifecycle_Common_26_1_0); + packages.Add (KnownPackages.Android_Arch_Lifecycle_Runtime_26_1_0); + packages.Add (KnownPackages.SupportCompat_27_0_2_1); + packages.Add (KnownPackages.SupportCoreUI_27_0_2_1); + packages.Add (KnownPackages.SupportCoreUtils_27_0_2_1); + packages.Add (KnownPackages.SupportDesign_27_0_2_1); + packages.Add (KnownPackages.SupportFragment_27_0_2_1); + packages.Add (KnownPackages.SupportMediaCompat_27_0_2_1); + packages.Add (KnownPackages.SupportV7AppCompat_27_0_2_1); + packages.Add (KnownPackages.Xamarin_Android_Crashlytics_2_9_4); + packages.Add (KnownPackages.Xamarin_Android_Crashlytics_Core_2_6_3); + packages.Add (KnownPackages.Xamarin_Android_Crashlytics_Beta_1_2_9); + packages.Add (KnownPackages.Xamarin_Android_Crashlytics_Answers_1_4_2); + packages.Add (KnownPackages.Xamarin_Firebase_Core_60_1142_1); + using (var builder = CreateApkBuilder (Path.Combine ("temp", TestName))) { + builder.ThrowOnBuildFailure = false; + builder.RequiresMSBuild = true; + builder.Target = "Restore"; + Assert.IsTrue (builder.Build (proj), "Restore should have succeeded."); + builder.Target = "Build"; + builder.Build (proj); //TODO: this fails with `package io.fabric.sdk.android.services.events does not exist`? + var manifest = File.ReadAllText (Path.Combine (Root, builder.ProjectDirectory, "obj", "Debug", "android", "AndroidManifest.xml")); + Assert.IsTrue (manifest.Contains ("android:authorities=\"UnnamedProject.UnnamedProject.crashlyticsinitprovider\""), "placeholder not replaced"); + Assert.IsFalse (manifest.Contains ("dollar_openBracket_applicationId_closeBracket"), "`aapt/AndroidManifest.xml` not ignored"); + } + } + [Test] public void ResourceExtraction () { diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Android/KnownPackages.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Android/KnownPackages.cs index 593d90a1f76..667b639af9a 100644 --- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Android/KnownPackages.cs +++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Android/KnownPackages.cs @@ -566,6 +566,60 @@ public static class KnownPackages } } }; + public static Package Xamarin_Android_Crashlytics_2_9_4 = new Package { + Id = "Xamarin.Android.Crashlytics", + Version = "2.9.4", + TargetFramework = "MonoAndroid60", + References = { + new BuildItem.Reference("Xamarin.Android.Crashlytics") { + MetadataValues = "HintPath=..\\packages\\Xamarin.Android.Crashlytics.2.9.4\\lib\\MonoAndroid60\\Xamarin.Android.Crashlytics.dll" + } + } + }; + public static Package Xamarin_Android_Crashlytics_Core_2_6_3 = new Package { + Id = "Xamarin.Android.Crashlytics.Core", + Version = "2.6.3", + TargetFramework = "MonoAndroid60", + References = { + new BuildItem.Reference("Xamarin.Android.Crashlytics.Core") { + MetadataValues = "HintPath=..\\packages\\Xamarin.Android.Crashlytics.Core.2.6.3\\lib\\MonoAndroid60\\Xamarin.Android.Crashlytics.Core.dll" + } + } + }; + public static Package Xamarin_Android_Crashlytics_Beta_1_2_9 = new Package { + Id = "Xamarin.Android.Crashlytics.Beta", + Version = "1.2.9", + TargetFramework = "MonoAndroid60", + References = { + new BuildItem.Reference("Xamarin.Android.Crashlytics.Beta") { + MetadataValues = "HintPath=..\\packages\\Xamarin.Android.Crashlytics.Beta.1.2.9\\lib\\MonoAndroid60\\Xamarin.Android.Crashlytics.Beta.dll" + } + } + }; + public static Package Xamarin_Android_Crashlytics_Answers_1_4_2 = new Package { + Id = "Xamarin.Android.Crashlytics.Answers", + Version = "1.4.2", + TargetFramework = "MonoAndroid60", + References = { + new BuildItem.Reference("Xamarin.Android.Crashlytics.Answers") { + MetadataValues = "HintPath=..\\packages\\Xamarin.Android.Crashlytics.Answers.1.4.2\\lib\\MonoAndroid60\\Xamarin.Android.Crashlytics.Answers.dll" + } + } + }; + public static Package Xamarin_Android_Fabric_1_4_3 = new Package { + Id = "Xamarin.Android.Fabric", + Version = "1.4.3", + TargetFramework = "MonoAndroid60", + References = { + new BuildItem.Reference("Xamarin.Android.Fabric") { + MetadataValues = "HintPath=..\\packages\\Xamarin.Android.Fabric.1.4.3\\lib\\MonoAndroid60\\Xamarin.Android.Fabric.dll" + } + } + }; + public static Package Xamarin_Firebase_Core_60_1142_1 = new Package { + Id = "Xamarin.Firebase.Core", + Version = "60.1142.1", + }; } }