我正在做一个小项目以允许 cookie 持久存在。我想将该项目制作为 JAR,以便其他开发人员可以在该项目中使用它。目前我可以将项目构建为 APKLIB,但这似乎没有必要,因为不需要资源。如果我将包装更改为 JAR,我会在构建时收到以下错误
结果 :
测试错误:
shouldAddCookie(com.doward.persistantcookietest.PersistantCookieStoreTest): java.lang.ClassNotFoundException: 在获取 com.doward.persistantcookies.R 的类文件时捕获异常
shouldClearAllCookies(com.doward.persistantcookietest.PersistantCookieStoreTest): java. lang.ClassNotFoundException:在获取 com.doward.persistantcookies.R 的类文件时
捕获异常。持久cookies.R
POM 看起来像这样
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.doward</groupId>
<artifactId>persistantcookiestore</artifactId>
<version>1</version>
<packaging>jar</packaging>
<name>persistantcookies</name>
<dependencies>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20090211</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.pivotallabs</groupId>
<artifactId>robolectric</artifactId>
<version>1.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>android</groupId>
<artifactId>android</artifactId>
<version>4.2.2_r2</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<version>3.3.2</version>
<configuration>
<androidManifestFile>${project.basedir}/AndroidManifest.xml</androidManifestFile>
<sdk>
<platform>17</platform>
</sdk>
<undeployBeforeDeploy>true</undeployBeforeDeploy>
</configuration>
<extensions>true</extensions>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</build>
</project>