本文介绍了AIDL无法找到Parcelable类的定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下项目结构。





我的 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 code>(它也抱怨 AutoCompleteApi.aidl ,因为它不能处理 StockInfoObserver.aidl ), / p>

参数stockInfo(1)未知类型StockInfo



但仍然无法找到,为什么在aidl, StockInfo 不被识别,虽然我有


  1. 提供 StockInfo.aidl

  2. 提供 StockInfo.java

有任何想法吗?



这是完整的错误。



>



注意, AutoCompleteApi.aidl 非常依赖 StockInfoObserver.aidl 。这是为什么你会看到错误。



我共享整个项目作为参考目的:

解决方案

根据Android文档您必须为上面没有列出的每个附加类型包括一个import语句,即使它们在与您的接口相同的包中定义



尝试将此行添加到 StockInfoObserver.aidl

  import org.yccheok.jstock.engine.StockInfo; 


I have the following project structure.

My StockInfo.java is perfectly fine.

StockInfo.java (No error)

package org.yccheok.jstock.engine;

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

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

StockInfo.aidl (No error)

package org.yccheok.jstock.engine;

parcelable StockInfo;

StockInfoObserver.aidl (Error!)

package org.yccheok.jstock.engine;

interface StockInfoObserver {

    void update(StockInfo stockInfo);
}

AutoCompleteApi.aidl (Error!)

package org.yccheok.jstock.engine;

interface AutoCompleteApi {

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

However, Eclipse complains in StockInfoObserver.aidl (It does complain AutoCompleteApi.aidl too, as it cannot process StockInfoObserver.aidl),

parameter stockInfo (1) unknown type StockInfo

I tried for an hour, but still not able to find out, why in aidl, StockInfo is not being recognized although I had

  1. Provided StockInfo.aidl
  2. Provided StockInfo.java

Any idea?

Here are the complete errors.

Note, AutoCompleteApi.aidl is very much dependent on StockInfoObserver.aidl. That's why you will see the error.

I share the entire project for your reference purpose : https://www.dropbox.com/s/0k5pe75jolv5mtq/jstock-android.zip

解决方案

According to Android documentation You must include an import statement for each additional type not listed above, even if they are defined in the same package as your interface

Try to add this line to StockInfoObserver.aidl

import org.yccheok.jstock.engine.StockInfo;

这篇关于AIDL无法找到Parcelable类的定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-19 07:47