Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lint gives incorrect MissingPrefix error #2360

Closed
sdebruyn opened this issue Oct 31, 2018 · 0 comments
Closed

Lint gives incorrect MissingPrefix error #2360

sdebruyn opened this issue Oct 31, 2018 · 0 comments
Labels
Area: App+Library Build Issues when building Library projects or Application projects. bug Component does not function as intended.
Milestone

Comments

@sdebruyn
Copy link
Contributor

sdebruyn commented Oct 31, 2018

Steps to Reproduce

  1. Create a Xamarin.Android project, set minimum API level to 24 and target API level to 27
  2. Set build property AndroidLintEnabled to true
  3. Add an XML resource where you have xmlns:app="http://schemas.android.com/apk/res-auto" in the root element
  4. Add an element that uses this namespace:
<TextView
            android:id="@+id/tv_itemaccountability_line"
            android:layout_width="150dp"
            android:layout_height="wrap_content"
            android:layout_marginBottom="8dp"
            android:layout_marginStart="8dp"
            android:layout_marginTop="8dp"
            android:gravity="left|center"
            style="@style/AccountabilityItemTextView"
            app:MvxBind="Text Line"
            app:layout_constraintBottom_toTopOf="@+id/ln_itemaccountability_line"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent" />
  1. Build with target SignAndroidPackage (or just deploy)

Important side note:
My Android app project also references an Android library project.

Expected Behavior

No errors of type MissingPrefix

Actual Behavior

In the build log:

(My build configuration is Development)

obj/Development/obj/Development/res/layout/item_accountability.xml(1,559): error XA0103:  Unexpected namespace prefix "app" found for tag TextView [MissingPrefix] [/path/to/my/project.csproj]

Version Information

=== Visual Studio Enterprise 2017 for Mac ===

Version 7.6.10 (build 27)
Installation UUID: e1324239-09f8-4ef0-841d-818a176fdfbd
Runtime:
	Mono 5.12.0.309 (2018-02/39d89a335c8) (64-bit)
	GTK+ 2.24.23 (Raleigh theme)
	Xamarin.Mac 4.4.1.178 (master / eeaeb7e6)

	Package version: 512000309

=== NuGet ===

Version: 4.3.1.4445

=== .NET Core ===

Runtime: /usr/local/share/dotnet/dotnet
Runtime Versions:
	2.1.2
	2.1.1
	2.1.0
	2.0.7
	2.0.5
SDK: /usr/local/share/dotnet/sdk/2.1.302/Sdks
SDK Versions:
	2.1.302
	2.1.301
	2.1.300
	2.1.200
	2.1.4
MSBuild SDKs: /Library/Frameworks/Mono.framework/Versions/5.12.0/lib/mono/msbuild/15.0/bin/Sdks

=== Xamarin.Profiler ===

Version: 1.6.3
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler

=== Apple Developer Tools ===

Xcode 10.0 (14320.25)
Build 10A255

=== Xamarin.Mac ===

Version: 5.0.0.0 (Visual Studio Enterprise)
Hash: b40230c0
Branch: 
Build date: 2018-09-27 11:41:37-0400

=== Xamarin.iOS ===

Version: 12.0.0.15 (Visual Studio Enterprise)
Hash: 84552a46
Branch: xcode10
Build date: 2018-09-17 21:54:33-0400

=== Xamarin.Android ===

Version: 9.0.0.20 (Visual Studio Enterprise)
Android SDK: /Users/sam/Library/Android/sdk
	Supported Android versions:
		5.0 (API level 21)
		6.0 (API level 23)
		7.0 (API level 24)
		7.1 (API level 25)
		8.0 (API level 26)
		8.1 (API level 27)

SDK Tools Version: 26.1.1
SDK Platform Tools Version: 28.0.1
SDK Build Tools Version: 28.0.3

Java SDK: /usr
java version "1.8.0_172"
Java(TM) SE Runtime Environment (build 1.8.0_172-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.172-b11, mixed mode)

Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL

=== Xamarin Inspector ===

Version: 1.4.3
Hash: db27525
Branch: 1.4-release
Build date: Mon, 09 Jul 2018 21:20:18 GMT
Client compatibility: 1

=== Build Information ===

Release ID: 706100027
Git revision: 94dbd4d35daaa5a2ff6a51c3fd5cbb2308bd83ea
Build date: 2018-10-18 16:34:31+00
Build branch: release-7.6
Xamarin extensions: 3a9afc960ba73e5862829e8a0cd9369bcca43d70

=== Operating System ===

Mac OS X 10.14.0
Darwin 18.0.0 Darwin Kernel Version 18.0.0
    Wed Aug 22 20:13:40 PDT 2018
    root:xnu-4903.201.2~1/RELEASE_X86_64 x86_64

=== Enabled user installed extensions ===

Android Signature Tool 2.1.2
Gist Ide Information 1.1.0
MSBuild Editor 2.0.4
NuGet Package Explorer 0.2
NuGet Package Management Extensions 0.13
xUnit.NET 2 testing framework support 0.7.5

Log File

See above.

@dellis1972 dellis1972 added this to the d16-0 milestone Nov 2, 2018
@dellis1972 dellis1972 added bug Component does not function as intended. Area: App+Library Build Issues when building Library projects or Application projects. labels Nov 2, 2018
dellis1972 added a commit to dellis1972/xamarin-android that referenced this issue Nov 2, 2018
Fixes dotnet#2360, dotnet#2361, dotnet#2362, dotnet#2363

When running the `Lint` checks on an application we
provide a path to a `project` directory. This is
currently the `$(IntermediateOutputPath)`. The problem
with this is that it also includes the `lp` directory.
The `lp` directory contains ALL the resources and
Manifest files for the library projects. As a result
if you are referencing support packages ALL of those
items are checked too.

It turns out that most of the Manifest files shipped
with the libraries are not complete or will cause
`lint` errors or warnings.

So what we need to do is point the `lint` check at
the `$(IntermediateOutputPath)android`. This will restrict
the checks to the files which the Build system
produces (the java code, and the final app manifest).

This PR includes an updated unit test which tests all
the issues raised in the bug reports.
jonpryor pushed a commit that referenced this issue Nov 2, 2018
Fixes: #2360
Fixes: #2361
Fixes: #2362
Fixes: #2363

When running the `<Lint/>` checks on an application we provide a path
to a `project` directory.  This was `$(IntermediateOutputPath)`.  The
problem with `$(IntermediateOutputPath)` is that it also includes the
`lp` directory, which contains ***all*** the resources and
`AndroidManifest.xml` files for all referenced library projects.  As
a result if you are referencing support packages all of those items
are checked too.

It turns out that most of the `AndroidManifest.xml` files shipped
with the support libraries are not complete or will cause `lint`
errors or warnings.

What we need to do is instead point the `lint` check at the
`$(IntermediateOutputPath)android` directory.  This will restrict the
checks to the files which the Build system produces (the java code,
and the final `AndroidManifest.xml` file).
@ghost ghost locked as resolved and limited conversation to collaborators Jun 7, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Area: App+Library Build Issues when building Library projects or Application projects. bug Component does not function as intended.
Projects
None yet
Development

No branches or pull requests

2 participants