Ad
Room Persistence Library (dependency Issue), MVVM Design Pattern
Iam following MVVM tutorial and when adding Room dependency
1- I got this this error in compile:
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- also this: (SOLVED)
error: cannot find symbol class of
when adding this code in 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(project):
repositories { google() jcenter() maven { url "https://kotlin.bintray.com/kotlinx/" } } allprojects { repositories { google() jcenter() maven { url "https://kotlin.bintray.com/kotlinx/" } } }
build.gradle(app):
room_version = "2.1.0-alpha06" implementation "androidx.room:room-runtime:$room_version" annotationProcessor "androidx.room:room-compiler:$room_version"
Ad
Answer
remove new
,
this will work:
noteViewModel = ViewModelProviders.of(this).get(NoteViewModel.class);
Ad
source: stackoverflow.com
Related Questions
- → should I choose reactjs+f7 or f7+vue.js?
- → Phonegap Android write to sd card
- → Local reference jquery script in nanohttpd (Android)
- → Click to navigate on mobile devices
- → How to allow api access to android or ios app only(laravel)?
- → Access the Camera and CameraRoll on Android using React Native?
- → React native change listening port
- → What is the default unit of style in React Native?
- → Google play market autocomplete icon
- → Warning: Each child in an array or iterator should have a unique "key" prop. Check the render method of `ListView`
- → Using Laravel with Genymotion
- → react native using like web-based ajax function
- → react native pdf View
Ad