Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 319
Sosullivan Avatar asked Dec 04 '25 22:12

Sosullivan


2 Answers

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

like image 148
Vyacheslav Shylkin Avatar answered Dec 07 '25 17:12

Vyacheslav Shylkin


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

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.FROYO) { ... }
like image 21
Sparky Avatar answered Dec 07 '25 16:12

Sparky