In the process of error localization, I found that the application "flies" on the line with the findViewById method (I removed all unnecessary from the code, but I have everything that I haven’t put in here, commented out):
public class AddItem extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_add_item); } LinearLayout AddItemContainer = (LinearLayout) findViewById(R.id.AddItemContainer); } It is strange that everything worked fine before, and I have not touched this line since. What could be the reason?
(We get into this activity from another activity; this also works fine if we remove the line with findViewById ).
Update
Cut from error message:
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'android.view.Window $ Callback android.view.Window.getCallback ()' on a null object reference