2010-07-25 60 views
12

我剛開始使用Eclipse進行Android應用程序。 我已經安裝了Eclipse 3.5.2和Java 5 AVD是Android 2.1 API 7應用程序未指定API級別

我最初的Hello Android程序運行正常,但不會再運行。

得到以下錯誤:

[2010-07-25 09:47:31 - HelloAndroid] WARNING: Application does not specify an API level requirement!
[2010-07-25 09:47:31 - HelloAndroid] Device API version is 7 (Android 2.1-update1)

搜索的論壇,但只能找到一個refernece到清單文件,以確保以下設置:

<uses-sdk android:minSdkVersion="3" /> 

我的manifest文件不包含線:

<?xml version="1.0" encoding="utf-8" ?> 
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.helloandriod" android:versionCode="1" android:versionName="1.0"> 
    <application android:icon="@drawable/icon" android:label="@string/app_name"> 
     <activity android:name=".HelloAndroid" android:label="@string/app_name"> 
      <intent-filter> 
       <action android:name="android.intent.action.MAIN" /> 
       <category android:name="android.intent.category.LAUNCHER" /> 
      </intent-filter> 
     </activity> 
    </application> 
    </manifest> 

我檢查了adv mgr,它被設置爲7 在Eclipse我去屬性 - > Android和它設置爲7級

得到同樣的警告

+0

就像一個headhead。 Eclipse不會因爲您在SDK管理器中創建AVD而生成該行。通過屬性設置目標API是正確的舉措,但也不會爲您生成線路。它僅在您創建項目時指定了AVD時纔會生成。我無法找到導入現有項目的方式,只能通過新項目 – celem 2011-07-22 11:45:55

回答

35

好吧,如果Eclipse是,無論出於何種原因,沒有生成線,你的一切意味着你可以將其添加你自己。

行地址:
<uses-sdk android:minSdkVersion="3" />

到您的清單,結束清單標籤之前。

+0

同時確保準確讀取設置各種''標籤的影響:http://developer.android.com/guide/ publishing/versioning.html#minsdkversion – 2010-07-25 21:07:25

10

你還應該包括

<uses-sdk android:minSdkVersion="7" /> 
清單檔案中的

,如果它已不存在。從你的問題來看並不清楚,但似乎並非如此。

有關API級別將來參考,請參閱this page

+0

感謝您的輸入。 對於閱讀此內容的人,我手動輸入了兩個src命令,Eclipse不喜歡手動輸入。說是不同步的。 但我能夠在Eclipse中更新清單。 它現在沒有錯誤運行,但avd只提供日期和時間。 我會弄清楚,但至少沒有錯誤。謝謝 – Trent 2010-07-27 03:40:45

7

看來,有在Android SDK工具修訂16需要uses-sdk標籤的正確排序的錯誤。如果您同時使用targetSdkVersionminSdkVersion,責令如下:

<uses-sdk android:targetSdkVersion="10" /> <!-- before minSdkVersion --> 
<uses-sdk android:minSdkVersion="7" />  <!-- after targetSdkVersion --> 

顛倒順序將給予警告信息,並彈出裝置選擇窗口。因此,我建議將它寫在一行中:

<uses-sdk android:targetSdkVersion="10" android:minSdkVersion="7" /> 
+0

確認。奇怪的確如此。 – 2012-03-14 08:52:06

+0

我已打開[問題#27320](http://code.google.com/p/android/issues/detail?id=27320)。 – 2012-03-20 15:52:41

+0

該問題已通過新的Lint警告解決!歡呼! – 2012-03-22 12:31:46

2

清單應該只包含一個元素,這是多次使用的錯誤。

在ADT 17,我們有一個新的皮棉警告檢測和報告此問題:

$ lint --version 
lint: version 17 
$ lint --show MultipleUsesSdk 
MultipleUsesSdk 
--------------- 
Summary: Checks that the <uses-sdk> element appears at most once 

Priority: 6/10 
Severity: Error 
Category: Correctness 

The <uses-sdk> element should appear just once; the tools will *not* merge the 
contents of all the elements so if you split up the atttributes across 
multiple elements, only one of them will take effect. To fix this, just merge 
all the attributes from the various elements into a single <uses-sdk> 
element. 

的更多信息:http://developer.android.com/guide/topics/manifest/uses-sdk-element.html

+0

感謝您在此發佈您的評論。作爲參考,已結束的問題是[問題#27320](http://code.google.com/p/android/issues/detail?id=27320)。 – 2012-03-25 16:14:55

0

你在你的代碼,以指定API級別,它應該是在一行中。

uses-sdk android:targetSdkVersion =「19」android:minSdkVersion =「4」。

目標應該是最新的。它可能會幫助你,因爲它爲我工作。謝謝

相關問題