Build Version Code O not being recognized correctly












1















I have this code snippet for my local notifications to work on Oreo devices.



if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
NotificationChannel channel = new NotificationChannel(CHANNEL_ID,
CHANNEL_NAME,
level);

manager.createNotificationChannel(channel);
}


On my window desktop this is fine, no issues. However on my macbook, lint complains about NotificationChannel requiring SDK 26 and my min is 21. However if I change the version check to



if (Build.VERSION.SDK_INT >= 26) 


the error goes away. I've tried restarting Android studio, clean/rebuild. Nothing works. When I do code inspection and use the suggested hints, its changing the Version_Code to 26. Its kinda bothering me having it act different on my 2 machines but same exact code. Anyone else seen this issue before?



compileSdkVersion = 26
buildToolsVersion = "26.0.2"

minSdkVersion = 21
targetSdkVersion = 26









share|improve this question

























  • did you set targetSdkVersion and if you set what is it

    – sanemars
    Apr 27 '18 at 2:48











  • Same question as above but for your compileSdkVersion, which needs to be at least 26 for this field to be available to you.

    – stkent
    Apr 27 '18 at 4:19











  • I added my gradle statements. Theyre the same on both computers, only the mac complains.

    – Le2e410
    Apr 27 '18 at 11:52











  • I reinstalled android studio and the error went away. I think the version number had something to do with it. It was on 2.3.1.

    – Le2e410
    Apr 28 '18 at 1:37











  • Possible duplicate of Android Studio 3.1: Erroneous unresolved references in editor

    – fireb86
    Nov 5 '18 at 11:08
















1















I have this code snippet for my local notifications to work on Oreo devices.



if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
NotificationChannel channel = new NotificationChannel(CHANNEL_ID,
CHANNEL_NAME,
level);

manager.createNotificationChannel(channel);
}


On my window desktop this is fine, no issues. However on my macbook, lint complains about NotificationChannel requiring SDK 26 and my min is 21. However if I change the version check to



if (Build.VERSION.SDK_INT >= 26) 


the error goes away. I've tried restarting Android studio, clean/rebuild. Nothing works. When I do code inspection and use the suggested hints, its changing the Version_Code to 26. Its kinda bothering me having it act different on my 2 machines but same exact code. Anyone else seen this issue before?



compileSdkVersion = 26
buildToolsVersion = "26.0.2"

minSdkVersion = 21
targetSdkVersion = 26









share|improve this question

























  • did you set targetSdkVersion and if you set what is it

    – sanemars
    Apr 27 '18 at 2:48











  • Same question as above but for your compileSdkVersion, which needs to be at least 26 for this field to be available to you.

    – stkent
    Apr 27 '18 at 4:19











  • I added my gradle statements. Theyre the same on both computers, only the mac complains.

    – Le2e410
    Apr 27 '18 at 11:52











  • I reinstalled android studio and the error went away. I think the version number had something to do with it. It was on 2.3.1.

    – Le2e410
    Apr 28 '18 at 1:37











  • Possible duplicate of Android Studio 3.1: Erroneous unresolved references in editor

    – fireb86
    Nov 5 '18 at 11:08














1












1








1








I have this code snippet for my local notifications to work on Oreo devices.



if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
NotificationChannel channel = new NotificationChannel(CHANNEL_ID,
CHANNEL_NAME,
level);

manager.createNotificationChannel(channel);
}


On my window desktop this is fine, no issues. However on my macbook, lint complains about NotificationChannel requiring SDK 26 and my min is 21. However if I change the version check to



if (Build.VERSION.SDK_INT >= 26) 


the error goes away. I've tried restarting Android studio, clean/rebuild. Nothing works. When I do code inspection and use the suggested hints, its changing the Version_Code to 26. Its kinda bothering me having it act different on my 2 machines but same exact code. Anyone else seen this issue before?



compileSdkVersion = 26
buildToolsVersion = "26.0.2"

minSdkVersion = 21
targetSdkVersion = 26









share|improve this question
















I have this code snippet for my local notifications to work on Oreo devices.



