我目前正在将 Eclipse 应用程序迁移到 Android Studio。
此应用程序使用应用程序内计费。
我的主要问题是编译项目和aidl文件(我猜你们都使用这个文件)
我收到此错误消息:
Gradle: error: cannot find symbol class IInAppBillingService
Gradle: error: package IInAppBillingService does not exist
因此,根据一些教程,我将此文件从 com.mypackage.billing 移动到 src/main/aidl
(看这个参考)
但当我这样做时,我立即收到以下消息:
Gradle:任务“:xxxxxxxxxx:compileDebugAidl”执行失败。
无法运行命令:
(...) C:\Users\xxxx\AndroidStudioProjects\xxxxxxProject\xxxxxxx\src\main\aidl\IInAppBillingService.aidl:45
接口 IInAppBillingService 应在名为的文件中声明
com\xxxxxxxx\billing\IInAppBillingService.aidl。
该消息显然与我上面链接的 Google bug 页面上的帖子相矛盾。
有人成功使这个aidl文件正常工作并且可以帮助我吗?
![enter image description here](https://i.stack.imgur.com/daRec.png)
只是为了通知您,我点击了一些链接:
- http://tools.android.com/tech-docs/new-build-system/user-guide
- http://developer.android.com/guide/components/aidl.html
添加此作为答案,因为它似乎对很多人有帮助。
-
创建一个新目录在“src/main/”下命名为“aidl”。它应该看起来像'src/main/aidl'.
-
添加新包 name 'com.android.vending.billing'到目录'src/main/aidl'
- 找到您的 SDK 位置并转到“sdk\extras\google\play_billing”。 sdk 的默认位置是“C:\Program Files (x86)\Android\android-sdk”。如果您自定义更改了它,那么您将必须通过 sdk 管理器找出位置。
-
复制“IInAppBillingService.aidl”到上面创建的包中。最后,它应该类似于下图。
![Screenshot of result](https://i.stack.imgur.com/zbNrj.png)
-
Rebuild项目应该可以顺利进行。
注意:如果您的参考不起作用,请确保包含必要的导入
import com.android.vending.billing.IInAppBillingService;
https://issuetracker.google.com/issues/36973270
从评论编辑
执行此操作后,代码中对 IInAppBillingService 的引用仍然突出显示为错误,但在重建应用程序后,该类被识别
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)