12

I'm trying to compile .aidl and generate .java but:

Error:Execution failed for task ':library:compileReleaseAidl'.
> java.lang.RuntimeException: com.android.ide.common.process.ProcessException:
Error while executing 'C:\Users\Michele\AppData\Local\Android\sdk\build-tools\25.0.0\aidl.exe'
with arguments {-pC:\Users\Michele\AppData\Local\Android\sdk\platforms\android-25\framework.aidl
-oC:\Users\Michele\workspace\AndroidLib\library\build\generated\source\aidl\release
-IC:\Users\Michele\workspace\AndroidLib\library\src
-IC:\Users\Michele\workspace\AndroidLib\library\src\release\aidl
-IC:\Users\Michele\workspace\AndroidLib\library\build\intermediates\exploded-aar\com.android.support\appcompat-v7\25.0.1\aidl
-IC:\Users\Michele\workspace\AndroidLib\library\build\intermediates\exploded-aar\com.android.support\support-v4\25.0.1\aidl
-IC:\Users\Michele\workspace\AndroidLib\library\build\intermediates\exploded-aar\com.android.support\support-fragment\25.0.1\aidl
-IC:\Users\Michele\workspace\AndroidLib\library\build\intermediates\exploded-aar\com.android.support\support-media-compat\25.0.1\aidl
-IC:\Users\Michele\workspace\AndroidLib\library\build\intermediates\exploded-aar\com.android.support\support-core-ui\25.0.1\aidl
-IC:\Users\Michele\workspace\AndroidLib\library\build\intermediates\exploded-aar\com.android.support\support-core-utils\25.0.1\aidl
-IC:\Users\Michele\workspace\AndroidLib\library\build\intermediates\exploded-aar\com.android.support\animated-vector-drawable\25.0.1\aidl
-IC:\Users\Michele\workspace\AndroidLib\library\build\intermediates\exploded-aar\com.android.support\support-vector-drawable\25.0.1\aidl
-IC:\Users\Michele\workspace\AndroidLib\library\build\intermediates\exploded-aar\com.android.support\support-compat\25.0.1\aidl
-dC:\Users\Michele\AppData\Local\Temp\aidl3070615992051288022.d
C:\Users\Michele\workspace\AndroidLib\library\src\IRemoteShortcutService.aidl}

I use this build.gradle

apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven'

group='com.github.michelelacorte'

android {
    compileSdkVersion 25
    buildToolsVersion '25.0.0'

    defaultConfig {
        minSdkVersion 14
        targetSdkVersion 25
        versionCode 2
        versionName "0.2.0"

        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

    }

    sourceSets {
        main {
            aidl.srcDirs = ['src/main/aidl']
        }
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:25.0.1'
    testCompile 'junit:junit:4.12'
    compile 'com.google.code.gson:gson:2.8.0'
}

And this root build.gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.2.3'
        classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

I've read about issue with build tools, but I doesn't found anything about API 25

EDIT:

I've launched aidl.exe with params and it return:

aidl.exe E  2236 13884 aidl_language.cpp:224] Error while opening file for parsing: 'C:\Users\Michele\workspace\AndroidLib\library\src\IRemoteShortcutService.aidl'

EDIT 2:

Shortcut.aidl

// Shortcut.aidl
package it.michelelacorte.androidshortcuts;

parcelable Shortcuts;

IRemoteShortcutService.aidl

// IRemoteShortcutService.aidl
package it.michelelacorte.androidshortcuts;

interface IRemoteShortcutService {

    void addShortcuts(int shortcutsImage, String shortcutsText);

    Shortcuts getShortcuts();
}

This .aidl are located in src/main/aidl folder

7
  • call buildToolsVersion '25.0.1' .Hope this helps .let me inform Dec 19, 2016 at 8:21
  • I've tried...but nothing Dec 19, 2016 at 8:40
  • may i know your gradle-wrapper version ? mine ..gradle-2.14.1-all.zip Dec 19, 2016 at 8:51
  • Accidentaly posted as an answer instead of comment. Did you try to add verbose option to gradle or execute the same aidl.exe manually with the same parameters? Probably there is an explanatory error code or message from aidl.exe that gradle does not show. Dec 19, 2016 at 9:26

4 Answers 4

7
+25

Did you try to add verbose option to gradle or execute the same aidl.exe manually with the same parameters?

Probably there is an explanatory error code or message from aidl.exe that gradle does not show.

According to the error aidl can not open the file. Check if file exists there and the content is valid.

Try to change to the new default layout:

Put aidl files in /src/main/aidl

build.gradle:

...
    sourceSets {
        main {
            aidl.srcDirs = ['src/main/aidl']
        }
    }

(though, in general, if file is in /src/main/aidl it is supposed to work without aidl.srcDirs entry)

Don't forget that aidl files should be under package folders like java. For example, if the package is it.michelelacorte.testaidl, the aidl file should be under src/main/aidl/it/michelelacorte/testaidl.

In recent version of Android Studio, the New/AIDL/AIDL File project menu should already place the file under correct folder, if project package is set correctly.

11
  • There is no any problem compiling aidl with build tools 25.0.0, actually working fine without modifying aidl.srcDirs if aidl files are in src/main/aidl as expected. If you can put somewhere zip with minimal failing sample we can check if the problem is in your sources/project or is it in your build environment setup. How do you run it? Studio or command line? Did you try to create new project with aidl from scratch in Studio, change versions to yours and see if there is the same problem? Dec 21, 2016 at 21:48
  • This you already said, but this is not a constructive dialog, it is not clear what exactly you did and what are the results. I suggested above a constructive way to proceed.with understanding of your problem. Fresh installation of 25.0.0 has no problem with aidl. So either the cause is in your sources or is in your environment. Put somewhere reduced sources that reproduce the problem so we can take a look and understand. Understanding if the problem is in sources or is it in the environment is an important step, don't you think? Dec 22, 2016 at 11:17
  • When you place files as required in src/main/aidl, what error do you get this time when running the failed command of changed structure manually? May be you forgot to put in package folders etc. and there is new error sufficient to understand the problem. If you were preparing a zip with minimal reproducible project it was much easier to check. Dec 22, 2016 at 13:51
  • It can not be the same error because at least you moved files to src/main/aidl and the path in output should be different. Dec 22, 2016 at 13:54
  • It change from \AndroidLib\library\src` to \AndroidLib\library\src\main\aidl Please do not make me repeat the same things, it's becoming frustrating... Dec 22, 2016 at 13:57
4

After refactoring java packages, the aidl files changed the packages structure also, but it missed the package in the file itself.

Assure that the aidl specifies the same package (first line in the .aidl) than the folder where it is.

1
  • Thanks a ton. I didn't notice my aidl files are lying in old package. Apr 21, 2019 at 19:07
2

please add

import it.michelelacorte.androidshortcuts.Shortcuts;

in IRemoteShortcutService.aidl file.

0

I have the same build's version as yours.

I just try to edit IRemoteShortcutService.aidl to import the Shortcut class.

Although, they are in the same package, then it compiles successfully.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.