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

Michele Lacorte
  • 5,323
  • 7
  • 32
  • 54
  • call `buildToolsVersion '25.0.1'` .Hope this helps .let me inform – IntelliJ Amiya Dec 19 '16 at 08:21
  • I've tried...but nothing – Michele Lacorte Dec 19 '16 at 08:40
  • may i know your `gradle-wrapper` version ? mine `..gradle-2.14.1-all.zip` – IntelliJ Amiya Dec 19 '16 at 08:51
  • http://stackoverflow.com/questions/30518750/android-studio-execution-failed-for-task-appcompiledebugaidl-failed – IntelliJ Amiya Dec 19 '16 at 08:53
  • 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. – Fedor Losev Dec 19 '16 at 09:26
  • @IntelliJAmiya i've already read this post, FedorLosev I've edit main post – Michele Lacorte Dec 19 '16 at 13:04
  • It is hard to say without seeing your project layout and IRemoteShortcutService.aidl, but did you check that IRemoteShortcutService.aidl is indeed under `C:\Users\Michele\workspace\AndroidLib\library\src\` and it is a valid aidl file? If it is in another location, you need either to move aidl to /src or change the aidl.srcDirs = ['src'] entry in build.gradle. – Fedor Losev Dec 21 '16 at 12:05

4 Answers4

7

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.

Fedor Losev
  • 3,244
  • 15
  • 13
  • 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? – Fedor Losev Dec 21 '16 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? – Fedor Losev Dec 22 '16 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. – Fedor Losev Dec 22 '16 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. – Fedor Losev Dec 22 '16 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... – Michele Lacorte Dec 22 '16 at 13:57
  • Well, if you can't find the time to prepare a project zip with minimal failing sample, probably I can't help more here. If the problem is in build environment you can try to install it from scratch e.g. with recent studio. But before trying random guesses it makes sense to check if you didn't overlook something in the sources on an environment which compiles aidl just fine and which I have. – Fedor Losev Dec 22 '16 at 14:02
  • And if the path in error `\AndroidLib\library\src\main\aidl` then you don't have aidl files under package folders as needed. – Fedor Losev Dec 22 '16 at 14:04
  • I've create a new empty project and it make same error...I can post zip... – Michele Lacorte Dec 22 '16 at 14:06
  • If you can post a zip at least we can know if it works on my environment. If it works you would know to reinstall or check the environment. If I get the same error it would be easier to see what causes it may be some option in project etc. – Fedor Losev Dec 22 '16 at 14:09
  • For me the build fails. Running manually the same command as in the failed build fails with pretty self-explanatory message: `Invalid package declaration 'it.michelelacorte.testaidl'`. First you need to move aidl file into the correct package folder `src/mian/aidl/it/michelelacorte/testaidl`, as I mentioned in the answer. After moving I get `gradlew assemble` - > `BUILD SUCCESSFUL`. Do you still get the error after moving to the correct package? If so upload the updated project. – Fedor Losev Dec 22 '16 at 15:18
  • ok I've found issue! There were classes of inclusions giving trouble, I tried with a AIDL class with a void method and it works, Thanks – Michele Lacorte Dec 23 '16 at 11:23
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.

crgarridos
  • 8,758
  • 3
  • 49
  • 61
2

please add

import it.michelelacorte.androidshortcuts.Shortcuts;

in IRemoteShortcutService.aidl file.

kingfeng
  • 149
  • 1
  • 4
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.

Unamata Sanatarai
  • 6,475
  • 3
  • 29
  • 51
lulu
  • 1
  • 1