Я следую учебному пособию MVVM и при добавлении Зависимость помещения
1- Я получил эту ошибку при компиляции:
Note: Failed to read get kotlin metadata for [Ljava.lang.Object;@54d771f9
Note: Failed to read get kotlin metadata for [Ljava.lang.Object;@4c00a268
Note: Failed to read get kotlin metadata for [Ljava.lang.Object;@42104314
Note: Failed to read get kotlin metadata for [Ljava.lang.Object;@203b72ad
2- и это: (решено)
error: cannot find symbol class of
при добавлении этого кода в MainActivity
:
public class MainActivity extends AppCompatActivity {
private NoteViewModel noteViewModel;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//error is here in the ViewModelProviders.of
noteViewModel = new ViewModelProviders.of(this).get(NoteViewModel.class);
noteViewModel.getAllNotes().observe(this, notes -> {
//update RecyclerView
Toast.makeText(MainActivity.this, "onChanged", Toast.LENGTH_SHORT).show();
});
}
}
build.gradle (проект):
repositories {
google()
jcenter()
maven { url "https://kotlin.bintray.com/kotlinx/" }
}
allprojects {
repositories {
google()
jcenter()
maven { url "https://kotlin.bintray.com/kotlinx/" }
}
}
build.gradle (приложение):
room_version = "2.1.0-alpha06"
implementation "androidx.room:room-runtime:$room_version"
annotationProcessor "androidx.room:room-compiler:$room_version"