Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6824819
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T21:56:50+00:00 2026-05-26T21:56:50+00:00

Log.d(TAG, Build.VERSION_CODES.ICE_CREAM_SANDWICH: + Build.VERSION_CODES.ICE_CREAM_SANDWICH); I write code like this, I used the sdk4.0 to

  • 0
Log.d(TAG, "Build.VERSION_CODES.ICE_CREAM_SANDWICH: " + Build.VERSION_CODES.ICE_CREAM_SANDWICH);

I write code like this, I used the sdk4.0 to compile this android program, so it didn’t cause compile error. When I run this program in my phone that running android 2.3.4, it run well.

Why? I am confused that version 2.3.4 (api level 10) has Build.VERSION_CODES.ICE_CREAM_SANDWICH property? And when I used sdk2.3.4 will cause compile error.

More

I test some code like these below,

private ScaleGestureDetector mScaleGestureDetector;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ECLAIR_MR1) {
    mScaleGestureDetector = new ScaleGestureDetector(this, new MyOnScaleGestureListener());
}

this code will run well on android 1.6 api level 4, but

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ECLAIR_MR1) {
    Log.d(TAG, "getx(0): " + event.getX(0));
}

this program run failed on android 1.6 api level 4.

They both run on android 2.3.4 well.

why? (In ScaleGestureDetector class use the event.getX(0) (since api level 5) too)

I test some code more..

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    Fragment f = new Fragment();

}

When I run it on android 1.6 emulator it throw java.lang.VerifyError, but on my phone running android 2.3.4 it throws java.lang.NoClassDefFoundError.

Why??

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T21:56:51+00:00Added an answer on May 26, 2026 at 9:56 pm

    It’s not as strange as it seems. It has to do with how Java treat constant values of primitives. During compilation, the value of the constant is put in the byte code, not a reference to the actual constant.

    For example:

    Log.d(TAG, “Build.VERSION_CODES.ICE_CREAM_SANDWICH: ” + Build.VERSION_CODES.ICE_CREAM_SANDWICH);

    will actucally be translated by the compiler to:

    Log.d(TAG, “Build.VERSION_CODES.ICE_CREAM_SANDWICH: ” + 14);

    so the reference to the actual constant (and class) is removed.

    Regarding the code that doesn’t run for you, it has to do with that the MotionEvent.getX(int n) method wasn’t available until api level 5. Before that, multitouch wasn’t supported and thus no need for any other method than getX().

    It doesn’t matter if you actually call the method that doesn’t exist. The error is appearing while the class is being loaded and verified by the platform. You most likely get a VerifyError in the log, since it will discover that you’re trying to call a non-existent method during the verification.

    On the other hand, if you try to use a class that doesn’t exist, you will get a ClassNotFoundException instead. Note that sometimes, a class exists in Android even if the documentation doesn’t say so. Some classes existed in early versions of Android but weren’t exposed until later. Some have even gone the other way.

    So:

    Trying to use a class that doesn’t exist – ClassNotFoundException
    Trying to use a method that doesn’t exist on a class that exists – VerifyError

    (When it comes to using Fragments, they are available for earlier versions with the standalone Android Support Library)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am new in android and i print log-cat using: Log.w(Tag, String text); and
I'm going by the following code example to dynamically build a preference activity. http://www.linuxtopia.org/online_books/android/devguide/guide/samples/ApiDemos/src/com/example/android/apis/app/PreferencesFromCode.html
I would like to build two versions of my Android application using an Apache
I want to use Jersey Client in my Android application. This is the code
hg log works. hg log --style does not work. C:\temp\myhg> c:\program files\mercurial\hg log changeset:
I am new to android and i am trying to build a RSS reader
One of the android Modules (AudioFlinger) has support for verbose logging (with Tag=AudioFlinger). Question
I want to build an android-based twitter feed reader app. I have problems in
I've been looking through the code of the GoogleIO Android app and I notice
How can I override Hudson build number? It sounds like an easy question, but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.