Android studio-created AIDL cannot find a solution for custom classes during compilation. androidaidl

Source: Internet
Author: User

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.

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.