Waz*_*_Be 136 android gradle aidl android-studio android-gradle-plugin
我目前正在将Eclipse应用程序迁移到Android Studio.此应用正在使用应用内结算功能.
我的主要问题是编译项目和aidl文件(我想你们都使用这个文件)
我收到此错误消息:
Gradle: error: cannot find symbol class IInAppBillingService
Gradle: error: package IInAppBillingService does not exist
Run Code Online (Sandbox Code Playgroud)
因此,在一些教程之后,我将此文件从com.mypackage.billing移动到src/main/aidl(请参阅此参考)
但是,就像我那样,我收到这条消息:
Gradle:任务执行失败':xxxxxxxxxxx:compileDebugAidl'.
无法运行命令:(...)C:\ Users\xxxx\AndroidStudioProjects\xxxxxxProject\xxxxxxx\src\main\aidl\IInAppBillingService.aidl:45接口IInAppBillingService应在名为com\xxxxxxxx\billing\IInAppBillingService的文件中声明.aidl.
该消息显然与我上面链接的Google错误页面中的帖子相矛盾.
任何人都过分使这个aidl文件工作,可以帮助我吗?
请注意,我遵循的一些链接:
Kal*_*ade 219
添加这个作为答案,因为它似乎帮助了很多人.
注意:如果您的参考不起作用,请确保包含必要的导入
import com.android.vending.billing.IInAppBillingService;
Run Code Online (Sandbox Code Playgroud)
https://issuetracker.google.com/issues/36973270
从评论编辑
执行此操作后,我的代码中对IInAppBillingService的引用仍然突出显示为错误,但在重建应用程序后,该类已被识别
Sam*_*zor 161
正如错误消息所示,您需要放入IInAppBillingService.aidl
由其包(com.android.vending.billing)指定的正确目录.
在src/main/aidl/
您已有的文件夹中,将.aidl
文件放入com/android/vending/billing/
.
src/main
被叫下创建新目录aidl
aidl
,选择new->add package
输入包的名称 com.android.vending.billing
IInAppBillingService.aidl
从目录复制Android/Sdk/extras/google/play_billing
到目录App_name/app/src/main/aidl/com/android/vending/billing
can not resolve symbol IInAppBillingXXXXXX
Build
android studio菜单,点击Rebuild Project
.这将IInAppBillingService.java
在里面生成文件App_Name/app/build/generated/source/aidl/debug/com/android/vending/billing
.这将解决问题.在build.gradle中添加此代码
android {
sourceSets {
main {
aidl.srcDirs = ['src']
}
}
}
Run Code Online (Sandbox Code Playgroud)
重建和导入aidl类
此答案可能并不完全适合所发布的问题,但可能会帮助其他遇到与创建AIDL
文件夹相关问题的人。有时,即使我们创建类似 .AIDL 的文件夹,AIDL 文件夹也不会显示在 Android Studio 中app > New > Folder > AIDL Folder
。该文件夹存在于文件资源管理器中,但在 Android Studio 中未显示或检测到。
我遇到了这个问题,并使用以下步骤解决了它
步骤1:打开文件并在文件末尾
gradle.properties
添加 ,如屏幕截图所示。android.defaults.buildfeatures.aidl=true
步骤 2:右键单击该app
文件夹,将显示一个窗口,执行以下流程app > New > Folder > AIDL Folder
第 3 步:单击“完成”按钮
该
AIDL
文件夹现已创建并显示在 Android Studio 中
归档时间: |
|
查看次数: |
79104 次 |
最近记录: |