Bug 57860 - AndroidManifest.xml line numbers off by one
Summary: AndroidManifest.xml line numbers off by one
Status: CONFIRMED
Alias: None
Product: Android
Classification: Xamarin
Component: MSBuild ()
Version: 8.0 (15.4)
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: dean.ellis
URL:
Depends on:
Blocks:
 
Reported: 2017-06-29 14:03 UTC by Edward Brey
Modified: 2017-07-10 06:14 UTC (History)
3 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report for Bug 57860 on Developer Community or GitHub if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: Developer Community HTML or GitHub Markdown
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:
Status:
CONFIRMED

Description Edward Brey 2017-06-29 14:03:15 UTC
If you have an error in AndroidManifest.xml, the line number that appears in the Visual Studio Output window is off by one line. For example, I ran into this error:

3>C:\Users\Brey\Code\Watertight\Mobile.Android\obj\Debug\android\manifest\AndroidManifest.xml(11): error APT0000:  Error: No resource found that matches the given name (at 'icon' with value '@drawable/icon').

However, the error was really on line 10, not line 11. The same was true for the other errors in the file.
Comment 1 Jon Douglas [MSFT] 2017-07-05 16:30:29 UTC
Hi Edward,

Can you please attach a sample project that is in the state of showing this error? Perhaps this can be fixed with some better linting or ensuring the line numbers match up. 

What I believe is happening is that you are being mislead by the Properties\AndroidManifest.xml's line number vs. the final generated in obj\Debug\android\AndroidManifest.xml

Here's an example:

I have 5 lines in my Properties\AndroidManifest.xml(It's hard to show if Bugzilla word wraps, but stay with me):

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="App21.App21" android:versionCode="1" android:versionName="1.0">
  <uses-sdk android:minSdkVersion="16" />
  <application android:label="App21" android:icon="@drawable/icon1"></application>
</manifest>

This generates the following error on Line 8 (Which shouldn't even exist because I only have 5 lines!)


Error: No resource found that matches the given name (at 'icon' with value '@drawable/icon1').	App21	c:\users\dougl\documents\visual studio 2017\Projects\App21\App21\obj\Debug\android\manifest\AndroidManifest.xml	8	

However if I look at Line 8 of the generated obj\Debug\android\AndroidManifest.xml

It does indeed fall on the correct line number:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="App21.App21" android:versionCode="1" android:versionName="1.0">
  <!--suppress UsesMinSdkAttributes-->
  <uses-sdk android:minSdkVersion="16" />
  <uses-permission android:name="android.permission.INTERNET" />
  <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
  <application android:label="App21" android:icon="@drawable/icon1" android:name="android.app.Application" android:allowBackup="true" android:debuggable="true">
    <activity android:icon="@drawable/icon" android:label="App21" android:name="md5c19661293df25ab8ed245319da3cf45c.MainActivity">
      <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
      </intent-filter>
    </activity>
    <provider android:name="mono.MonoRuntimeProvider" android:exported="false" android:initOrder="2147483647" android:authorities="App21.App21.mono.MonoRuntimeProvider.__mono_init__" />
    <!--suppress ExportedReceiver-->
    <receiver android:name="mono.android.Seppuku">
      <intent-filter>
        <action android:name="mono.android.intent.action.SEPPUKU" />
        <category android:name="mono.android.intent.category.SEPPUKU.App21.App21" />
      </intent-filter>
    </receiver>
  </application>
</manifest>

Thus I am marking this bug as NEEDINFO until we have a sample project demonstrating the 1-off scenario.
Comment 2 Edward Brey 2017-07-08 13:07:51 UTC
Here's a repro:

1. Create a new blank C# Android project.
2. In AndroidManifest.xml, change the application element to look like this:

<application android:label="MyAndroidProject" android:noelement="none"></application>

3. Build.

The result is this error:

AndroidManifest.xml(8): error APT0000:  No resource identifier found for attribute 'noelement' in package 'android'

4. Double-click the error.

The result is that it takes you to line 8 of the generated AndroidManifest.xml. However, the error is actually on line 7.
Comment 3 Prashant [MSFT] 2017-07-10 06:14:43 UTC
As per the comment #2, I am able to reproduce this issue the line number reported is a always +1 in the generated manifest file in obj\Debug\android\manifest\AndroidManifest.xml (see comment #1)