When you create a Adil file using as, the as will generate a Aidl folder and a package with the same package name under the main folder. Usually we put all the Adil-related classes or files under this package, but if there is a custom class, the program fails to compile, prompting that the custom package cannot be found. The solution is to add the following code to the 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 ']
}
After joining, the complete Build.gradle file reads as follows:
Apply plugin: ' Com.android.application '
Android {
compilesdkversion
buildtoolsversion "23.0.2"
defaultconfig {
ApplicationID " Aidl.aidl.demo "
minsdkversion
targetsdkversion
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 when the program is compiled, the custom class in Aidl can be found.
The above to introduce you to use the Android studio created Aidl compile-time can not find a custom class solution, I hope to help!