编译带有aidl文件的android源码项目报错

项目目录结构:

-- Setting
------- src
----------- main
--------------- java
--------------- aidl
-------------------- IBluetoothManager.aidl
-------------------- IBluetoothCallback.aidl
------- Android.bp

IBluetoothManager.aidl代码如下:

// IBluetooth1Manager.aidl
package com.example.setting;

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

import com.example.setting.IBluetoothCallback;

interface IBluetoothManager {
    void connectUnPariDevice(String addr);
    void unPair();
    void registerCallback(IBluetoothCallback callback);
}

IBluetoothCallback.aidl代码如下:

// IBluetoothCallback.aidl
package com.example.setting;

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

interface IBluetoothCallback {
    void onConnectionStateChanged(int state);
}

Android.bp代码如下:

android_app {
    name: "Setting",

    manifest: "src/main/AndroidManifest.xml",
    srcs: [
        "src/main/java/**/*.java",
        "src/main/aidl/**/*.aidl",
    ],

    //省略无关代码...
}

编译的时候出现如下错误:

ERROR: com.example.IBluetoothCallback: couldn't find import for class com.example.IBluetoothCallback

导致该错误的原因是没有指定系统应该在哪里查找 AIDL 文件

只需在Android.bp文件中添加如下属性就能解决这个错误:

aidl: {
        local_include_dirs: ["src/main/aidl"],
},

修改后的Android.bp文件如下:

android_app {
    name: "Setting",

    manifest: "app/src/main/AndroidManifest.xml",
    srcs: [
        "app/src/main/java/**/*.java",
        "app/src/main/aidl/com/ais/setting/IBluetoothCallback.aidl",
        "app/src/main/aidl/com/ais/setting/IBluetooth1Manager.aidl",
    ],

    aidl: {
            local_include_dirs: ["app/src/main/aidl"],
        },
    //省略无关代码...
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值