您的位置:首页 > 移动开发 > Android开发

Android Studio, aidl refusing to generate code from aidl file defining parcelable. Why?

2019-07-17 17:03 3367 查看

Test.java (Implements Parcelable):

package com.app.pack.classes;

public class Test implements Parcelable {

private int test = 33;

protected Test(Parcel in) {
test = in.readInt();
}

@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeInt(test);
}

@Override
public int describeContents() {
return 0;
}

public static final Creator<Test> CREATOR = new Creator<Test>() {
@Override
public Test createFromParcel(Parcel in) {
return new Test(in);
}

@Override
public Test[] newArray(int size) {
return new Test[size];
}
};
}

Test.aidl (Declares the class I want to send):

package com.app.pack.aidl;
parcelable Test;

TestService.aidl (provides the method that returns a Test object):

package com.app.pack.aidl;
import com.app.pack.aidl.Test;

interface TestService{
Test getAll(in int[] listOfInts);
}

这样写编译会报错:
refusing to generate code from aidl file defining parcelable couldn’t find import for class xxxxx

原因:
Test类的包名称,Test.aidl中的com.app.pack.aidl与Java代码中的com.app.pack.classes之间存在不匹配(不一样); 他们需要匹配(完全一样)。

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