【问题标题】:not understanding compile errors in AIDL files不理解 AIDL 文件中的编译错误
【发布时间】:2013-01-14 01:00:41
【问题描述】:

我首次涉足 Android 服务时遇到了 AIDL 文件中的编译错误问题。我正在使用 Eclipse(带有 Android 开发工具)和 Android 4.1。我有以下 AIDL 文件:

Weather.aidl

package ws.hamacher.weatherservice.service;

parcelable ws.hamacher.weatherservice.dto.Weather;

在此文件中,我得到“接口 ws.hamacher.weatherservice.dto.Weather 应在名为 ws\hamacher\weatherservice\service\ws.aidl 的文件中声明。”在 parcelable 线上,但这指的是我的 Java 类!

IWeatherService.aidl

package ws.hamacher.weatherservice.service;

import ws.hamacher.weatherservice.service.Weather;

interface IWeatherService {
    void addToWeatherService(in Weather weather);
    void deleteFromWeatherService(in Weather weather);
    List<Weather> getLocations();
}

这里,import 语句再次给出了类似的错误“接口 ws.hamacher.weatherservice.dto.Weather 应在名为 ws\hamacher\weatherservice\service\ws.aidl 的文件中声明。”这应该是指上面的第一个文件吧?

除此之外,方法声明都有错误,与“未知类型天气”有关。

任何帮助将不胜感激。

【问题讨论】:

  • import 行与急救人员 sn-p 相关的内容是什么?你为什么把那个重要的部分漏掉了?
  • 感谢您的回复。不太明白你的问题。我已经提供了所有的错误信息和代码。
  • weather.aidl,你遗漏了什么?它应该被包裹在一个接口
  • 就像我说的,这对我来说是第一次。我正在关注书中的一个例子。请详细说明。谢谢。
  • 查看、显示并粘贴示例?请让您的问题“直截了当”。简单地引用一堆不相关的代码,让其他人猜测你的问题对回答者没有帮助

标签: android aidl


【解决方案1】:

如果你想发送自定义对象,例如 Weather 类,你应该创建一个包: ws.hamacher.weatherservice.dto

写:

天气.java

在包中:ws.hamacher.weatherservice.dto 像这样:

 public class Weather implements Parcelable {
....
}

然后,编写 Weather.aidl:

package ws.hamacher.weatherservice.dto;

parcelable Weather;

请参阅AndroidMusicPlayer 和 AndroidMusicPlayerClient 获取真实代码。

【讨论】:

  • 感谢您的回复。正如你所说,我已经创建了 Weather Java 类。
  • 可以看到AndroidMusicPlayer的源码。我可以帮忙。
【解决方案2】:

解决了。我的 Weather.aidl 必须与我的 parcelable Weather 类位于同一目录中。

【讨论】:

  • 我遇到了同样的错误..你能帮帮我吗..谢谢
猜你喜欢
  • 1970-01-01
  • 2017-04-27
  • 2013-10-17
  • 1970-01-01
  • 1970-01-01
  • 2019-04-03
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多