Jake Wharton mentioned this library in a recent conversation, and it looks like a great way to avoid loading the template, so I let it go. But without success.
https://github.com/SimonVT/schematic
The following is a definition of a content provider with an annotation attached and a manifest provider element. The problem is that Android Studio does not like the definition of the provider, because the content provider class does not extend the ContentProvider.
Caused by: java.lang.ClassCastException: com.myapp.SchematicContentProvider
cannot be cast to android.content.ContentProvider
What am I missing? This may be due to android-apt, which I don't use (the scheme recommends, but doesn't seem to require it) - when I try to use android-apt, I get VerifyError, so I had to remove it from the assembly.
AndroidManifest.xml
<provider
android:name="com.myapp.SchematicContentProvider"
android:authorities="com.myapp.provider"
android:exported="false" />
And class definition:
import net.simonvt.schematic.annotation.ContentProvider;
import net.simonvt.schematic.annotation.ContentUri;
import net.simonvt.schematic.annotation.TableEndpoint;
@ContentProvider(authority = SchematicContentProvider.AUTHORITY, database = SchematicDatabase.class)
public class SchematicContentProvider {
public static final String AUTHORITY = "com.myapp.provider";
interface Path {
String ROUTES = "routes";
}
@TableEndpoint(table = SchematicDatabase.ROUTES) public static class Routes {
@ContentUri(path = Path.ROUTES, type = "vnd.android.cursor.dir/list", defaultSort = SchematicRouteColumns.TITLE + " ASC")
public static final Uri ROUTES = Uri.parse("content://" + AUTHORITY + "/" + Path.ROUTES );
}
}
Schematic ( readme ), , . , , , ? , BuildConfig Schematic.
, , .