[mono-android] Android Lint

Jonathan Pryor jonp at xamarin.com
Fri Oct 5 02:36:02 UTC 2012


On Oct 4, 2012, at 4:53 PM, hwrdprkns <taylorhp at gmail.com> wrote:
> Is there any way I can run Android lint (or a C# version of it) on my Mono-for-Android project?

It appears to work, at least to a limited degree, if you give it the obj\Debug directory:

	$ lint ProjectDir/obj/Debug

This will allow it to see your Java types (ACWs), assets, resources, etc, allowing you to do some validation:

	# for monodroid-samples/JetBoy
	$ lint obj/Debug

	Scanning android: .................................................................................................................................
	Scanning android (Phase 2): 
	android/AndroidManifest.xml:19: Warning: <uses-permission> tag appears after <application> tag [ManifestOrder]
	  <uses-permission android:name="android.permission.INTERNET" />
	  ^
	android/AndroidManifest.xml:12: Warning: Exported receiver does not require permission [ExportedReceiver]
	    <receiver android:name="mono.android.Seppuku">
	    ^
	android/AndroidManifest.xml:4: Warning: Avoid hardcoding the debug mode; leaving it out allows debug and release builds to automatically assign one [HardcodedDebugMode]
	  <application android:name="mono.android.app.Application" android:debuggable="true">
	                                                           ^
	Warning: The resource R.drawable.asteroid01 appears to be unused [UnusedResources]
	Warning: The resource R.drawable.asteroid02 appears to be unused [UnusedResources]
	...
	0 errors, 47 warnings 

This obviously can't scan your C# source code, but it may be better than nothing.

On the bright side, we finally have a way to determine what the correct element ordering within AndroidManifest.xml is. Alas, now you get warnings for everything. :-/

 - Jon



More information about the Monodroid mailing list