skip to Main Content

Android Studio – Unit testing. java.lang.NullPointerException

everyone! I am writing unit tests for the mobile app. But I have an error that I don't know how to solve. The error has the following form: java.lang.NullPointerException at androidx.appcompat.app.AppCompatDelegateImpl.createSubDecor(AppCompatDelegateImpl.java:841) at androidx.appcompat.app.AppCompatDelegateImpl.ensureSubDecor(AppCompatDelegateImpl.java:806) at androidx.appcompat.app.AppCompatDelegateImpl.findViewById(AppCompatDelegateImpl.java:630) at androidx.appcompat.app.AppCompatActivity.findViewById(AppCompatActivity.java:223) at com.example.projectMP3.SplashScreenActivityTest.testLaunchOfNewActivity(SplashScreenActivityTest.java:14) at…

VIEW QUESTION

Android Studio – Why I can't find by id XML image

public class MainActivity extends AppCompatActivity { ListView listView; Button buttonForCP; ImageView img; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); buttonForCP =(Button) findViewById(R.id.buttonForCP); img = findViewById(R.drawable.ic_img);//this problem // |||||||||||||||||||||||||| buttonForCP.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { buttonForCP.setBackground(img); }…

VIEW QUESTION
Back To Top
Search