【发布时间】:2020-04-29 05:59:42
【问题描述】:
所以我有以下项目结构:
.
├── Central
│ ├── app
│ │ ├── build.gradle
│ │ └── src
│ ├── build.gradle
│ ├── gradle.properties
│ └── settings.gradle
└── Client
├── app
│ ├── build.gradle
│ └── src
├── build.gradle
├── gradle.properties
└── settings.gradle
在 Central 应用程序中,我定义了一个服务以及一个 AIDL 接口。在 AIDL 中,其中一个函数返回一个自定义对象(扩展 Parcelable)。在客户端应用程序中,我放置了完全相同的 AIDL 文件(在 src/aidl 目录中的同一包下)。我尝试通过声明对 Central 应用程序的 gradle 依赖项来导入自定义类。
这里是客户端的settings.gralde
rootProject.name='Client'
include ':app'
include ":Central"
project(":Central").projectDir = file('../Central/app')
客户的 app/build.gralde:
apply plugin: 'com.android.application'
android {
compileSdkVersion 29
buildToolsVersion "29.0.3"
defaultConfig {
applicationId "com.Patel.Cli3n5"
minSdkVersion 28
targetSdkVersion 29
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation project(path: ':Central', configuration: 'default')
}
还有aidl文件(在两个应用程序中都有):
package com.Patel.Central;
import android.graphics.Bitmap;
parcelable Info;
interface MusicCentral {
List<Info> getAllSongsInfo();
Bitmap getSongImage(int songNum);
}
请注意,Info 类是在包com.Patel.Central 中定义的。
当我尝试构建客户端应用程序时,我收到以下错误:
error: cannot find symbol
@Override public java.util.List<com.Patel.Central.Info> getAllSongsInfo() throws android.os.RemoteException
总而言之,问题是有一个自定义类,我需要从另一个目录中的应用程序导入。
【问题讨论】: