android - AIDL 无法找到 Parcelable 类的定义

标签 android class parcelable aidl

我有以下项目结构。

enter image description here

我的 StockInfo.java 完全没问题。

StockInfo.java(无错误)

package org.yccheok.jstock.engine;

import android.os.Parcel;
import android.os.Parcelable;

public class StockInfo implements Parcelable {
    ...
    ...

StockInfo.aidl(无错误)

package org.yccheok.jstock.engine;

parcelable StockInfo;

StockInfoObserver.aidl(错误!)

package org.yccheok.jstock.engine;

interface StockInfoObserver {

    void update(StockInfo stockInfo);
}

AutoCompleteApi.aidl(错误!)

package org.yccheok.jstock.engine;

interface AutoCompleteApi {

    void handle(String string);
    void attachStockInfoObserver(StockInfoObserver stockInfoObserver);
}

但是,Eclipse 在 StockInfoObserver.aidl 中提示(它也提示 AutoCompleteApi.aidl,因为它无法处理 StockInfoObserver.aidl),

参数stockInfo(1)未知类型StockInfo

我试了一个小时,还是没找到,为什么在aidl中,虽然我有StockInfo却没有被识别

  1. 提供StockInfo.aidl
  2. 提供StockInfo.java

有什么想法吗?

这里是完整的错误。

enter image description here

请注意,AutoCompleteApi.aidl 非常依赖于 StockInfoObserver.aidl。这就是您会看到错误的原因。

我分享整个项目供您引用:https://www.dropbox.com/s/0k5pe75jolv5mtq/jstock-android.zip

最佳答案

根据 Android 文档 您必须为上面未列出的每个其他类型包含一个 import 语句,即使它们是在与您的接口(interface)相同的包中定义的也是如此

尝试将此行添加到 StockInfoObserver.aidl

import org.yccheok.jstock.engine.StockInfo;

关于android - AIDL 无法找到 Parcelable 类的定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14263005/

相关文章:

android - solo.searchButton 总是返回 true (Android 2.3.6 with robotium)

android - Unresolved 类 MainActivity - AndroidManifest.xml

python - 如何在Python中处理类**kwargs?

c++ - 包含头文件的顺序是什么?

java - 无法保存RelativeLayout的状态

android - 无法在 flutter 中提取 zipper

c++ - 为什么C++不允许派生类在初始化列表中使用基类成员?

java - Java Parceler 问题

android - 通过广播 Intent 传递 ArrayList

android - 在 Linux 中运行 Android 应用程序