gpt4 book ai didi

android - 我们可以在aidl中声明一个原始类型的变量吗

转载 作者:搜寻专家 更新时间:2023-11-01 08:23:39 26 4
gpt4 key购买 nike

我有一个疑问。我们可以在 aidl 文件中声明一个常量变量吗?例如,我有一个名为 ITest.aidl 的 aidl 文件:

package com.example.test;    
interface ITest {
public static final String name = "abc";
public static final int number = 1234;
}

当我尝试我的测试应用程序时,它给出了语法错误和运行时异常

Error:(4) syntax error
Error:(4) syntax error before ';' (expected method or constant declaration)
Error:(5) syntax error
Error:Execution failed for task ':app:compileDebugAidl'.
java.lang.RuntimeException: com.android.ide.common.process.ProcessException: Error while executing 'D:\Android\sdk\build-tools\25.0.2\aidl.exe' with arguments {-pD:\Android\sdk\platforms\android-25\framework.aidl -oE:\Workspace-Production\MyTestingApplication\app\build\generated\source\aidl\debug -IE:\Workspace-Production\MyTestingApplication\app\src\main\aidl -IE:\Workspace-Production\MyTestingApplication\app\src\debug\aidl -IE:\Workspace-Production\MyTestingApplication\app\build\intermediates\exploded-aar\com.android.support\appcompat-v7\25.1.1\aidl -IE:\Workspace-Production\MyTestingApplication\app\build\intermediates\exploded-aar\com.android.support\support-v4\25.1.1\aidl -IE:\Workspace-Production\MyTestingApplication\app\build\intermediates\exploded-aar\com.android.support\support-fragment\25.1.1\aidl -IE:\Workspace-Production\MyTestingApplication\app\build\intermediates\exploded-aar\com.android.support\support-media-compat\25.1.1\aidl -IE:\Workspace-Production\MyTestingApplication\app\build\intermediates\exploded-aar\com.android.support\support-core-ui\25.1.1\aidl -IE:\Workspace-Production\MyTestingApplication\app\build\intermediates\exploded-aar\com.android.support\support-core-utils\25.1.1\aidl -IE:\Workspace-Production\MyTestingApplication\app\build\intermediates\exploded-aar\com.android.support\animated-vector-drawable\25.1.1\aidl -IE:\Workspace-Production\MyTestingApplication\app\build\intermediates\exploded-aar\com.android.support\support-vector-drawable\25.1.1\aidl -IE:\Workspace-Production\MyTestingApplication\app\build\intermediates\exploded-aar\com.android.support\support-compat\25.1.1\aidl -dC:\Users\20065920\AppData\Local\Temp\aidl2875180729857776911.d E:\Workspace-Production\MyTestingApplication\app\src\main\aidl\ITest.aidl

请给我一些链接,为什么它会这样?

最佳答案

AIDL 支持方法和常量声明。

您必须更新 aidl 接口(interface)上的常量声明,

package com.example.test;    
interface ITest {
public static final String name = "abc";
public static final int number = 1234;
}

到,

package com.example.test;    
interface ITest {
const String NAME = "abc";
const int NUMBER= 1234;
}

String and int constants can be defined in the AIDL interface. For example: const int VERSION = 1;

引用: Create the .aidl file

关于android - 我们可以在aidl中声明一个原始类型的变量吗,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47549524/

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