AndroidStudio 引入 aidl 文件,一般来说,有两种方法.
第一种方法
直接在 src/main 目录下新建 aidl 文件夹,并将我们的 aidl 文件放到该目录下。因为 AndroidStudio 默认的 aidl 文件默认配置是这样的。
第二种方法 把 adil 文件拷贝到libs文件夹下在build.gradle文件中配置
sourceSets { main { jniLibs.srcDirs = ['libs'] aidl.srcDirs = ['src/main/java'] } }
最后给大家分享个实例:
项目迁移后文件夹变动如下:
Android Gradle projects use a different directory structure than ADT Eclipse projects. Here's how the projects were restructured: * AndroidManifest.xml => appsrcmainAndroidManifest.xml * assets => appsrcmainassets * libsxUtils-2.5.5.jar => applibsxUtils-2.5.5.jar * proguard-android.txt => appproguard-android.txt * proguard-project.txt => appproguard-project.txt * res => appsrcmainres * src => appsrcmainjava * srcandroidcontentpmIPackageDataObserver.aidl => appsrcmainaidlandroidcontentpmIPackageDataObserver.aidl * srcandroidcontentpmIPackageStatsObserver.aidl => appsrcmainaidlandroidcontentpmIPackageStatsObserver.aidl * srcandroidcontentpmPackageStats.aidl => appsrcmainaidlandroidcontentpmPackageStats.aidl * srcandroidtelephonyNeighboringCellInfo.aidl => appsrcmainaidlandroidtelephonyNeighboringCellInfo.aidl * srccomandroidinternaltelephonyITelephony.aidl => appsrcmainaidlcomandroidinternaltelephonyITelephony.aidl
引入aidl文件:如提示中所说需要在appsrcmain下创建aidl目录,接着包名文件名.aidl
例:adt中文件路径:
srcandroidcontentpmIPackageDataObserver.aidl
Android Studio中文件路径:
appsrcmainaidlandroidcontentpmIPackageDataObserver.aidl