我将我的Android项目转换为Maven项目。我有一个名为appcompat_v7的支持库,我想将其添加到我的Maven依赖项中。
我读到我应该将依赖项添加到pom.xml
<dependency>
<groupId>android.support</groupId>
<artifactId>compatibility-v7-appcompat</artifactId>
<version>19.1.0</version>
<type>apklib</type>
</dependency>
<dependency>
<groupId>android.support</groupId>
<artifactId>compatibility-v7-appcompat</artifactId>
<version>19.1.0</version>
<type>jar</type>
</dependency>
还通过运行来构建jar和apklib:
mvn install:install-file -Dfile="./com/android/support/appcompat-v7/19.1.0/appcompat-v7-19.1.0.aar"/ -DpomFile="./com/android/support/appcompat-v7/19.1.0/appcompat-v7-19.1.0.pom"/ -Dpackaging="apklib"
mvn install:install-file -Dfile="./com/android/support/appcompat-v7/19.1.0/appcompat-v7-19.1.0.jar"/ -DpomFile="./com/android/support/appcompat-v7/19.1.0/appcompat-v7-19.1.0.pom"/ -Dpackaging="jar"
我的pom.xml现在如下:
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>ProjectTest</groupId>
<artifactId>ProjectTest</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependency>
<groupId>com.android.support</groupId>
<artifactId>appcompat-v7</artifactId>
<version>19.1.0</version>
<type>apklib</type>
</dependency>
<dependency>
<groupId>com.android.support</groupId>
<artifactId>appcompat-v7</artifactId>
<version>19.1.0</version>
<type>jar</type>
</dependency>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source/>
<target/>
</configuration>
</plugin>
</plugins>
</build>
</project>
在删除支持libraby appcompat_v7后,我仍然有错误''R无法解析为变量'