gpt4 book ai didi

java - 编译 AIDL 时出错

转载 作者:搜寻专家 更新时间:2023-10-30 21:27:21 25 4
gpt4 key购买 nike

我正在尝试编译 .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
}

我读过关于构建工具的问题,但我没有找到任何关于 API 25 的信息

编辑:

我用参数启动了 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 文件夹

最佳答案

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

可能存在 gradle 未显示的来自 aidl.exe 的解释性错误代码或消息。

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

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

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

build.gradle:

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

(尽管,一般来说,如果文件在 /src/main/aidl 中,它应该在没有 aidl.srcDirs 条目的情况下工作)

不要忘记 aidl 文件应该在包文件夹下,例如 java.lang.例如,如果包是 it.michelelacorte.testaidl,则 aidl 文件应该位于 src/main/aidl/it/michelelacorte/testaidl 下。

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

关于java - 编译 AIDL 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41110128/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com