2010-11-28 89 views
10

我正在嘗試編譯Android SDK附帶的Google ApiDemos。 但我只能讓它運行!它已經讓我瘋狂了!編譯並運行ApiDemos

當我基於示例(目標1.5或1.6)在Eclipse中創建一個新項目並嘗試編譯和運行時,我得到近千個錯誤。不是我期望從教程應用程序!

Description Resource Path Location Type 
IRemoteService cannot be resolved RemoteServiceBinding.java /ApiDemos/src/com/example/android/apis/app line 84 Java Problem 
IRemoteService cannot be resolved to a type RemoteService.java /ApiDemos/src/com/example/android/apis/app line 92 Java Problem 
IRemoteService cannot be resolved to a type RemoteService.java /ApiDemos/src/com/example/android/apis/app line 104 Java Problem 
IRemoteService cannot be resolved to a type RemoteService.java /ApiDemos/src/com/example/android/apis/app line 104 Java Problem 
IRemoteService cannot be resolved to a type RemoteServiceBinding.java /ApiDemos/src/com/example/android/apis/app line 41 Java Problem 
IRemoteService cannot be resolved to a type RemoteServiceBinding.java /ApiDemos/src/com/example/android/apis/app line 84 Java Problem 
IRemoteService cannot be resolved to a type RemoteServiceBinding.java /ApiDemos/src/com/example/android/apis/app line 91 Java Problem 
IRemoteService cannot be resolved to a type RemoteServiceBinding.java /ApiDemos/src/com/example/android/apis/app line 107 Java Problem 
IRemoteService cannot be resolved to a type RemoteServiceBinding.java /ApiDemos/src/com/example/android/apis/app line 141 Java Problem 
IRemoteService cannot be resolved to a type RemoteServiceBinding.java /ApiDemos/src/com/example/android/apis/app line 155 Java Problem 
IRemoteService cannot be resolved to a type RemoteServiceBinding.java /ApiDemos/src/com/example/android/apis/app line 157 Java Problem 
IRemoteServiceCallback cannot be resolved to a type RemoteService.java /ApiDemos/src/com/example/android/apis/app line 51 Java Problem 
IRemoteServiceCallback cannot be resolved to a type RemoteService.java /ApiDemos/src/com/example/android/apis/app line 52 Java Problem 
IRemoteServiceCallback cannot be resolved to a type RemoteService.java /ApiDemos/src/com/example/android/apis/app line 79 Java Problem 
IRemoteServiceCallback cannot be resolved to a type RemoteService.java /ApiDemos/src/com/example/android/apis/app line 105 Java Problem 
IRemoteServiceCallback cannot be resolved to a type RemoteService.java /ApiDemos/src/com/example/android/apis/app line 106 Java Problem 
IRemoteServiceCallback cannot be resolved to a type RemoteService.java /ApiDemos/src/com/example/android/apis/app line 108 Java Problem 
IRemoteServiceCallback cannot be resolved to a type RemoteService.java /ApiDemos/src/com/example/android/apis/app line 109 Java Problem 
IRemoteServiceCallback cannot be resolved to a type RemoteService.java /ApiDemos/src/com/example/android/apis/app line 142 Java Problem 
IRemoteServiceCallback cannot be resolved to a type RemoteService.java /ApiDemos/src/com/example/android/apis/app line 145 Java Problem 
IRemoteServiceCallback cannot be resolved to a type RemoteService.java /ApiDemos/src/com/example/android/apis/app line 151 Java Problem 
IRemoteServiceCallback cannot be resolved to a type RemoteServiceBinding.java /ApiDemos/src/com/example/android/apis/app line 91 Java Problem 
IRemoteServiceCallback cannot be resolved to a type RemoteServiceBinding.java /ApiDemos/src/com/example/android/apis/app line 157 Java Problem 
IRemoteServiceCallback cannot be resolved to a type RemoteServiceBinding.java /ApiDemos/src/com/example/android/apis/app line 212 Java Problem 
IRemoteServiceCallback cannot be resolved to a type RemoteServiceBinding.java /ApiDemos/src/com/example/android/apis/app line 212 Java Problem 
ISecondary cannot be resolved RemoteServiceBinding.java /ApiDemos/src/com/example/android/apis/app line 125 Java Problem 
ISecondary cannot be resolved to a type RemoteService.java /ApiDemos/src/com/example/android/apis/app line 95 Java Problem 
ISecondary cannot be resolved to a type RemoteService.java /ApiDemos/src/com/example/android/apis/app line 116 Java Problem 
ISecondary cannot be resolved to a type RemoteService.java /ApiDemos/src/com/example/android/apis/app line 116 Java Problem 
ISecondary cannot be resolved to a type RemoteServiceBinding.java /ApiDemos/src/com/example/android/apis/app line 43 Java Problem 
ISecondary cannot be resolved to a type RemoteServiceBinding.java /ApiDemos/src/com/example/android/apis/app line 125 Java Problem 
ISecondary cannot be resolved to a type RemoteServiceBinding.java /ApiDemos/src/com/example/android/apis/app line 130 Java Problem 
ISecondary cannot be resolved to a type RemoteServiceBinding.java /ApiDemos/src/com/example/android/apis/app line 143 Java Problem 
ISecondary cannot be resolved to a type RemoteServiceBinding.java /ApiDemos/src/com/example/android/apis/app line 179 Java Problem 
ISecondary cannot be resolved to a type RemoteServiceBinding.java /ApiDemos/src/com/example/android/apis/app line 181 Java Problem 
R cannot be resolved to a variable AdvancedPreferences.java /ApiDemos/src/com/example/android/apis/app line 58 Java Problem 
R cannot be resolved to a variable AlarmController.java /ApiDemos/src/com/example/android/apis/app line 73 Java Problem 
R cannot be resolved to a variable AlarmController.java /ApiDemos/src/com/example/android/apis/app line 76 Java Problem 
R cannot be resolved to a variable AlarmController.java /ApiDemos/src/com/example/android/apis/app line 78 Java Problem 
R cannot be resolved to a variable AlarmController.java /ApiDemos/src/com/example/android/apis/app line 80 Java Problem 
R cannot be resolved to a variable AlarmController.java /ApiDemos/src/com/example/android/apis/app line 108 Java Problem 
R cannot be resolved to a variable AlarmController.java /ApiDemos/src/com/example/android/apis/app line 140 Java Problem 
R cannot be resolved to a variable AlarmController.java /ApiDemos/src/com/example/android/apis/app line 162 Java Problem 
R cannot be resolved to a variable AlarmService.java /ApiDemos/src/com/example/android/apis/app line 52 Java Problem 
R cannot be resolved to a variable AlarmService.java /ApiDemos/src/com/example/android/apis/app line 55 Java Problem 
R cannot be resolved to a variable AlarmService.java /ApiDemos/src/com/example/android/apis/app line 57 Java Problem 
R cannot be resolved to a variable AlarmService.java /ApiDemos/src/com/example/android/apis/app line 72 Java Problem 
R cannot be resolved to a variable AlarmService.java /ApiDemos/src/com/example/android/apis/app line 84 Java Problem 
R cannot be resolved to a variable AlarmService_Service.java /ApiDemos/src/com/example/android/apis/app line 62 Java Problem 
R cannot be resolved to a variable AlarmService_Service.java /ApiDemos/src/com/example/android/apis/app line 65 Java Problem 
R cannot be resolved to a variable AlarmService_Service.java /ApiDemos/src/com/example/android/apis/app line 100 Java Problem 
R cannot be resolved to a variable AlarmService_Service.java /ApiDemos/src/com/example/android/apis/app line 103 Java Problem 
R cannot be resolved to a variable AlarmService_Service.java /ApiDemos/src/com/example/android/apis/app line 111 Java Problem 
R cannot be resolved to a variable AlarmService_Service.java /ApiDemos/src/com/example/android/apis/app line 116 Java Problem 
R cannot be resolved to a variable AlertDialogSamples.java /ApiDemos/src/com/example/android/apis/app line 75 Java Problem 
R cannot be resolved to a variable AlertDialogSamples.java /ApiDemos/src/com/example/android/apis/app line 76 Java Problem 
R cannot be resolved to a variable AlertDialogSamples.java /ApiDemos/src/com/example/android/apis/app line 77 Java Problem 
R cannot be resolved to a variable AlertDialogSamples.java /ApiDemos/src/com/example/android/apis/app line 83 Java Problem 
R cannot be resolved to a variable AlertDialogSamples.java /ApiDemos/src/com/example/android/apis/app line 92 Java Problem 
R cannot be resolved to a variable AlertDialogSamples.java /ApiDemos/src/com/example/android/apis/app line 93 Java Problem 
R cannot be resolved to a variable AlertDialogSamples.java /ApiDemos/src/com/example/android/apis/app line 94 Java Problem 
R cannot be resolved to a variable AlertDialogSamples.java /ApiDemos/src/com/example/android/apis/app line 95 Java Problem 
R cannot be resolved to a variable AlertDialogSamples.java /ApiDemos/src/com/example/android/apis/app line 101 Java Problem 
R cannot be resolved to a variable AlertDialogSamples.java /ApiDemos/src/com/example/android/apis/app line 107 Java Problem 
R cannot be resolved to a variable AlertDialogSamples.java /ApiDemos/src/com/example/android/apis/app line 116 Java Problem 
R cannot be resolved to a variable AlertDialogSamples.java /ApiDemos/src/com/example/android/apis/app line 117 Java Problem 
R cannot be resolved to a variable AlertDialogSamples.java /ApiDemos/src/com/example/android/apis/app line 121 Java Problem 
R cannot be resolved to a variable AlertDialogSamples.java /ApiDemos/src/com/example/android/apis/app line 130 Java Problem 
R cannot be resolved to a variable AlertDialogSamples.java /ApiDemos/src/com/example/android/apis/app line 131 Java Problem 
R cannot be resolved to a variable AlertDialogSamples.java /ApiDemos/src/com/example/android/apis/app line 134 Java Problem 
R cannot be resolved to a variable AlertDialogSamples.java /ApiDemos/src/com/example/android/apis/app line 140 Java Problem 
R cannot be resolved to a variable AlertDialogSamples.java /ApiDemos/src/com/example/android/apis/app line 149 Java Problem 
R cannot be resolved to a variable AlertDialogSamples.java /ApiDemos/src/com/example/android/apis/app line 150 Java Problem 
R cannot be resolved to a variable AlertDialogSamples.java /ApiDemos/src/com/example/android/apis/app line 151 Java Problem 
R cannot be resolved to a variable AlertDialogSamples.java /ApiDemos/src/com/example/android/apis/app line 157 Java Problem 
R cannot be resolved to a variable AlertDialogSamples.java /ApiDemos/src/com/example/android/apis/app line 163 Java Problem 
R cannot be resolved to a variable AlertDialogSamples.java /ApiDemos/src/com/example/android/apis/app line 172 Java Problem 
R cannot be resolved to a variable AlertDialogSamples.java /ApiDemos/src/com/example/android/apis/app line 173 Java Problem 
R cannot be resolved to a variable AlertDialogSamples.java /ApiDemos/src/com/example/android/apis/app line 174 Java Problem 
R cannot be resolved to a variable AlertDialogSamples.java /ApiDemos/src/com/example/android/apis/app line 183 Java Problem 
R cannot be resolved to a variable AlertDialogSamples.java /ApiDemos/src/com/example/android/apis/app line 189 Java Problem 
R cannot be resolved to a variable AlertDialogSamples.java /ApiDemos/src/com/example/android/apis/app line 199 Java Problem 
R cannot be resolved to a variable AlertDialogSamples.java /ApiDemos/src/com/example/android/apis/app line 201 Java Problem 
R cannot be resolved to a variable AlertDialogSamples.java /ApiDemos/src/com/example/android/apis/app line 202 Java Problem 
R cannot be resolved to a variable AlertDialogSamples.java /ApiDemos/src/com/example/android/apis/app line 204 Java Problem 
R cannot be resolved to a variable AlertDialogSamples.java /ApiDemos/src/com/example/android/apis/app line 210 Java Problem 
R cannot be resolved to a variable AlertDialogSamples.java /ApiDemos/src/com/example/android/apis/app line 230 Java Problem 
R cannot be resolved to a variable AlertDialogSamples.java /ApiDemos/src/com/example/android/apis/app line 233 Java Problem 
R cannot be resolved to a variable AlertDialogSamples.java /ApiDemos/src/com/example/android/apis/app line 241 Java Problem 
R cannot be resolved to a variable AlertDialogSamples.java /ApiDemos/src/com/example/android/apis/app line 250 Java Problem 
R cannot be resolved to a variable AlertDialogSamples.java /ApiDemos/src/com/example/android/apis/app line 258 Java Problem 
R cannot be resolved to a variable AlertDialogSamples.java /ApiDemos/src/com/example/android/apis/app line 269 Java Problem 
R cannot be resolved to a variable AlertDialogSamples.java /ApiDemos/src/com/example/android/apis/app line 277 Java Problem 
R cannot be resolved to a variable AlertDialogSamples.java /ApiDemos/src/com/example/android/apis/app line 285 Java Problem 
R cannot be resolved to a variable AlphaBitmap.java /ApiDemos/src/com/example/android/apis/graphics line 67 Java Problem 
R cannot be resolved to a variable AnimateDrawables.java /ApiDemos/src/com/example/android/apis/graphics line 46 Java Problem 
R cannot be resolved to a variable Animation1.java /ApiDemos/src/com/example/android/apis/view line 34 Java Problem 
R cannot be resolved to a variable Animation1.java /ApiDemos/src/com/example/android/apis/view line 36 Java Problem 
R cannot be resolved to a variable Animation1.java /ApiDemos/src/com/example/android/apis/view line 41 Java Problem 
R cannot be resolved to a variable Animation1.java /ApiDemos/src/com/example/android/apis/view line 42 Java Problem 

