eclipse 编译和运行 ApiDemos
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4298155/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Compiling and running ApiDemos
提问by Czechnology
I'm trying to compile Google's ApiDemos that come with the Android SDK. But I just CANT GET IT TO RUN! It makes me crazy already!!
我正在尝试编译 Android SDK 附带的 Google 的 ApiDemos。但我就是无法让它运行!已经让我抓狂了!!
When I create a new project in Eclipse based on the sample (target 1.5 or 1.6) and try to compile and run, I get almost a thousand errors. Not what I'd expect from a tutorial app!
当我基于示例(目标 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.
What am I doing wrong??
我究竟做错了什么??
采纳答案by Captain Spandroid
I just had the same thing, and found that buried in the massive list of errors, there were some xml parsing errors for strings.xml. There are 4 unescaped single quotes in the text which eclipse doesn't like. The problem strings are "I'm off!" "I'm on!", and "you'll" and "you're" in the big block of text starting "The Android platform is a software stack...". If you escape these by putting \ in front of each apostrophe, all the errors magically disappear :)
我刚刚遇到了同样的事情,发现在大量错误列表中,strings.xml 存在一些 xml 解析错误。eclipse 不喜欢的文本中有 4 个未转义的单引号。问题字符串是“我走了!” “我在!”、“你会”和“你是”在大块的文本中以“Android 平台是一个软件堆栈......”开头。如果您通过将 \ 放在每个撇号前面来逃避这些,所有错误都会神奇地消失:)
回答by Charlie A
I had the same problem.
我有同样的问题。
I found that eclipse had automatically targeted Android 1.6. But the API demo was from the 4.4.2 sdk.
我发现 eclipse 已经自动针对 Android 1.6。但是 API 演示来自 4.4.2 sdk。
I changed the 'project build target' to Android 4.4.2 in the project properties and it compiled and ran fine.
我在项目属性中将“项目构建目标”更改为 Android 4.4.2,它编译并运行良好。
回答by John Lehmann
I had problems at first. This worked for me, using API 15:
一开始我遇到了问题。这对我有用,使用 API 15:
- First remove the samples and re-add it using the SDK manager, just to be sure you're starting clean.
- Import/Android/Existing Android Code into Workspace
- For root directory provide the path to ApiDemos, like: /opt/android-sdks/samples/android-15/ApiDemos
- Click refresh, and the ApiDemos package should show up. Select it and finish.
- 首先删除示例并使用 SDK 管理器重新添加它,以确保您开始干净。
- 将/Android/现有 Android 代码导入工作区
- 对于根目录,提供 ApiDemos 的路径,例如:/opt/android-sdks/samples/android-15/ApiDemos
- 单击刷新,应该会显示 ApiDemos 包。选择它并完成。
I think this is tricky to setup because initial attempts produce eclipse files within the file structure, and subsequent attempts fail because eclipse tries to use those files again.
我认为这设置起来很棘手,因为最初的尝试会在文件结构中生成 eclipse 文件,随后的尝试会失败,因为 eclipse 会尝试再次使用这些文件。
回答by kcstrom
I had similar issues and I found that it was because I had imported the project into an Eclipse workspace that I already had other projects open in. I selected those projects in the "Package Explorer" pane and then selected Project->Close Project. I did that for each other project in the workspace leaving only the ApiDemos project open. Then I did a clean build and it was successful. (with 293 warnings - yikes).
我遇到了类似的问题,我发现这是因为我将项目导入到 Eclipse 工作区中,而我已经在其中打开了其他项目。我在“包资源管理器”窗格中选择了这些项目,然后选择了项目->关闭项目。我为工作区中的每个其他项目都这样做了,只留下 ApiDemos 项目打开。然后我做了一个干净的构建,它成功了。(有 293 个警告 - 哎呀)。
回答by gypsicoder
Please try importing the API Demo project from File->Import then show the directory of the API Demo folder.
请尝试从 File->Import 导入 API Demo 项目,然后显示 API Demo 文件夹的目录。
回答by Eric Levine
Try targeting the latest SDK version, rather than 1.5 or 1.6.
尝试针对最新的 SDK 版本,而不是 1.5 或 1.6。
回答by Keith
I am getting the same issue. I am running MyEclipse 8.0. When you look at these errors you see that you need to bring in an IRemoteService class. I assumed this means the com.eclipse.ecf.remoteservice.IRemoteService interface. I tried to load the ecf project but there are issues with that. If anyone has successfully integrated ECF into their Eclipse let me know.
我遇到了同样的问题。我正在运行 MyEclipse 8.0。当您查看这些错误时,您会发现您需要引入一个 IRemoteService 类。我认为这意味着 com.eclipse.ecf.remoteservice.IRemoteService 接口。我尝试加载 ecf 项目,但存在问题。如果有人成功地将 ECF 集成到他们的 Eclipse 中,请告诉我。
回答by Joe Wang
I encounter similar issues in Android Studio with Gradle build system.
And my reason is not complie aidl files correctly, for example IRemoteService
is defined in IRemoteService.aidlactually. So my solution is add sourceSets configuration in build.gradleas follow:
我在使用 Gradle 构建系统的 Android Studio 中遇到了类似的问题。而我的原因是没有正确编译aidl文件,例如实际上IRemoteService
是在IRemoteService.aidl中定义的。所以我的解决方案是在build.gradle 中添加 sourceSets 配置如下:
sourceSets {
main {
dirs.each { dir ->
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs "src"
res.srcDirs "res"
aidl.srcDirs "src"
}
}
回答by bkurzius
Make sure that you have set properties>android to the correct build target -- then clean and retry.
确保您已将 properties>android 设置为正确的构建目标——然后清理并重试。
回答by Riffer
I had the same problem and this is my solution.
我有同样的问题,这是我的解决方案。
- Uncheck "Build automatically" in the menu "project"
- Select "Clean" from menu "project".
- Select "Clean projects selected below" and check "ApiDemos".
- Check "Start a build immediatly", "Build only the selected projects"
- 在菜单“项目”中取消选中“自动构建”
- 从菜单“项目”中选择“清洁”。
- 选择“清理下面选择的项目”并选中“ApiDemos”。
- 选中“立即开始构建”、“仅构建选定的项目”
Then it compiles as it should (at least for me).
然后它按照它应该的方式编译(至少对我来说)。
After this you can check "Build automatically" in the menu "project" again.
在此之后,您可以再次选中菜单“项目”中的“自动构建”。
Copied from https://stackoverflow.com/a/9670606/785827. Hope it helps!
复制自https://stackoverflow.com/a/9670606/785827。希望能帮助到你!
Best regards from germany.
来自德国的问候。