if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
NotificationChannel channel = new NotificationChannel(CHANNEL_ID,
CHANNEL_NAME,
level);

manager.createNotificationChannel(channel);
}


On my window desktop this is fine, no issues. However on my macbook, lint complains about NotificationChannel requiring SDK 26 and my min is 21. However if I change the version check to



if (Build.VERSION.SDK_INT >= 26) 


the error goes away. I've tried restarting Android studio, clean/rebuild. Nothing works. When I do code inspection and use the suggested hints, its changing the Version_Code to 26. Its kinda bothering me having it act different on my 2 machines but same exact code. Anyone else seen this issue before?



compileSdkVersion = 26
buildToolsVersion = "26.0.2"

minSdkVersion = 21
targetSdkVersion = 26






android android-studio android-8.0-oreo notification-channel






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Apr 27 '18 at 11:48







Le2e410

















asked Apr 27 '18 at 2:13









Le2e410Le2e410

113111




113111













  • did you set targetSdkVersion and if you set what is it

    – sanemars
    Apr 27 '18 at 2:48











  • Same question as above but for your compileSdkVersion, which needs to be at least 26 for this field to be available to you.

    – stkent
    Apr 27 '18 at 4:19











  • I added my gradle statements. Theyre the same on both computers, only the mac complains.

    – Le2e410
    Apr 27 '18 at 11:52











  • I reinstalled android studio and the error went away. I think the version number had something to do with it. It was on 2.3.1.

    – Le2e410
    Apr 28 '18 at 1:37











  • Possible duplicate of Android Studio 3.1: Erroneous unresolved references in editor

    – fireb86
    Nov 5 '18 at 11:08



















  • did you set targetSdkVersion and if you set what is it

    – sanemars
    Apr 27 '18 at 2:48











  • Same question as above but for your compileSdkVersion, which needs to be at least 26 for this field to be available to you.

    – stkent
    Apr 27 '18 at 4:19











  • I added my gradle statements. Theyre the same on both computers, only the mac complains.

    – Le2e410
    Apr 27 '18 at 11:52











  • I reinstalled android studio and the error went away. I think the version number had something to do with it. It was on 2.3.1.

    – Le2e410
    Apr 28 '18 at 1:37











  • Possible duplicate of Android Studio 3.1: Erroneous unresolved references in editor

    – fireb86
    Nov 5 '18 at 11:08

















did you set targetSdkVersion and if you set what is it

– sanemars
Apr 27 '18 at 2:48





did you set targetSdkVersion and if you set what is it

– sanemars
Apr 27 '18 at 2:48













Same question as above but for your compileSdkVersion, which needs to be at least 26 for this field to be available to you.

– stkent
Apr 27 '18 at 4:19





Same question as above but for your compileSdkVersion, which needs to be at least 26 for this field to be available to you.

– stkent
Apr 27 '18 at 4:19













I added my gradle statements. Theyre the same on both computers, only the mac complains.

– Le2e410
Apr 27 '18 at 11:52





I added my gradle statements. Theyre the same on both computers, only the mac complains.

– Le2e410
Apr 27 '18 at 11:52













I reinstalled android studio and the error went away. I think the version number had something to do with it. It was on 2.3.1.

– Le2e410
Apr 28 '18 at 1:37





I reinstalled android studio and the error went away. I think the version number had something to do with it. It was on 2.3.1.

– Le2e410
Apr 28 '18 at 1:37













Possible duplicate of Android Studio 3.1: Erroneous unresolved references in editor

– fireb86
Nov 5 '18 at 11:08





Possible duplicate of Android Studio 3.1: Erroneous unresolved references in editor

– fireb86
Nov 5 '18 at 11:08












2 Answers
2






active

oldest

votes


















0














Same problem with android studio 3.2.1 after I switched from an old project to another. Very annoying. I solved with these steps:




  • Delete {projectDir}/.idea/libraries folder

  • File -> Sync Project with Gradle Files

  • File -> Sync Project with File System






