-1

related question: startActivity(intent) doesn't work in some devices

I tested out with LUNA(5.0.2) from TG&CO and Galaxy J5 2016(6.0.1) from SAMSUNG, PHAB 2 PRO from LENOVO, SKY IM-100 from Pantech.

They doesn't work with

startActivity(this, MainActivity::class.java)
startActivity(this@SplashActivity, MainActivity::class.java)

I guess a lot of things related to context. This shows this error:

java.lang.NoClassDefFoundError: com.example.view.main.MainActivity

Try-catch doesn't work either. I tested more than 20 devices. And only those devices have the problem.

What's wrong with the devices?

c-an
  • 3,543
  • 5
  • 35
  • 82
  • have you tried check the context is null or not? – Rofie Sagara Oct 04 '19 at 09:11
  • No, But I tested more than 20 devices. And only those devices have the problem. Include Pixel phones and Samsung Galaxy 9. – c-an Oct 04 '19 at 09:12
  • check this https://stackoverflow.com/questions/26702179/failing-to-launch-activity-due-to-classnotfoundexception – Rofie Sagara Oct 04 '19 at 09:15
  • I'm pretty sure it might happen when we copy multiple file from other package but forget to rename them on destination. It build perfectly but on runtime it lead to error. – nfl-x Oct 04 '19 at 09:27
  • Well, I guess It is a device specific problem because all popular phones don't have any problems. – c-an Oct 04 '19 at 09:31

1 Answers1

0

Well, It happened because of I used some Interfaces but didn't implement them completely. It had a red line at the first line of the class. I don't know how it is able to build the project. Anyway, It built the project perfectly and worked fine with popular phones. But didn't work with the phones that I mentioned above.

After fixing this problem, All the phones worked fine. If you know the reason why they work like this, Please comment.

c-an
  • 3,543
  • 5
  • 35
  • 82