public void LibraryProjectZipWithLint()
        {
            var path = Path.Combine("temp", TestName);
            var lib  = new XamarinAndroidBindingProject()
            {
                ProjectName        = "BindingsProject",
                AndroidClassParser = "class-parse",
                Jars =
                {
                    new AndroidItem.LibraryProjectZip("fragment-1.2.2.aar")
                    {
                        WebContent = "https://maven.google.com/androidx/fragment/fragment/1.2.2/fragment-1.2.2.aar"
                    }
                },
                MetadataXml = @"<metadata><remove-node path=""/api/package[@name='androidx.fragment.app']/interface[@name='FragmentManager.OpGenerator']"" /></metadata>"
            };
            var app = new XamarinAndroidApplicationProject()
            {
                ProjectName = "App",
                IsRelease   = true,
                LinkTool    = "r8",
                References  = { new BuildItem.ProjectReference($"..\\{lib.ProjectName}\\{lib.ProjectName}.csproj", lib.ProjectName, lib.ProjectGuid) }
            };

            using (var libBuilder = CreateDllBuilder(Path.Combine(path, lib.ProjectName), cleanupAfterSuccessfulBuild: false))
                using (var appBuilder = CreateApkBuilder(Path.Combine(path, app.ProjectName))) {
                    Assert.IsTrue(libBuilder.Build(lib), "Library build should have succeeded.");
                    Assert.IsTrue(appBuilder.Build(app), "App build should have succeeded.");
                    StringAssertEx.DoesNotContain("warning : Missing class: com.android.tools.lint.detector.api.Detector", appBuilder.LastBuildOutput, "Build output should contain no warnings about com.android.tools.lint.detector.api.Detector");
                    var libraryProjects = Path.Combine(Root, appBuilder.ProjectDirectory, app.IntermediateOutputPath, "lp");
                    Assert.IsFalse(Directory.EnumerateFiles(libraryProjects, "lint.jar", SearchOption.AllDirectories).Any(),
                                   "`lint.jar` should not be extracted!");
                }
        }
Esempio n. 2
0
        public void GetDependencyNdkRequiredConditions(string property, bool ndkRequired)
        {
            var proj = new XamarinAndroidApplicationProject();

            proj.AotAssemblies = true;
            proj.SetProperty(property, "true");
            using (var builder = CreateApkBuilder()) {
                builder.Target = "GetAndroidDependencies";
                Assert.IsTrue(builder.Build(proj), "Build should have succeeded.");
                IEnumerable <string> taskOutput = builder.LastBuildOutput
                                                  .Select(x => x.Trim())
                                                  .SkipWhile(x => !x.StartsWith("Task \"CalculateProjectDependencies\""))
                                                  .SkipWhile(x => !x.StartsWith("Output Item(s):"))
                                                  .TakeWhile(x => !x.StartsWith("Done executing task \"CalculateProjectDependencies\""));
                if (ndkRequired)
                {
                    StringAssertEx.Contains("ndk-bundle", taskOutput, "ndk-bundle should be a dependency.");
                }
                else
                {
                    StringAssertEx.DoesNotContain("ndk-bundle", taskOutput, "ndk-bundle should not be a dependency.");
                }
            }
        }