Sosullivan
Sosullivan

Reputation: 657

Why can't android.os.build.VERSION be resolved to a variable?

I am getting the error: "android.os.Build.VERSION cannot be resolved to a variable" as an error attached to the line "int myVersion = android.os.Build.VERSION;" in the code below:

    public void test4_validate_mainOverflowMenuAbout()  {
    int myVersion = android.os.Build.VERSION;
    String myModel = android.os.Build.MODEL;

    if(myVersion >= HONEYCOMB && myModel == "MY PHONE")
        TestUtils.invokeMenuItem(@+id/dashboard_menu_item_about)
        assertTrue(TestUtils.waitForTextOnThePageWithTimeout("My Text", True, 1000));

I THINK that my control structure is proper, but would appreciate a gander from more experienced eyes.

TIA for any and all assistance!

Regards,

Steve O'Sullivan

Upvotes: 3

Views: 3841

Answers (2)

Vyacheslav Shylkin
Vyacheslav Shylkin

Reputation: 9791

Because Build.VERSION is a static class... Use Build.VERSION.SDK_INT

Upvotes: 8

Sparky
Sparky

Reputation: 8477

In my code, I'm doing it like this:

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.FROYO) { ... }

Upvotes: 4

Related Questions