Question

I'm attempting to run apps on an emulator and I'm experiencing some strange crashes, e.g.:

java.lang.NoSuchMethodError: android.telephony.SmsMessage.<init>

Certainly this should more or less be standard? Is this potentially a version error? I'm running on API 15; I believe the apk in question was built to an older version, although I don't know which (I'm in the process of installing and testing on older API versions).

Any thoughts on what could be going on here / approaches to get around it?

Thanks!

Was it helpful?

Solution

<init> stands for constructor, but if you'll take a look at the docs you'll realize, it has no constructor (actually it has, but it is private, take a look here), so you can't do something like that:

SmsMessage smsMessage = new SmsMessage();

EDIT The confusion is coming from the fact, that there are 2 versions of SmsMessage:

  1. The first one is coming from android.telephony.gsm.SmsMessage, was added at API level 1, but is deprecated since API level 4 and it has public constructor.
  2. The second one is coming from android.telephony.SmsMessage and replaces the version above since API level 4.

So, because you are getting such error, you imported the newest one android.telephony.SmsMessage and the code should be re-written to fit newer version of class.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top