Android 安卓;cl不能解析为变量";错误

Android 安卓;cl不能解析为变量";错误,android,Android,我对android的AIDL文件有问题。我从网上下载了一个示例项目,我在代码中看到,他们有一个AIDL文件。我不知道这个文件是什么,我做了一些研究并编写了一些代码 在创建了一个AIDL文件之后,我声明了这样一个方法 interface IRemoteService{ Map onClick(in int id, in Map state); } 然后Eclipse将自动生成一个文件IRemoteService.java,并返回错误: cl cannot be resolved to a v

我对android的AIDL文件有问题。我从网上下载了一个示例项目,我在代码中看到,他们有一个AIDL文件。我不知道这个文件是什么,我做了一些研究并编写了一些代码

在创建了一个AIDL文件之后,我声明了这样一个方法

interface IRemoteService{
  Map onClick(in int id, in Map state);
}
然后Eclipse将自动生成一个文件
IRemoteService.java
,并返回错误:

cl cannot be resolved to a variable
我做错什么了吗

编辑 这是自动生成的IRemoteService.java

/*
 * This file is auto-generated.  DO NOT MODIFY.
 * Original file: /home/nampham/Data/works/workspace/MapAidl/src/nampham/mapaidl/IRemoteService.aidl
 */
package nampham.mapaidl;
public interface IRemoteService extends android.os.IInterface
{
/** Local-side IPC implementation stub class. */
public static abstract class Stub extends android.os.Binder implements nampham.mapaidl.IRemoteService
{
private static final java.lang.String DESCRIPTOR = "nampham.mapaidl.IRemoteService";
/** Construct the stub at attach it to the interface. */
public Stub()
{
this.attachInterface(this, DESCRIPTOR);
}
/**
 * Cast an IBinder object into an nampham.mapaidl.IRemoteService interface,
 * generating a proxy if needed.
 */
public static nampham.mapaidl.IRemoteService asInterface(android.os.IBinder obj)
{
if ((obj==null)) {
return null;
}
android.os.IInterface iin = (android.os.IInterface)obj.queryLocalInterface(DESCRIPTOR);
if (((iin!=null)&&(iin instanceof nampham.mapaidl.IRemoteService))) {
return ((nampham.mapaidl.IRemoteService)iin);
}
return new nampham.mapaidl.IRemoteService.Stub.Proxy(obj);
}
public android.os.IBinder asBinder()
{
return this;
}
@Override public boolean onTransact(int code, android.os.Parcel data, android.os.Parcel reply, int flags) throws android.os.RemoteException
{
switch (code)
{
case INTERFACE_TRANSACTION:
{
reply.writeString(DESCRIPTOR);
return true;
}
case TRANSACTION_click:
{
data.enforceInterface(DESCRIPTOR);
int _arg0;
_arg0 = data.readInt();
java.util.Map _arg1;
java.lang.ClassLoader cl = (java.lang.ClassLoader)this.getClass().getClassLoader();
_arg1 = data.readHashMap(cl);
java.util.Map _result = this.click(_arg0, _arg1);
reply.writeNoException();
reply.writeMap(_result);
return true;
}
}
return super.onTransact(code, data, reply, flags);
}
private static class Proxy implements nampham.mapaidl.IRemoteService
{
private android.os.IBinder mRemote;
Proxy(android.os.IBinder remote)
{
mRemote = remote;
}
public android.os.IBinder asBinder()
{
return mRemote;
}
public java.lang.String getInterfaceDescriptor()
{
return DESCRIPTOR;
}
public java.util.Map click(int id, java.util.Map state) throws android.os.RemoteException
{
android.os.Parcel _data = android.os.Parcel.obtain();
android.os.Parcel _reply = android.os.Parcel.obtain();
java.util.Map _result;
try {
_data.writeInterfaceToken(DESCRIPTOR);
_data.writeInt(id);
_data.writeMap(state);
mRemote.transact(Stub.TRANSACTION_click, _data, _reply, 0);
_reply.readException();
_result = _reply.readHashMap(cl);  `<<< This line return error`
}
finally {
_reply.recycle();
_data.recycle();
}
return _result;
}
}
static final int TRANSACTION_click = (android.os.IBinder.FIRST_CALL_TRANSACTION + 0);
}
public java.util.Map click(int id, java.util.Map state) throws android.os.RemoteException;
}
/*
*此文件是自动生成的。不要修改。
*原始文件:/home/nampham/Data/works/workspace/MapAidl/src/nampham/MapAidl/IRemoteService.aidl
*/
包装nampham.mapaidl;
公共接口IRemoteService扩展了android.os.IInterface
{
/**本地端IPC实现存根类*/
公共静态抽象类存根扩展了android.os.Binder实现了nampham.mapaidl.IRemoteService
{
私有静态final java.lang.String描述符=“nampham.mapaidl.IRemoteService”;
/**在将存根连接到接口时构造存根*/
公共存根()
{
this.attachInterface(this,描述符);
}
/**
*将IBinder对象强制转换为nampham.mapaidl.IRemoteService接口,
*如果需要,生成代理。
*/
公共静态nampham.mapaidl.IRemoteService作为接口(android.os.IBinder obj)
{
如果((obj==null)){
返回null;
}
android.os.IInterface iin=(android.os.IInterface)obj.queryLocalInterface(描述符);
if(((iin!=null)和&(iin instanceof nampham.mapaidl.IRemoteService))){
返回((nampham.mapaidl.IRemoteService)iin);
}
返回新的nampham.mapaidl.IRemoteService.Stub.Proxy(obj);
}
公共android.os.IBinder asBinder()
{
归还这个;
}
@覆盖公共布尔onTransact(int代码、android.os.Parcel数据、android.os.Parcel回复、int标志)抛出android.os.RemoteException
{
开关(代码)
{
案例接口\u事务:
{
答复.书面限制(描述符);
返回true;
}
案例交易点击:
{
数据接口(描述符);
int_arg0;
_arg0=data.readInt();
java.util.Map_arg1;
java.lang.ClassLoader cl=(java.lang.ClassLoader)this.getClass().getClassLoader();
_arg1=data.readHashMap(cl);
java.util.Map _result=this.click(_arg0,_arg1);
reply.writeNoException();
答复.书面答复(_结果);
返回true;
}
}
返回super.onTransact(代码、数据、回复、标志);
}
私有静态类代理实现nampham.mapaidl.IRemoteService
{
私有android.os.IBinder mRemote;
代理(android.os.IBinder远程)
{
mRemote=远程;
}
公共android.os.IBinder asBinder()
{
返回mRemote;
}
public java.lang.String getInterfaceDescriptor()
{
返回描述符;
}
public java.util.Map click(int-id,java.util.Map-state)抛出android.os.RemoteException
{
android.os.Parcel _data=android.os.Parcel.get();
android.os.Parcel _reply=android.os.Parcel.get();
java.util.Map_结果;
试一试{
_data.writeInterfaceToken(描述符);
_数据写入(id);
_data.writeMap(状态);
mRemote.transact(Stub.TRANSACTION\u单击,\u数据,\u回复,0);
_reply.readException();
_结果=_reply.readHashMap(cl);`问题在于:

_result = _reply.readHashMap(cl);
其中,
cl不能解析为变量,因为
cl
onTransact()中本地定义的

我不知道自动生成的代码是否意味着不应该修改或不能修改。但是,我可以告诉你的是,除非你编辑代码并:

  • 在错误行之前添加另一个
    cl
    定义:

    java.lang.ClassLoader cl = (java.lang.ClassLoader)this.getClass().getClassLoader();
    _result = _reply.readHashMap(cl);
    

什么是
aidl文件
?你能发布整个跟踪吗?我,请看一下这个页面:你会知道什么是aidl文件。使用CAPS!现在发布完整的跟踪。对不起,我不知道CAPS是什么。你想知道我是怎么做的以及我从Eclipse收到了什么,对吗?CAPS:
aidl->aidl
:)。是的,发布你收到的错误日志来自Eclipse的e。谢谢您的时间。正如您所说,我已在错误行之前添加了上面的行,但Eclipse在保存文件后返回错误。错误是“IRemoteService.java已手动修改!还原到生成的版本!”@NamPham抱歉。我想不出任何其他内容。
java.lang.ClassLoader cl = (java.lang.ClassLoader)this.getClass().getClassLoader();
_result = _reply.readHashMap(cl);