我们正在尝试使用com.google.android.gms:play-services-location,但无法构建我们的项目。问题似乎是maven尝试下载JAR,而此工件以AAR文件的形式存在。这是我们的pom.xml
<dependency>
<groupId>com.google.android.gms</groupId>
<artifactId>play-services-location</artifactId>
<version>17.0.0</version>
</dependency>
...
<repositories>
<repository>
<id>google-local-repo</id>
<name>Google Maven Repo</name>
<url>file:///Users/sjain68/Library/Android/sdk/extras/google/m2repository</url>
</repository>
<repository>
<id>google-remote-repo</id>
<name>Google Maven Repo</name>
<url>https://maven.google.com</url>
</repository>
</repositories>
无论我们怎么努力,都会遇到此错误:
[ERROR] Failed to execute goal on project android: Could not resolve dependencies for project com.google.zxing:android:apk:4.7.10: Failure to find com.google.android.gms:play-services-location:jar:17.0.0 in https://maven.google.com was cached in the local repository, resolution will not be reattempted until the update interval of google-remote-repo has elapsed or updates are forced -> [Help 1]
,这是事实。 JAR不存在。它是一个AAR文件。我们如何告诉Maven寻找AAR文件而不是JAR文件?
$ wget https://maven.google.com/com/google/android/gms/play-services-location/17.0.0/play-services-location-17.0.0.aar
--2019-06-27 13:19:49-- https://maven.google.com/com/google/android/gms/play-services-location/17.0.0/play-services-location-17.0.0.aar
Resolving maven.google.com (maven.google.com)... 172.217.3.195
Connecting to maven.google.com (maven.google.com)|172.217.3.195|:443... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: https://dl.google.com/dl/android/maven2/com/google/android/gms/play-services-location/17.0.0/play-services-location-17.0.0.aar [following]
--2019-06-27 13:19:50-- https://dl.google.com/dl/android/maven2/com/google/android/gms/play-services-location/17.0.0/play-services-location-17.0.0.aar
Resolving dl.google.com (dl.google.com)... 216.58.193.78
Connecting to dl.google.com (dl.google.com)|216.58.193.78|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 128878 (126K) [application/octet-stream]
Saving to: ‘play-services-location-17.0.0.aar’
play-services-location-17.0.0.aar 100%[==========================================================>] 125.86K --.-KB/s in 0.03s
2019-06-27 13:19:50 (4.81 MB/s) - ‘play-services-location-17.0.0.aar’ saved [128878/128878]
答案 0 :(得分:0)
使用<type>aar</type>
使它工作:
<dependency>
<groupId>com.google.android.gms</groupId>
<artifactId>play-services-location</artifactId>
<version>17.0.0</version>
<type>aar</type>
</dependency>