Activity calls the Isdestroyed () method to report that the Java.lang.NoSuchMethodError

Source: Internet
Author: User

During the test of the app, the activity called the Isdestroyed () method and reported a java.lang.NoSuchMethodError error.

Own mobile Mi 2S, version 4.1.1.

In fact, the reason is isdestroyed () This method is introduced in 4.2, so the 4.1.1 on the increase in this method will be an error.

Need to make a version of the judgment, Build.VERSION.SDK_INT < 17.


So the question is, how do you judge the version introduced by a function? From the Android developer site, you'll find

Actually want to see in the source code, but there is no description in the source code.

Https://developer.android.com/reference/android/app/Activity.html#isDestroyed ()



Summary: There are several points to note when calling a method:

(1) Note the API version number introduced by this method;

(2) It is best not to call @deprecated tag classes and methods, as the third party may delete the source code that is @deprecated tagged;

(3) Mark @hide is also best not to call, remember when beginners, quite a lot of people use the way of reflection to obtain private data and call the appropriate method, at that time, it was quite a research spirit;


Focus: When you are now standing in the perspective of maintenance, a lot of users in your products, a variety of different mobile phones, models appear, resulting in different bugs. It makes sense to follow the above rules.


Attach some of the better articles:

Spiritual Brother speaks Crash (i): Unsatisfiedlinkerror

Spiritual Brother speaks Crash (ii): Java.lang.NoSuchMethodError

Little Lori said crash (a): Unrecognized selector sent to instance xxxx



Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Activity calls the Isdestroyed () method to report that the Java.lang.NoSuchMethodError

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.