Skip to content

Commit

Permalink
[Xamarin.Android.Build.Tasks] Add check for aapt2 invalid data path e…
Browse files Browse the repository at this point in the history
…rror (#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.
  • Loading branch information
dellis1972 authored and jonathanpeppers committed Feb 6, 2024
1 parent 751e845 commit 7a5784b
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Xamarin.Android.Build.Tasks/Tasks/Aapt2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,8 @@ static string GetErrorCode (string message)
Tuple.Create ("APT2262", "unexpected element <activity> found in <manifest>"),
Tuple.Create ("APT2263", "found in <manifest>"), // unexpected element <xxxxx> found in <manifest>
Tuple.Create ("APT2264", "The system cannot find the file specified. (2)"), // Windows Long Path error from aapt2
Tuple.Create ("APT2265", "The system cannot find the file specified. (2)") // Windows non-ASCII characters error from aapt2
Tuple.Create ("APT2265", "The system cannot find the file specified. (2)"), // Windows non-ASCII characters error from aapt2
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 ‘/’.
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,32 @@ public void ApplicationVersionTests (string applicationVersion, bool seperateApk
}
}

[Test]
public void ManifestDataPathError ()
{
var proj = new XamarinAndroidApplicationProject () {
IsRelease = true,
};
var s = proj.AndroidManifest.Replace ("</application>", @"<activity android:name=""net.openid.appauth.RedirectUriReceiverActivity"" android:exported=""true"">
<intent-filter>
<action android:name=""android.intent.action.VIEW""/>
<category android:name=""android.intent.category.DEFAULT""/>
<category android:name=""android.intent.category.BROWSABLE""/>
<data android:path=""code/buildproauth://com.hyphensolutions.buildpro"" android:scheme=""msauth""/>
<data android:path=""callback"" android:scheme=""buildproauth""/>
</intent-filter>
</activity>
</application>");
proj.AndroidManifest = s;
using (var builder = CreateApkBuilder (Path.Combine ("temp", TestContext.CurrentContext.Test.Name))) {
builder.ThrowOnBuildFailure = false;
Assert.IsFalse (builder.Build (proj), "Build should have failed.");
var messages = builder.LastBuildOutput.SkipWhile (x => !x.StartsWith ("Build FAILED.", StringComparison.Ordinal));
string error = messages.FirstOrDefault (x => x.Contains ("error APT2266:"));
Assert.IsNotNull (error, "Warning should be APT2266");
}
}

[Test]
public void ManifestPlaceholders ([Values ("legacy", "manifestmerger.jar")] string manifestMerger)
{
Expand Down

0 comments on commit 7a5784b

Please sign in to comment.