Stuck with @SuppressLint(“NewApi”) (developer.android.com/training/basics/firstapp/starting-activity)

后端 未结 7 939
醉话见心
醉话见心 2021-01-17 09:54

I\'m a begginer with Android and currently stuck with the lession: http://developer.android.com/training/basics/firstapp/starting-activity.html

In the part C

相关标签:
7条回答
  • 2021-01-17 10:28

    I ran into the exact same problem. CTRL-SHIFT-o (organize imports) filled in the missing import for me.

    0 讨论(0)
  • 2021-01-17 10:30

    SuppressLint annotation was added in API level 16. You need to either:

    • set your build SDK to 16 or higher, or
    • copy tools/support/annotations.jar from your Android SDK to the project libs.
    0 讨论(0)
  • 2021-01-17 10:31

    Your build target is NOT set to API Level 14 or higher. This is not a bug, please close this issue.

    (In eclipse: Project => Properties => Android)

    0 讨论(0)
  • 2021-01-17 10:34

    It works, if you set the line @SuppressLint("NewApi") above the class declaration! (In this lesson, this line is positioned within onCreate, and that doesn't work!)

    0 讨论(0)
  • 2021-01-17 10:41

    Move your cursor over "SuppressLint", which will be underlined in red. Select the fix option "Fix project setup". From the popup list select "add archive 'annotations.jar'. Have a happy day.

    0 讨论(0)
  • 2021-01-17 10:45

    ctrl+shift+O to import libraries and ctrl+s to save made the error go away for me.

    0 讨论(0)
提交回复
热议问题