Bug 16678 - Subclassing SQLiteOpenHelper results in a compiler error
Summary: Subclassing SQLiteOpenHelper results in a compiler error
Alias: None
Product: Android
Classification: Xamarin
Component: General ()
Version: 4.10.1
Hardware: PC All
: --- normal
Target Milestone: ---
Assignee: Jonathan Pryor
Depends on:
Reported: 2013-12-09 11:43 UTC by John Carruthers
Modified: 2013-12-09 12:15 UTC (History)
1 user (show)

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 on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description John Carruthers 2013-12-09 11:43:16 UTC
A recent update to Xamarin.Android has introduced a compiler bug.

When creating a subclass from android.database.sqlite.SQLiteOpenHelper with the following code:

	public class ConfigurationStore : SQLiteOpenHelper
		private const string DATABASE_NAME = "Adjutant";
		private const int DATABASE_VERSION = 1;

		public override void OnCreate (SQLiteDatabase db)
				CREATE TABLE Config (
          			ConfigName TEXT NOT NULL,
          			Contents TEXT NOT NULL

		public override void OnUpgrade (SQLiteDatabase db, int oldVersion, int newVersion)


		public ConfigurationStore(Context context) : base(context, DATABASE_NAME, null, DATABASE_VERSION)

		public string LoadFromDb(string dbName)
			string ret = null;
			using (var cursor = ReadableDatabase.RawQuery("select * from Config where ConfigName = ?", new [] { dbName }))
				while (cursor.MoveToNext())
					ret = cursor.GetString(1);
			return ret;

		public void SaveToDb(string dbName, string str)
			var values = new ContentValues();
			values.Put("ConfigName", dbName);
			values.Put("Contents", str);
			if (LoadFromDb(dbName) == null)
				WritableDatabase.Insert("Config", null, values);
				WritableDatabase.Update("Config", values, "ConfigName = ?", new [] { dbName });

		public static ConfigurationStore Instance { get; set; }

the compiler fails with the following error:

api\ConfigurationStore.java(159,159): Error:  cannot find symbol
symbol  : class DatabaseErrorHandler
location: package android.database
	public ConfigurationStore (android.content.Context p0, java.lang.String p1, android.database.sqlite.SQLiteDatabase.CursorFactory p2, int p3, android.database.DatabaseErrorHandler p4) throws java.lang.Throwable

I am using Xamarin Studio to create and compile my projects.
Comment 1 Jonathan Pryor 2013-12-09 12:15:05 UTC
Discussed on IRC.

The problem was that his App project set $(TargetFrameworkVersion) to v4.0.3 (API-15) while the Properties\AndroidManifest.xml contained a //uses-sdk/@android:targetSdkVersion value of 10 (API-10).

$(TargetFrameworkVersion) is used to control which constructors are generated (all constructor prototypes are always generated, not just those in C#), while //uses-sdk/@android:targetSdkVersion controls which types/members `javac` will see. There is thus an implicit requirement that //uses-sdk/@android:targetSdkVersion be >= $(TargetFrameworkVersion), which was not the case here.

Changing //uses-sdk/@android:targetSdkVersion to be >= $(TargetFrameworkVersion) fixed the compilation error.