赞
踩
问题1.新版本android studio(2022.2.1)无法创建aidl文件,创建选项是灰色的。
解决办法(来源:解决androidstudio2022.2.1新建不了aidl文件_android_lingz的博客-CSDN博客):
build.gradle(app)添加
- buildFeatures{
- aidl true
- }
问题2.android studio导入包含aidl的项目以后,aidl文件中的接口类在实现代码中提示找不到类型。
解决方法:
build.gradle(app)中的android节点下面,有个sourceSets节点(没有的话手动添加),在main里面添加 aidl.srcDirs = ['src\\main\\aidl\\com\\hh\\apiserver'],并clean项目重新rebuild一下。
sourceSets {
main {
jniLibs.srcDirs = ['libs']
aidl.srcDirs = ['src\\main\\aidl\\com\\hh\\apiserver']
}
}
问题3.新版本的Android studio引入class.jar这种系统jar包以后,需要修改编译顺序,系统中添加的相关方法才能够识别到。
方法:在.idea目录下找到项目的.iml文件,将其中的
<orderEntry type="jdk" jdkName="Android API 33 Platform" jdkType="Android SDK" />类似这个移动到最下面。
将添加的framework-connectivity-t.jar放到 build.gradle (app)中的dependencies节点。
dependencies {
//implementation fileTree(include: ['*.jar'], dir: 'libs')
compileOnly files('libs/framework-connectivity-t.jar')
build.gradle (项目)中的allprojects添加如下节点:
gradle.projectsEvaluated {
tasks.withType(JavaCompile) {
Set<File> fileSet = options.bootstrapClasspath.getFiles()
List<File> newFileList = new ArrayList<>();
newFileList.add(new File("app/libs/framework-connectivity-t.jar"))
newFileList.addAll(fileSet)
options.bootstrapClasspath = files(
newFileList.toArray()
)
}
}
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。