...and 841 more. 

我在做什麼錯?

+0

可能重複[安卓APIDemos編譯錯誤](http://stackoverflow.com/questions/7346662/android-apidemos-compile-錯誤) – 2012-03-12 16:55:04

回答

5

我剛剛有同樣的事情,發現埋在大量錯誤列表中,strings.xml存在一些xml解析錯誤。日食不喜歡的文字中有4個未轉義的單引號。問題字符串是「我離開了!」 「我開始了!」,以及「你會」和「你在」開始的大塊文本「Android平臺是一個軟件堆棧......」。如果你通過在每個撇號前加\來避開這些錯誤,所有的錯誤都會神奇地消失:)

0

請嘗試從File-> Import導入API Demo項目,然後顯示API Demo文件夾的目錄。

+0

嗨,我不知道我知道你的意思......我不能導入ApiDemos項目,因爲沒有項目中可用,它只是一個與文件/目錄(資產,資源,SRC,測試目錄,AndroidManifest.xml,default.properties)。我通過選擇File-> New-> Project >> Anroid Project >>從現有示例創建項目來創建項目。 – Czechnology 2010-11-28 19:25:09

0

嘗試定位最新的SDK版本,而不是1.5或1.6。

+0

但是,當試圖在1.6模擬器上運行時,不應該從/ platforms/android-4/samples中的ApiDemos示例工作正常嗎? (我的PDA仍然運行1.6操作系統,所以我的目標是讓它在這樣的設備上運行) – Czechnology 2010-11-28 20:04:37

