在Maven项目如何使用谷歌播放服务?如何使用、项目、Maven

2023-09-13 00:40:33 作者:云中寄锦书

有人可以给我一步一步的教程约我怎么能在一个Maven项目中使用谷歌播放服务? 我已经添加了两个依赖

Somebody can give me a step by step tutorial about how can I use google play services in a maven project? I've added two dependencies

<dependency>
    <groupId>com.google.android.gms</groupId>
    <artifactId>google-play-services</artifactId>
    <version>4</version>
    <type>apklib</type>
</dependency>

<dependency>
    <groupId>com.google.android.gms</groupId>
    <artifactId>google-play-services</artifactId>
    <version>4</version>
    <type>jar</type>
</dependency> 

在apklib和jar出现在Maven仓库,但不会产生com.google.android.gms.R类。

The apklib and jar appears in maven repository but the com.google.android.gms.R class is not generated.

我收到的NoClassDefFoundError。我怎样才能把com.google.android.gms在根文件夹?

I recieve NoClassDefFoundError. How can i put the com.google.android.gms in the gen folder?

推荐答案

您可以使用的Andr​​oid SDK Maven的部署的不仅仅是谷歌播放服务

You can use the Android Maven SDK Deployer for more than just Google Play Services

顺便说一句,你应该使用13.0.0版本,而不是4

Btw you should use version 13.0.0 and not 4

<dependency>
  <groupId>com.google.android.gms</groupId>
  <artifactId>google-play-services</artifactId>
  <version>13.0.0</version>
  <type>apklib</type>
</dependency>

<dependency>
  <groupId>com.google.android.gms</groupId>
  <artifactId>google-play-services</artifactId>
  <version>13.0.0</version>
</dependency>

。AAR与Android,Maven的插件3.8.2 +

使用Android的Maven的插件3.8.2,您还可以使用播放服务AAR

".aar" with android-maven-plugin 3.8.2+

With android-maven-plugin 3.8.2 you can also use the play services aar

<dependency>
  <groupId>com.google.android.gms</groupId>
  <artifactId>play-services</artifactId>
  <version>4.0.30</version>
  <type>aar</type>
</dependency>