share|improve this answer

































    0














    Oreo is android 8.

    Instead your code, using below code:



    if (Build.VERSION.SDK_INT >= 26) {
    NotificationChannel channel = new NotificationChannel(CHANNEL_ID,
    CHANNEL_NAME,
    level);
    manager.createNotificationChannel(channel);
    }





    share|improve this answer

























      Your Answer






      StackExchange.ifUsing("editor", function () {
      StackExchange.using("externalEditor", function () {
      StackExchange.using("snippets", function () {
      StackExchange.snippets.init();
      });
      });
      }, "code-snippets");

      StackExchange.ready(function() {
      var channelOptions = {
      tags: "".split(" "),
      id: "1"
      };
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function() {
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled) {
      StackExchange.using("snippets", function() {
      createEditor();
      });
      }
      else {
      createEditor();
      }
      });

      function createEditor() {
      StackExchange.prepareEditor({
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader: {
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      },
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      });


      }
      });














      draft saved

      draft discarded


















      StackExchange.ready(
      function () {
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f50054252%2fbuild-version-code-o-not-being-recognized-correctly%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      0














      Same problem with android studio 3.2.1 after I switched from an old project to another. Very annoying. I solved with these steps:




      • Delete {projectDir}/.idea/libraries folder

      • File -> Sync Project with Gradle Files

      • File -> Sync Project with File System






      share|improve this answer






























        0














        Same problem with android studio 3.2.1 after I switched from an old project to another. Very annoying. I solved with these steps:




        • Delete {projectDir}/.idea/libraries folder

        • File -> Sync Project with Gradle Files

        • File -> Sync Project with File System






        share|improve this answer




























          0












          0








          0







          Same problem with android studio 3.2.1 after I switched from an old project to another. Very annoying. I solved with these steps:




          • Delete {projectDir}/.idea/libraries folder

          • File -> Sync Project with Gradle Files

          • File -> Sync Project with File System






          share|improve this answer















          Same problem with android studio 3.2.1 after I switched from an old project to another. Very annoying. I solved with these steps:




          • Delete {projectDir}/.idea/libraries folder

          • File -> Sync Project with Gradle Files

          • File -> Sync Project with File System







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 5 '18 at 11:15

























          answered Oct 30 '18 at 9:56









          fireb86fireb86

          563819




          563819

























              0














              Oreo is android 8.

              Instead your code, using below code:



              if (Build.VERSION.SDK_INT >= 26) {
              NotificationChannel channel = new NotificationChannel(CHANNEL_ID,
              CHANNEL_NAME,
              level);
              manager.createNotificationChannel(channel);
              }





              share|improve this answer






























                0














                Oreo is android 8.

                Instead your code, using below code:



                if (Build.VERSION.SDK_INT >= 26) {
                NotificationChannel channel = new NotificationChannel(CHANNEL_ID,
                CHANNEL_NAME,
                level);
                manager.createNotificationChannel(channel);
                }





                share|improve this answer




























                  0












                  0








                  0







                  Oreo is android 8.

                  Instead your code, using below code:



                  if (Build.VERSION.SDK_INT >= 26) {
                  NotificationChannel channel = new NotificationChannel(CHANNEL_ID,
                  CHANNEL_NAME,
                  level);
                  manager.createNotificationChannel(channel);
                  }





                  share|improve this answer















                  Oreo is android 8.

                  Instead your code, using below code:



                  if (Build.VERSION.SDK_INT >= 26) {
                  NotificationChannel channel = new NotificationChannel(CHANNEL_ID,
                  CHANNEL_NAME,
                  level);
                  manager.createNotificationChannel(channel);
                  }






                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Nov 22 '18 at 19:19









                  סטנלי גרונן

                  1,76482245




                  1,76482245










                  answered Nov 22 '18 at 18:22









                  Majid ZareMajid Zare

                  11




                  11






























                      draft saved

                      draft discarded




















































                      Thanks for contributing an answer to Stack Overflow!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid



                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.


                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f50054252%2fbuild-version-code-o-not-being-recognized-correctly%23new-answer', 'question_page');
                      }
                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      "Incorrect syntax near the keyword 'ON'. (on update cascade, on delete cascade,)

                      Alcedinidae

                      Origin of the phrase “under your belt”?