0

我遇到同樣的問題。我正在運行MyEclipse 8.0。當你看到這些錯誤時,你會發現你需要引入一個IRemoteService類。我認爲這意味着com.eclipse.ecf.remoteservice.IRemoteService接口。我試圖加載ecf項目,但有問題。如果有人已經成功地將ECF集成到Eclipse中,請告訴我。

-1

我有同樣的問題,這是我的解決方案。

  1. 取消選中從菜單中的「項目」菜單中的「項目」
  2. 選擇「清潔」,「自動生成」。
  3. 選擇「下面選擇的清潔項目」並選中「ApiDemos」。
  4. 檢查「立刻開始構建」,「只有建立在選定的項目」

然後再編譯,因爲它應該(至少對我來說)。

此後,您可以再次在菜單「項目」中檢查「自動生成」。

複製自https://stackoverflow.com/a/9670606/785827。 希望它有幫助!

來自德國的問候。

0

確保您已將屬性> android設置爲正確的構建目標 - 然後清理並重試。

1

我起初有問題。這對我來說,使用API​​ 15:

  1. 首先刪除示例,並重新添加它使用SDK管理器,只是爲了確保你開始乾淨。
  2. 導入/安卓/將現有Android代碼到工作區
  3. 對於根目錄提供路徑ApiDemos,像中:/ opt/Android的軟件開發工具包/樣本/ Android的15/ApiDemos
  4. 點擊刷新,而ApiDemos包應該出現。選擇它並完成。

