問題描述
這個應用程序是我大約一年前完成的(!),但從未在市場上推出過.我現在正在嘗試在 Eclipse 中打開它,以進行一些小的修改并稍微處理代碼.所以我導入了它,然后發現這個奇怪的無法解析目標"錯誤.它突出顯示了我所有src"文件中的每個類紅色.
This app I completed around a year ago (!) but never launched it on the market place. I am trying to open it up in eclipse now to make some small modifications and work on the code a little bit. So I imported it and then found this weird "unable to resolve target" error. It's highlighting every class red in all my 'src' files.
我看過一個類似的問題,它說要將該行添加到 default.properties 文件中.我的項目有一個 project.properties 文件,其中包含以下行:
I've looked at a similar question which said to add the line to default.properties file. My project has a project.properties file which has the line:
target=android-7
任何建議如何讓它工作?我總是可以開始一個新項目并復制所有的 src 文件,但這會很蹩腳且浪費時間.
Any advice how to get this to work? I could always start a new project and just copy all the src files but that would be pretty lame and time-wasting.
還有一條評論 - 我正在一臺新計算機上進行開發,但我認為我沒有 API 級別 7.這可能是問題嗎?我已經進入了 Window --> Android SDK Manager,它顯示的最舊的可用 API 是 8 級.但 7 級意味著我可以針對更多設備,所以我想使用它.
One more comment - I'm developing on a new computer and I don't think I have the API level 7. Could that be the problem? I've gone into Window --> Android SDK Manager and the oldest available API it shows is level 8. But level 7 will mean I can target more devices I think so I'd like to go with that.
感謝您的幫助.
推薦答案
嗯,是的,這就是你的問題.您沒有下載 API 級別 7.您可以右鍵單擊該項目并轉到屬性-> android 并選擇另一個可用的 API.只要您不更改清單中的 min sdk 版本,您的目標設備仍然與以前一樣多.
Well, yes that is your problem. You don't have the API level 7 downloaded. You can right click the project and go properties->android and select another available API. As long as you don't change the min sdk version in your manifest you are still targeting as many devices as before.
<uses-sdk android:minSdkVersion="7"/>
更新
您不必這樣做,但您可以在 SDK 存檔上獲取較舊的 API頁面
You don't have to do this, but you can get the older APIs on the SDK Archives page
我不知道下一個聲明是否有任何官方來源,但這是我在工作時發現的.如果有人能以更好的答案完成此任務,我將不勝感激.
I don't know if there is any official source for the next statement but that is what I found while working. If anybody can complete this with a better answer I would appreciate it very much.
只要不使用任何與之前版本不兼容的代碼,您就可以使用較新的 SDK 版本編譯代碼.
You can compile the code with a newer SDK version as long as you don't use any code not compatible to the previous ones.
例子:
我希望我的應用可用于 API 級別 7.但我只安裝了 API 級別 15.只要我在 Manifest 中保留 minSdkVersion="7" 并且不使用以前 API 中不可用的任何資源,該應用程序就可以在我的目標設備上正常運行.
I want my app to be available for API level 7. But i only have API level 15 installed. As long as I keep the minSdkVersion="7" in my Manifest and don't use any resource not available in the previous APIs the app will work just fine on my targeted devices.
這篇關于導入項目給 Unable to resolve target 'android-7'的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!