Common problems of AIDL cross-process communication

The problems encountered in learning AIDL today are summarized.
Question 1. The error "Interface name must be unique" occurs when the entity class Book is created while creating Book.aidl?
Solution:
Method 1. Delete the entity class, first create the Book.aidl file and create the entity class Book. java
method 2. Create a .aidl file at will. After the creation, modify the file name to Book
. Problem 2. Make Project report an error syntax error?
Solution: The error is caused by the .aidl file writing error. The entity class must be serialized to implement the interface. Parceable, the file package name needs to be introduced when referencing in the file .aidl, even if it is under the same package, it must be imported.
Question 3. Error crash at runtime java.lang.SecurityException: Binder invocation to an incorrect interface?
Solution: Because the package names of the two project storage .aidl files are inconsistent, they need to be unified, and the entity classes must also be unified.
How to use: Use the method that requires Service, binderService, and implicit startup.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324916240&siteId=291194637