I want to use this android dependency in my java program:
http://jcenter.bintray.com/com/o3dr/android/dronekit-android/2.9.0/
so I added all the plugins & repositories into my maven pom file:
<repositories>
<repository>
<id>central</id>
<name>bintray</name>
<url>http://jcenter.bintray.com</url>
<!--<snapshots>-->
<!--<enabled>false</enabled>-->
<!--</snapshots>-->
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<!--<snapshots>-->
<!--<enabled>false</enabled>-->
<!--</snapshots>-->
<id>central</id>
<name>bintray-plugins</name>
<url>http://jcenter.bintray.com</url>
</pluginRepository>
</pluginRepositories>
<build>
<plugins>
<plugin>
<groupId>com.simpligility.maven.plugins</groupId>
<artifactId>android-maven-plugin</artifactId>
<version>4.1.0</version>
<extensions>true</extensions>
<configuration>
<sign>
<debug>false</debug>
</sign>
</configuration>
</plugin>
...
Then I add the dependency into the same file:
<dependency>
<groupId>com.o3dr.android</groupId>
<artifactId>dronekit-android</artifactId>
<version>2.9.0</version>
<type>aar</type>
</dependency>
But nothing happens, maven ignore it as if it doesn't exist, if I import its main package in a scala file and build it with mvn clear install -U
, I get this error:
[ERROR] /home/peng/git-drone/dronespike/src/main/scala/Main.scala:1: object o3dr is not a member of package com
[ERROR] import com.o3dr.android._
[ERROR] ^
Question: What should I do to fix this problem?
If you run Maven and it fails to download your required dependencies it's likely to be caused by your local firewall & HTTP proxy configurations. See the Maven documentation for details of how to configure the HTTP proxy.
We can use -U/--update-snapshots flag when building a maven project to force maven to download dependencies from the remote repository. Here, -U,--update-snapshots : Forces a check for missing releases and updated snapshots on remote repositories.
Navigate to your module project's generated build folder (e.g., /target ). You'll notice there is a newly generated JAR file. This is the artifact you'll deploy to your Nexus repository. Run Maven's deploy command to deploy your module project's artifact to your configured remote repository.
Use Android packaging, e.g. <packaging>apk</packaging>
.
If Maven couldn't download the artifact, it would complain much sooner in the build lifecycle. The problem is that artifact is downloaded, but not used. aar
is not a standard Maven artifact, so Maven doesn't know what to do with it. Using it requires a third party plugin with extensions, hence usage of android-maven-plugin
. Reading its documentation, it has some requirements to work properly. Specifically you didn't use android packaging as mentioned here:
usage of a supported packaging: apk, aar or apklib
Indeed, looking at the plugin source code it checks for android packaging before adding anything from aar
to classpath.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With