Skip to content

Commit 705bb47

Browse files
authored
[Xamarin.Android.Build.Tasks] Add check for aapt2 invalid data path error (#8640)
Fixes https://dev.azure.com/devdiv/DevDiv/_workitems/edit/1922983 Our error matching in Aapt2.cs did not include a new error message which has been introduced. As a result we got a APT2000 error instead of an actual error message which we get for other errors.
1 parent 8e65135 commit 705bb47

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

src/Xamarin.Android.Build.Tasks/Tasks/Aapt2.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,8 @@ static string GetErrorCode (string message)
541541
Tuple.Create ("APT2262", "unexpected element <activity> found in <manifest>"),
542542
Tuple.Create ("APT2263", "found in <manifest>"), // unexpected element <xxxxx> found in <manifest>
543543
Tuple.Create ("APT2264", "The system cannot find the file specified. (2)"), // Windows Long Path error from aapt2
544-
Tuple.Create ("APT2265", "The system cannot find the file specified. (2)") // Windows non-ASCII characters error from aapt2
544+
Tuple.Create ("APT2265", "The system cannot find the file specified. (2)"), // Windows non-ASCII characters error from aapt2
545+
Tuple.Create ("APT2266", "in <data> tag has value of") // error: attribute ‘android:path’ in <data> tag has value of ‘code/fooauth://com.foo.foo, it must start with a leading slash ‘/’.
545546
};
546547
}
547548
}

src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/ManifestTest.cs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -559,6 +559,32 @@ public void ApplicationVersionTests (string applicationVersion, bool seperateApk
559559
}
560560
}
561561

562+
[Test]
563+
public void ManifestDataPathError ()
564+
{
565+
var proj = new XamarinAndroidApplicationProject () {
566+
IsRelease = true,
567+
};
568+
var s = proj.AndroidManifest.Replace ("</application>", @"<activity android:name=""net.openid.appauth.RedirectUriReceiverActivity"" android:exported=""true"">
569+
<intent-filter>
570+
<action android:name=""android.intent.action.VIEW""/>
571+
<category android:name=""android.intent.category.DEFAULT""/>
572+
<category android:name=""android.intent.category.BROWSABLE""/>
573+
<data android:path=""code/buildproauth://com.hyphensolutions.buildpro"" android:scheme=""msauth""/>
574+
<data android:path=""callback"" android:scheme=""buildproauth""/>
575+
</intent-filter>
576+
</activity>
577+
</application>");
578+
proj.AndroidManifest = s;
579+
using (var builder = CreateApkBuilder (Path.Combine ("temp", TestContext.CurrentContext.Test.Name))) {
580+
builder.ThrowOnBuildFailure = false;
581+
Assert.IsFalse (builder.Build (proj), "Build should have failed.");
582+
var messages = builder.LastBuildOutput.SkipWhile (x => !x.StartsWith ("Build FAILED.", StringComparison.Ordinal));
583+
string error = messages.FirstOrDefault (x => x.Contains ("error APT2266:"));
584+
Assert.IsNotNull (error, "Warning should be APT2266");
585+
}
586+
}
587+
562588
[Test]
563589
public void ManifestPlaceholders ([Values ("legacy", "manifestmerger.jar")] string manifestMerger)
564590
{

0 commit comments

Comments
 (0)