1.Android 报错:Attempt to invoke virtual method...on a null object reference
For this error, I made a binding error, that is
ImageView imageview==getView().findViewById(R.id.x) The id of x is modified in the xml file, but whether it is modified to the extent that the xml text is the main one.
2. Android报错: java.lang.IllegalArgumentException: navigation destination com.example.appcomputer2:id/action_home1Fragment_to_home3Fragment is unknown to this NavController
Translated into Chinese as: Illegal parameter exception: Navigation destination xxx is unknown to this navigation controller
It took me two days of vacation to find a solution to this hot chicken bug. Although I know it is a small navigation problem, for a novice, I still don’t know how to solve it. Through trial and error, I also want to avoid this problem, but this problem seems to be unavoidable. It tortured me for two days. Finally, I found this related problem on a website, but the method given by the answerer of the website seems to be helpful to me. The problem is not applicable. Although it is the same bug, the error may be in different ways. It is best to solve this problem smoothly with the help of my lovely seniors.
Solution: First check the xml file in the navigation, carefully review the name, id, destination, etc. to make sure nothing goes wrong. I just made a mistake in the name
After modification: android:name="com.example.myapplication3.game4Fragment"
The following is the Android learning website I found, share it!