How to add thirdparty jar to android maven project?

99 Views Asked by At

I have already searched stackoverflow for this issue and did not get solution.

I have one Android Maven project my-app to which I want to add one thirdparty lib jar. I created dependency tag in pom file of android project as below

    <dependency>
       <groupId>com.lib</groupId>
       <artifactId>javalib</artifactId>
       <version>1.0</version>
       <scope>compile</scope>
       <type>jar</type>
    </dependency>

and then installed that jar in maven as below

     mvn install:install-file -Dfile=libs/com/lib/javalib/1.0/javaimfusion.jar -DgroupId=com.lib -DartifactId=javalib -Dversion=1.0 -Dpackaging=jar

This was it installed lib without any errors. But when I try to install/deploy android app which has references to lib code then it show error

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project my-app: Compilation failure

[ERROR] /xxx/yyy/tmp/my-app/src/main/java/com/zzz/app/HelloAndroidActivity.java:[7,36] package com.lib does not exist

How do I fix this?

1

There are 1 best solutions below

0
On

Well... the contents of the jar file will tell you the correct import statement in your code and NOT the groupId. I suspect these are different in your case. Look at the jar and see what the package structure in there actually is and import that.