android程序出现了奇怪的错误 Field requires API level 5 (current min is 1): ......

android程序出现了奇怪的错误  Field requires API level 5 (current min is 1): ......

解决办法:

Right click on the project folder > Android tools > Clear Link Markers

英文网站找的,细节就看不懂了。参见
http://stackoverflow.com/questions/10322482/android-lint-erroneously-thinks-min-sdk-version-is-1




Eclipse refuses to build my Android project. In the package explorer, the project root node has the little red error symbol, but nothing else inside of it has this symbol. The Problems tab shows errors detected by Lint:

Call requires API level 3 (current min is 1): android.os.AsyncTask#   
Call requires API level 3 (current min is 1): android.view.GestureDetector#   
Call requires API level 3 (current min is 1): android.view.inputmethod.InputMethodManager#hideSoftInputFromWindow   
Call requires API level 3 (current min is 1): android.view.inputmethod.InputMethodManager#hideSoftInputFromWindow   
Call requires API level 3 (current min is 1): android.view.inputmethod.InputMethodManager#showSoftInput
Call requires API level 3 (current min is 1): android.view.inputmethod.InputMethodManager#showSoftInput
Call requires API level 3 (current min is 1): android.view.inputmethod.InputMethodManager#showSoftInput
Call requires API level 3 (current min is 1): android.view.inputmethod.InputMethodManager#toggleSoftInput
Call requires API level 3 (current min is 1): android.view.Menu#getItem 
Call requires API level 3 (current min is 1): android.view.Menu#getItem 
Call requires API level 3 (current min is 1): android.widget.HorizontalScrollView#getId 
Call requires API level 5 (current min is 1): android.app.Activity#onBackPressed    
Call requires API level 5 (current min is 1): android.app.Activity#onBackPressed    
Call requires API level 5 (current min is 1): android.app.Activity#onBackPressed    
Class requires API level 3 (current min is 1): android.view.inputmethod.InputMethodManager  
Class requires API level 3 (current min is 1): android.view.inputmethod.InputMethodManager  
Class requires API level 3 (current min is 1): android.view.inputmethod.InputMethodManager
Class requires API level 3 (current min is 1): android.view.inputmethod.InputMethodManager  
Class requires API level 3 (current min is 1): android.view.inputmethod.InputMethodManager  
Class requires API level 3 (current min is 1): android.view.inputmethod.InputMethodManager
Class requires API level 3 (current min is 1): android.widget.HorizontalScrollView
Class requires API level 3 (current min is 1): android.widget.HorizontalScrollView
Field requires API level 3 (current min is 1): android.os.Build#DISPLAY
Field requires API level 4 (current min is 1): android.content.res.Configuration#screenLayout   
Field requires API level 4 (current min is 1): android.os.Build#CPU_ABI 
Field requires API level 4 (current min is 1): android.os.Build#MANUFACTURER
Field requires API level 4 (current min is 1): android.os.Build$VERSION#SDK_INT

My best guess is that Lint thinks my minSdkVersion is 1, which it isn't; my manifest declares minSdkVersion="8". I've tried the following in an effort to fix this:

  • Restarting Eclipse
  • Restarting my computer
  • Project > Clean
  • Manually deleting /bin and /gen to force hem to be generated again

At this point I'm out of ideas. Anybody have suggestions?

share | improve this question
 
Do you have other project opened in eclipse? If yes, close all but hte one you're working with (even libraries). Then re-run lint. –  inazaruk Apr 25 at 19:39
 
I confirm this also happened to me when I moved the working Android project into subfolder on the workspace. Android tools > Clear Link Markers seems a working workaround. –  user197831 Oct 12 at 9:41
Was this post useful to you?     

2 Answers

active oldest votes
up vote 19 down vote accepted

I have the same problem, and my solution is:

Right click on the project folder > Android tools > Clear Link Markers

"Run Android Lint" makes some markers and the markers cause this error.

share | improve this answer
 
I believe this is what I did, but somehow did it from the Problems tab through right-clicking and selecting something ... I'm honestly not sure what, but I remember a "Clear Lint Markers" being part of it, so this gets the checkmark. –  jdk Apr 26 at 17:48
 
On other solution is to move a project to the top level of the workspace instead of some subfolder –  Seppl Jul 11 at 8:43
 
Even on doing this, the error appeared. Needed to close and reopen the project in addition to "Clear Lint Markers". –  tarkeshwar Aug 6 at 9:19
feedback
up vote 0 down vote

Try right clicking on the project folder > Android tools > fix properties

You should also check in the build properties that all your android libraries and things are checked and loading in the correct order. Right click on the project > Properties > Build

share | improve this answer
 
feedback

你可能感兴趣的:(android)