当前位置:   article > 正文

【Android支持】AIDL文件无法生成Java接口代码_android studio aidl无法自动生成java

android studio aidl无法自动生成java

版本Android Studio Dolphin | 2021.3.1 Patch 1
这个版本右键就可以创建AIDL文件——自动创建一个aidl文件夹(自动生成包路径),自动生成AIDL文件

// IStudent.aidl
package com.daban.remoteservice;

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

interface IStudent {
    /**
     * Demonstrates some basic types that you can use as parameters
     * and return values in AIDL.
     */
    void basicTypes(int anInt, long aLong, boolean aBoolean, float aFloat,
            double aDouble, String aString);
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13

我们改成我们需要的模式

package com.daban.remoteservice;
import com.daban.remoteservice.Student;
interface IStudentService {
    Student getStudentById(int id);
}
  • 1
  • 2
  • 3
  • 4
  • 5

这个文件如果要引用自定义类Student,需要import导入类
并且创建一个自定义类的AIDL文件,内容如下

package com.daban.remoteservice;
parcelable Student;
  • 1
  • 2

无法生成接口文件的其他原因我不知道
我的原因时gradle的问题

解决办法:
删除目录中的build文件夹,重启项目,就会自动创建build文件夹,这时接口文件就自动生成了

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/article/detail/40914
推荐阅读
相关标签
  

闽ICP备14008679号