编译AIDL时出错

我试图编译.aidl并生成.java但是:

 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} 

我使用这个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' } 

而这个根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 } 

我已经阅读关于构build工具的问题,但是我没有发现有关API 25的任何信息

编辑:

我用params启动了aidl.exe ,并返回:

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

编辑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(); } 

这个.aidl位于src/main/aidl文件夹中

Solutions Collecting From Web of "编译AIDL时出错"

您是否尝试添加详细选项到gradle或者使用相同的参数手动执行相同的aidl.exe?

可能存在来自aidl.exe的说明性错误代码或消息,即gradle不显示。

根据错误aidl无法打开文件。 检查文件是否存在,内容是否有效。

尝试更改为新的默认布局:

将aidl文件放在/src/main/aidl

的build.gradle:

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

(但是,一般来说,如果文件在/src/main/aidl ,则应该在没有aidl.srcDirs条目的情况下运行)

不要忘记,aidl文件应该在像java这样的包文件夹下。 例如,如果包是it.michelelacorte.testaidl ,那么aidl文件应该在src/main/aidl/it/michelelacorte/testaidl

在最新版本的Android Studio中,如果项目包设置正确, New/AIDL/AIDL File项目菜单应该已经将文件放置在正确的文件夹下。

我有和你一样的版本。

我只是尝试编辑IRemoteShortcutService.aidl来导入Shortcut类。

虽然它们在同一个包中,但是它编译成功。

请加

 import it.michelelacorte.androidshortcuts.Shortcuts; 

IRemoteShortcutService.aidl文件中。