Android的工作室与谷歌播放服务工作室、Android

2023-09-12 21:31:44 作者:暖心萌菇凉

我想测试谷歌播放服务与全新的Andr​​oid工作室。 我有一个依赖于google_play_services.jar项目。 但是,当我试图重建项目中,我得到了以下错误:

I'm trying to test Google Play Services with the new Android Studio. I have a project with a dependency to the google_play_services.jar. But when I try to Rebuild the project I get the following errors:

Information:[TstGP3-TstGP3] Crunching PNG Files in source dir: C:\Users\ans\AndroidStudioProjects\TstGP3\TstGP3\src\main\res
Information:[TstGP3-TstGP3] To destination dir: C:\Users\ans\AndroidStudioProjects\TstGP3\build\classes\res-cache\TstGP3-TstGP3
Information:Compilation completed with 2 errors and 0 warnings in 2 sec
Information:2 errors
Information:0 warnings
C:\Users\ans\.AndroidStudioPreview\system\compiler\tstgp3.3f17bd41\.generated\Android_BuildConfig_Generator\TstGP3-TstGP3.74fc5b25\production\com\example\tstgp3\BuildConfig.java
    Error:Error:line (4)error: duplicate class: com.example.tstgp3.BuildConfig
C:\Users\ans\.AndroidStudioPreview\system\compiler\tstgp3.3f17bd41\.generated\aapt\TstGP3-TstGP3.74fc5b25\production\com\example\tstgp3\R.java
    Error:Error:line (10)error: duplicate class: com.example.tstgp3.R

似乎它有两个BuildConfig文件,也两个R类。我怎样才能解决这个问题?

It seems that it has two BuildConfig files and also two R classes. How can I resolve the issue?

编辑:

我已经注意到,编译器编译2 R.java文件:一个是在我的项目文件夹中,另外一个是位于文件夹%USERPROFILE%.AndroidStudio preVIEW 所以,我试图排除在编译器设置这个preVIEW文件夹,现在它的工作。 这个问题只有我开始后继续使用谷歌播放服务类在我的项目出现。 我将AP preciate如果有人可以解释这背后的问题的原因。

I have noticed that the compiler compiles two R.java files: the one that is in my project folder and another one that is located in the folder %USERPROFILE%.AndroidStudioPreview So, I tried to exclude this "Preview" folder in the compiler settings and now it's working. This issue only occurs after I have started to use Google Play Services classes in my project. I will appreciate if someone can explain the reason behind this problem.

推荐答案

所有这些答案都是错的,因为摇篮插件v0.4.2发布的Andr​​oid下的谷歌工作室的建立发挥服务是直线前进。你并不需要输入任何JAR或添加任何项目库,也没有在Android的工作室添加任何新的模块。什么,你需要做的就是添加正确的依赖关系到build.gradle文件。请看看这些链接:摇篮插件v0.4.2更新,的