Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
325 views
in Technique[技术] by (71.8m points)

android - How can I use google play services in a maven project?

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> 

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

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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

".apklib" with android-maven-plugin <3.8.1

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" 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>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...