Я занимаюсь разработкой Android Я реализовал комнату и получаю несколько ошибок из сборки
below errors
You can consider adding a type converter for it.
error: Cannot figure out how to save this field into database. You can consider adding a type converter for it.
error: cannot find symbol class DaggerBBCSportFragmentComponent
Room cannot create an SQLite connection to verify the queries. Query verification will be disabled. Error: [SQLITE_ERROR] SQL error
или отсутствует база данных (AUTOINCREMENT разрешено только для INTEGER PRIMARY KEY)
Каталог экспорта схемыне предоставляется процессору аннотаций, поэтому мы не можем экспортировать схему.Вы можете предоставить room.schemaLocation
аргумент процессора аннотации ИЛИ установить для exportSchema значение false.
ниже класса модели Article.java
@Entity
public class Article {
@PrimaryKey(autoGenerate = true)
@SerializedName("source")
@Expose
private Source source;
@SerializedName("author")
@Expose
@ColumnInfo(name = "author")
private String author;
@SerializedName("title")
@Expose
@ColumnInfo(name = "title")
private String title;
@SerializedName("description")
@Expose
@ColumnInfo(name = "description")
private String description;
@SerializedName("url")
@Expose
@ColumnInfo(name = "url")
private String url;
@SerializedName("urlToImage")
@Expose
@ColumnInfo(name = "urlToImage")
private String urlToImage;
@SerializedName("publishedAt")
@Expose
@ColumnInfo(name = "publishedAt")
private String publishedAt;
@SerializedName("content")
@Expose
@ColumnInfo(name = "content")
private String content;
public Source getSource() {
return source;
}
public void setSource(Source source) {
this.source = source;
}
public String getAuthor() {
return author;
}
public void setAuthor(String author) {
this.author = author;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public String getUrlToImage() {
return urlToImage;
}
public void setUrlToImage(String urlToImage) {
this.urlToImage = urlToImage;
}
public String getPublishedAt() {
return publishedAt;
}
public void setPublishedAt(String publishedAt) {
this.publishedAt = publishedAt;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
}
below database class
Database(entities = {Article.class}, version = 1)
public abstract class SportNewsDatabase extends RoomDatabase {
public abstract SportNewsDao databaseInterface();
@Override
protected SupportSQLiteOpenHelper createOpenHelper(DatabaseConfiguration config) {
return null;
}
@Override
protected InvalidationTracker createInvalidationTracker() {
return null;
}
}
below BBCSportNewsFragment
public class BBCSportFragment extends Fragment implements ArticleAdapter.ClickListener {
public List<Article> articleList = new ArrayList<>();
@ActivityContext
public Context activityContext;
@ApplicationContext
public Context mContext;
@BindView(R.id.recycler_view)
RecyclerView recyclerView;
BBCSportFragmentComponent bbcSportFragmentComponent;
BBCFragmentContextModule bbcFragmentContextModule;
private SportNews sportNews;
private ArticleAdapter articleAdapter;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_bbcsport, container, false);
Activity activity = getActivity();
ButterKnife.bind(this, view);
SportInterface sportInterface = SportClient.getApiService();
Call<SportNews> call = sportInterface.getArticles();
call.enqueue(new Callback<SportNews>() {
@Override
public void onResponse(Call<SportNews> call, Response<SportNews> response) {
sportNews = response.body();
if (sportNews != null && sportNews.getArticles() != null) {
articleList.addAll(sportNews.getArticles());
}
articleAdapter = new ArticleAdapter(articleList, sportNews);
ApplicationComponent applicationComponent = MyApplication.get(Objects.requireNonNull(activity)).getApplicationComponent();
// bbcSportFragmentComponent = (BBCSportFragmentComponent) DaggerApplicationComponent.builder().contextModule(new ContextModule(getContext())).build();
bbcSportFragmentComponent = (BBCSportFragmentComponent) DaggerBBCSportFragmentComponent.builder().applicationComponent(applicationComponent).build();
bbcSportFragmentComponent.injectBBCSportFragment(BBCSportFragment.this);
RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(getContext());
recyclerView.setLayoutManager(layoutManager);
recyclerView.setAdapter(articleAdapter);
}
@Override
public void onFailure(Call<SportNews> call, Throwable t) {
Log.e("Error", "error");
}
});
return view;
}
}
below Dao class
@Dao
public interface SportNewsDao {
@Query("SELECT * FROM article")
List<Article> getArticles();
@Insert
void insertAll(Article... article);
}