Android Maven 采用第三方jar包,程序运行时报错的解决方案

转载请注明出处:http://xuantan.iteye.com/blog/1847485

Android工程中用到了一个第三方jar包,但此jar包在公司内部的maven仓库中不存在。

因此在POM文件中采用了如下配置方式:

<dependency>
	<groupId>com.baidu.android</groupId>
	<artifactId>pushservice</artifactId>
	<version>2.1.1</version>
	<scope>system</scope>
	<systemPath>${project.basedir}/libs/pushservice-2.1.1.jar</systemPath>
</dependency>

 然后利用mvn命令进行编译、打包,至此一切正常。

但是在程序运行时却报出了如下错误:

04-15 11:28:59.929: E/AndroidRuntime(6427): java.lang.NoClassDefFoundError: com.baidu.android.pushservice.PushManager

断定原因为:是这个第三方jar包没有打入到apk中,因此报了类找不到的错误

扫描二维码关注公众号,回复: 695323 查看本文章

解决方案为:

1、利用mvn命令将此第三方jar包上传到自己的maven本地仓库中:

mvn install:install-file -Dfile=libs\pushservice-2.1.1.jar -DgroupId=com.baidu.android -DartifactId=pushservice -Dversion=2.1.1 -Dpackaging=jar

 2、然后更改POM文件中的配置即可:

<dependency>
	<groupId>com.baidu.android</groupId>
	<artifactId>pushservice</artifactId>
	<version>2.1.1</version>
	<scope>compile</scope>
</dependency>

至此,问题解决。

转载请注明出处:http://xuantan.iteye.com/blog/1847485

猜你喜欢

转载自xuantan.iteye.com/blog/1847485