我覺得這很難設置,因爲初始嘗試在文件結構中產生eclipse文件,隨後嘗試失敗,因爲eclipse試圖再次使用這些文件。

0

我有類似的問題,我發現,這是因爲我已經進口了這個項目,到我已經有其他項目打開一個Eclipse工作空間。我選擇了「包資源管理器」窗格中的項目,然後選擇項目 - >關閉項目。我爲工作區中的每個其他項目都做了這樣的工作,只留下了ApiDemos項目。然後,我做了一個乾淨的構建,並取得了成功。 (有293條警告 - 行程)。

12

我有同樣的問題。

我發現日食已自動針對Android 1.6。但API演示來自4.4.2 sdk。

我在項目屬性中將'項目構建目標'更改爲Android 4.4.2並編譯並運行正常。

+0

同樣在這裏。請注意,有些人可能需要在更改目標後進行強制清理。 – Dean 2013-05-10 08:01:46

0

我在使用Gradle構建系統的Android Studio中遇到類似的問題。 而我的理由是不正確complie AIDL文件,例如IRemoteServiceIRemoteService.aidl實際上定義。所以我的解決辦法是在的build.gradle添加sourceSets配置如下:

sourceSets { 
    main { 
     dirs.each { dir -> 
      manifest.srcFile 'AndroidManifest.xml' 
      java.srcDirs "src" 
      res.srcDirs "res" 
      aidl.srcDirs "src" 
     } 
    }