如何解决compileDebugAidl?

时间:2018-06-26 02:16:54

标签: android aidl

该代码是示例。我只使用了可打包的Java bean Book,此后,我创建了Book.aidl文件和IBookManager.aidl文件。代码如下所示。我找不到错误在哪里,可能有人可以告诉我吗?非常感谢。

public class Book implements Parcelable {
    private String name;
    private int price;

protected Book(Parcel in) {
    name = in.readString();
    price = in.readInt();
}

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

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

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

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

  public void readFromParcel(Parcel dest) {
    //注意,此处的读值顺序应当是和writeToParcel()方法中一致的
    name = dest.readString();
    price = dest.readInt();
}

public String getName() {
    return name;
}

public void setName(String name) {
    this.name = name;
}

public int getPrice() {
    return price;
}

public void setPrice(int price) {
    this.price = price;
}

public Book() {
}

@Override
public String toString() {
    return "Book{" +
            "name='" + name + '\'' +
            ", price=" + price +
            '}';
}

IBook.aidl文件

package com.example.administrator.test2;

// Declare any non-default types here with import statements
parcelable Book;

IBookManager.aidl文件

package com.example.administrator.test2;
import  com.example.administrator.test2.Book;

// Declare any non-default types here with import statements

interface BookManager {
    /**
     * Demonstrates some basic types that you can use as parameters
     * and return values in AIDL.
     */
        List<Book> getBooks();
        void addBook(in Book book);
}

崩溃显示如下。

   Error:Execution failed for task ':app:compileDebugAidl'.

> java.io.IOException: com.android.ide.common.process.ProcessException: Error while executing process D:\Android_SDK\build-tools\26.0.2\aidl.exe with arguments {-pD:\Android_SDK\platforms\android-26\framework.aidl -oC:\Users\Administrator\Desktop\Test2\app\build\generated\source\aidl\debug -IC:\Users\Administrator\Desktop\Test2\app\src\debug\aidl -IC:\Users\Administrator\Desktop\Test2\app\src\main\aidl -IC:\Users\Administrator\.gradle\caches\transforms-1\files-1.1\support-media-compat-26.1.0.aar\714135a4b68e61f21a17e61af53f820a\aidl -IC:\Users\Administrator\.gradle\caches\transforms-1\files-1.1\support-compat-26.1.0.aar\f243d299e7951d2f761f12b2eb0be63d\aidl -dC:\Users\ADMINI~1\AppData\Local\Temp\aidl6704255644871633464.d C:\Users\Administrator\Desktop\Test2\app\src\main\aidl\com\example\administrator\test2\IBookManager.aidl}

0 个答案:

没有答案