Maven compilation error caused by Android environment methods

I’m quite new to Maven so apologies upfront. I’m attempting to build my application which I had previously written and built in Eclipse with no issues. I’ve attempted to convert the project to Maven structure and create a pom.xml file bu when I try to build the project I get Compilation Errors on all of the environment methods I have used. The output from attempting to build is as follows:

[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /C:/Users/*me*/workspace/*app*-Final/src/main/java/com/*org*/android/
*app*/SystemTests.java:[124,35] cannot find symbol
symbol:   method getStorageState(java.io.File)
location: class android.os.Environment
[ERROR] /C:/Users/*me*/workspace/*app*-Final/src/main/java/com/*org*/android/
*app*/SystemTests.java:[135,30] cannot find symbol
symbol:   method getBlockSizeLong()
location: variable stat of type android.os.StatFs
[ERROR] /C:/Users/*me*/workspace/*app*-Final/src/main/java/com/*org*/android/
*app*/SystemTests.java:[136,32] cannot find symbol
symbol:   method getBlockCountLong()
location: variable stat of type android.os.StatFs
[ERROR] /C:/Users/*me*/workspace/*app*-Final/src/main/java/com/*org*/android/
*app*/SystemTests.java:[190,34] cannot find symbol
symbol:   method getBlockSizeLong()
location: variable stat of type android.os.StatFs
[ERROR] /C:/Users/*me*/workspace/*app*-Final/src/main/java/com/*org*/android/
*app*/SystemTests.java:[191,36] cannot find symbol
symbol:   method getBlockCountLong()
location: variable stat of type android.os.StatFs
[INFO] 5 errors

and my pom.xml file is as follows:

<?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.*org*.android</groupId>
<artifactId>*app*</artifactId>
<version>1.0.0</version>
<packaging>apk</packaging>

<name>*app name*</name>
<properties>
    <!-- at test time this will be overridden with snapshot version -->
    <it-plugin.version>4.3.0</it-plugin.version>
</properties>

<dependencies>
    <dependency>
    <groupId>com.google.android</groupId>
        <artifactId>android</artifactId>
        <version>4.1.1.4</version>
        <scope>provided</scope>
    </dependency>
</dependencies>
<build>
    <pluginManagement>
        <plugins>
            <plugin>
                <groupId>com.simpligility.maven.plugins</groupId>
                <artifactId>android-maven-plugin</artifactId>
                <version>${it-plugin.version}</version>
                <extensions>true</extensions>
            </plugin>
            <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.1</version>
            <configuration>
                <source>1.7</source>
                <target>1.7</target>
            </configuration>
        </plugin>
        </plugins>
    </pluginManagement>
    <plugins>
        <plugin>
            <groupId>com.simpligility.maven.plugins</groupId>
            <artifactId>android-maven-plugin</artifactId>
            <configuration>
                <sdk>
                    <platform>19</platform>
                </sdk>
            </configuration>
        </plugin>               
    </plugins>
</build>
</project>

Finally the output from mvn --version is:

Apache Maven 3.3.3 (7994120775791599e205a5524ec3e0dfe41d4a06;  2015-04-22T12:57:3
7+01:00)
Maven home: C:Program FilesApachemaven
Java version: 1.8.0_51, vendor: Oracle Corporation
Java home: C:Program FilesJavajdk1.8.0_51jre
Default locale: en_GB, platform encoding: Cp1252
OS name: "windows 7", version: "6.1", arch: "amd64", family: "dos"

Thanks in advance!


Source: eclipse

Leave a Reply