简体   繁体   中英

AIDL passing object parameter

im currently stuck at using Object type for the AIDL.

SongItem.java

public class SongItem implements Parcelable{

}

SongItem.aidl

// SongItem.aidl
package com.example.krot.musicplayer;

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

MyAIDL.aidl

 interface IPlaybackAction {

     void setSongList(in List<SongItem> item);
 }

Everytime i rebuild the project it keeps saying that

Error:aidl E 03-07 17:18:19 14651 1413571 type_namespace.cpp:129] unknown type

The package for the SongItem class must match exactly between the Java and the AIDL, and the MyAIDL.aidl file must import the class (which is why you have the SongItem.aidl file which declares the class as parcelable .

Add this to the top of MyAIDL.aidl :

import com.example.krot.musicplayer.model.SongItem;

From the package structure image provided in the deleted answer, I can see SongItem.java is in a different package than what is in the AIDL. Move your SongItem.aidl file to be in the directory src/main/aidl/com/example/krot/musicplayer/model and update the package declaration at the top of that file to be com.example.krot.musicplayer.model .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM