Android开发者工具无法识别较新的API?

时间:2015-11-08 03:32:58

标签: android sdk adt

该项目建立在Android 4.4.2上。

现在我想使用Android 5.0.1的新API ADT无法识别&#39; public class ClockDisplay { private NumberDisplay hours; private NumberDisplay minutes; private String displayString; // simulates the actual display public static final int FIRST_MORNING_HOUR = 0; public static final int LAST_MORNING_HOUR = 11; public static final int FIRST_EVENING_HOUR = 12; public static final int LAST_EVENING_HOUR = 23; public static final int MINUTES_PER_HOUR = 60; public static final int MINUTES_ZERO = 0; public static final String MORNING_SUFFIX = "a.m."; public static final String EVENING_SUFFIX = "p.m."; public static final int MIDNIGHT_HOUR = 0; public static final int HOURS_PER_DAY = 0; public static final int TWENTY_FOUR_HOURS = 24; /** * Constructor for ClockDisplay objects. This constructor * creates a new clock set at 00:00. */ public ClockDisplay() { hours = new NumberDisplay(TWENTY_FOUR_HOURS); minutes = new NumberDisplay(MINUTES_PER_HOUR); updateDisplay(); } /** * Constructor for ClockDisplay objects. This constructor * creates a new clock set at the time specified by the * parameters. */ public ClockDisplay(int hour, int minute) { hours = new NumberDisplay(TWENTY_FOUR_HOURS); minutes = new NumberDisplay(MINUTES_PER_HOUR); setTime(hour, minute); } /** * This method should get called once every minute - it makes * the clock display go one minute forward. */ public void timeTick() { minutes.increment(); if(minutes.getValue() == MINUTES_ZERO){ // it just rolled over! hours.increment(); } updateDisplay(); } /** * Set the time of the display to the specified hour and * minute. */ public void setTime(int hour, int minute) { hours.setValue(hour); minutes.setValue(minute); updateDisplay(); } /** * @retun the time from displayString */ public String getTime() { return displayString; } /** * the updated display */ private void updateDisplay() { if(hours.getValue() < FIRST_EVENING_HOUR){ displayString = hours.getDisplayValue() + ":" + minutes.getDisplayValue() + " am"; } else if(hours.getValue() > FIRST_EVENING_HOUR && hours.getValue() <LAST_EVENING_HOUR){ displayString = Integer.toString(hours.getValue() - FIRST_EVENING_HOUR) + ":" + minutes.getDisplayValue() + " pm"; } else if(hours.getValue() == MIDNIGHT_HOUR){ hours.setValue(FIRST_EVENING_HOUR); displayString = hours.getDisplayValue() + ":"+ minutes.getDisplayValue() + " am (midnight)"; } else{ hours.setValue(FIRST_EVENING_HOUR); displayString = hours.getDisplayValue() + ":" + minutes.getDisplayValue() + " pm (noon)"; } } } &#39; 我该如何解决?

code like this

2 个答案:

答案 0 :(得分:0)

您应该确保您的compileSdkVersion和buildToolsVersion适用于5.0.1。

Adt将不再更新,因此建议您使用AndroidStudio。

答案 1 :(得分:0)

从提供的图片中可以清楚地看到您的构建目标仍设置为Android 4.4.2,您需要将其更改为5.0.1: enter image description here

此外,您现在应该立即迁移到使用Android Studio,并且不知道Google将继续支持Eclipse ADT多长时间。