Aidl created with Android Studio cannot find a custom class solution _android

Source: Internet
Author: User

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!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.