Android studio-created AIDL cannot find a solution for custom classes during compilation. androidaidl
When you use AS to create an ADIL file, AS will generate an aidl folder and a package with the same package name under the main folder, we usually put all classes or files related to ADIL under this package. However, if a custom class exists, the program cannot pass during compilation, and the system prompts that the custom package cannot be found. Solution: add the following code to build. gradle of the startup Module:
sourceSets { main { manifest.srcFile 'src/main/AndroidManifest.xml' java.srcDirs = ['src/main/java', 'src/main/aidl'] resources.srcDirs = ['src/main/java', 'src/main/aidl'] aidl.srcDirs = ['src/main/aidl'] res.srcDirs = ['src/main/res'] assets.srcDirs = ['src/main/assets'] } }
The complete build. gradle file after adding is as follows:
apply plugin: 'com.android.application'android { compileSdkVersion 23 buildToolsVersion "23.0.2" defaultConfig { applicationId "aidl.aidl.demo" minSdkVersion 14 targetSdkVersion 23 versionCode 1 versionName "1.0" } sourceSets { main { manifest.srcFile 'src/main/AndroidManifest.xml' java.srcDirs = ['src/main/java', 'src/main/aidl'] resources.srcDirs = ['src/main/java', 'src/main/aidl'] aidl.srcDirs = ['src/main/aidl'] res.srcDirs = ['src/main/res'] assets.srcDirs = ['src/main/assets'] } } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } }}dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) testCompile 'junit:junit:4.12' compile 'com.android.support:appcompat-v7:23.1.1'}
In sourceSets, the src/main/aidl file is also used as java. srcDirs, resources. srcDirs, so that the custom classes in AIDL can be found during program compilation.