编译AIDL时出错

Mic*_*rte 11 java android aidl android-studio build.gradle

我正在尝试编译.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}
Run Code Online (Sandbox Code Playgroud)

我用这个 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'
}
Run Code Online (Sandbox Code Playgroud)

而这根 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
}
Run Code Online (Sandbox Code Playgroud)

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

编辑:

aidl.exe用params 启动它返回:

aidl.exe E  2236 13884 aidl_language.cpp:224] Error while opening file for parsing: 'C:\Users\Michele\workspace\AndroidLib\library\src\IRemoteShortcutService.aidl'
Run Code Online (Sandbox Code Playgroud)

编辑2:

Shortcut.aidl

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

parcelable Shortcuts;
Run Code Online (Sandbox Code Playgroud)

IRemoteShortcutService.aidl

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

interface IRemoteShortcutService {

    void addShortcuts(int shortcutsImage, String shortcutsText);

    Shortcuts getShortcuts();
}
Run Code Online (Sandbox Code Playgroud)

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

Fed*_*sev 7

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

可能有一个解释性的错误代码或来自aidl.exe的消息,gradle没有显示.

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

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

把aidl文件放入 /src/main/aidl

的build.gradle:

...
    sourceSets {
        main {
            aidl.srcDirs = ['src/main/aidl']
        }
    }
Run Code Online (Sandbox Code Playgroud)

(但是,一般情况下,如果文件在/src/main/aidl其中,则应该在没有aidl.srcDirs条目的情况下工作)

不要忘记aidl文件应该在java之类的包文件夹下.例如,如果包是it.michelelacorte.testaidl,则aidl文件应该在src/main/aidl/it/michelelacorte/testaidl.

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


归档时间:

查看次数:

5658 次

最近记录:

8 年,3 月 前