use*_*225 11 android jar maven android-library apklib
我已经下载了第三方Android库项目,该项目不包含java类文件,而是包含文件夹下的jar文件libs/
:
libs/
- CustomService.jar
res/
-…
pom.xml
Run Code Online (Sandbox Code Playgroud)
这个库项目可以构建为apklib存档.我构建了它并且我已将此存档安装到我的本地maven存储库中.
然后在我自己的Android项目中,我添加了这个apklib项目的依赖项:
<dependency>
<groupId>com.custom.service</groupId>
<artifactId>custom-service</artifactId>
<type>apklib</type>
<version>1.0</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
在我的Java代码中,我使用了CustomService.jar中的类,但是当我maven构建我的项目时,我经常遇到以下错误:
[ERROR] package com.custom.service.user does not exist
[ERROR] location: class com.my.app.MyClass
[ERROR] /Users/Johon/MyApp/src/main/java/com/my/app/MyClass.java:[34,17] cannot find symbol
[ERROR] symbol: variable UserService
Run Code Online (Sandbox Code Playgroud)
上面的错误抱怨它无法UserService
从库apklib存档中找到该类.然后,我通过命令检查了库jar文件的内容:
jar tf CustomService.jar
我看到该类位于库项目的CustomService.jar中
com/custom/service/user/UserService.class
Run Code Online (Sandbox Code Playgroud)
这个类在jar中,为什么我得到错误然后????
小智 0
尝试添加范围:
<dependency>
<groupId>com.custom.service</groupId>
<artifactId>custom-service</artifactId>
<type>apklib</type>
<version>1.0</version>
<scope>compile</scope>
</dependency>
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
905 次 |
最近记录: |