4

I am getting package R does not exist on building pom.xml file.

Compilation Error is:

[INFO] Compiling 12 source files to E:\My_Work6\AtosListReq\target\classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] E:\My_Work6\MyListReq\src\com\as\dragsortandswipe\DragSortListView.java:[32,23] error: cannot find symbol
[ERROR]   symbol:   class R
  location: package com.as.listreq
E:\My_Work6\MyListReq\src\com\as\dragsortandswipe\DragSortController.java:[17,23] error: cannot find symbol
[ERROR]   symbol:   class R
  location: package com.as.listreq
E:\My_Work6\MyListReq\src\com\as\dragsortandswipe\DragSortListView.java:[406,6] error: package R does not exist
[ERROR] E:\My_Work6\MyListReq\src\com\as\dragsortandswipe\DragSortListView.java:[409,6] error: package R does not exist
[ERROR] E:\My_Work6\MyListReq\src\com\as\dragsortandswipe\DragSortListView.java:[412,6] error: package R does not exist
[ERROR] E:\My_Work6\MyListReq\src\com\as\dragsortandswipe\DragSortListView.java:[419,29] error: package R does not exist
[ERROR] E:\My_Work6\MyListReq\src\com\as\listreq\NextActivity.java:[41,40] error: package R does not exist
[ERROR] E:\My_Work6\MyListReq\src\com\as\listreq\NextActivity.java:[42,43] error: package R does not exist
.
.
.
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project MyListReq: Compilation failure: Compilation failure:
[INFO] 58 errors

Below is my pom.xml file:

    <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>MyListReq</groupId>
    <artifactId>MyListReq</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>MyList</name>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    </properties>


    <dependencies>
        <dependency>
            <groupId>com.google.android</groupId>
            <artifactId>android</artifactId>
            <version>4.1.1.4</version>
            <scope>compile</scope>
        </dependency>


        <dependency>
            <groupId>com.google.android</groupId>
            <artifactId>support-v4</artifactId>
            <version>r7</version>
        </dependency>
    </dependencies>
    <build>
        <sourceDirectory>src</sourceDirectory>
        <plugins>

            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                    <fork>true</fork>
                    <executable>C:\Program Files\Java\jdk1.7.0_03\bin\javac.exe
                    </executable>
                </configuration>
            </plugin>

            <plugin>
                <groupId>com.jayway.maven.plugins.android.generation2</groupId>
                <artifactId>android-maven-plugin</artifactId>
                <configuration>
                    <sdk>
                        <path>${env.ANDROID_HOME}</path>
                        <platform>17</platform>
                    </sdk>
                </configuration>
                <extensions>true</extensions>
            </plugin>

        </plugins>
    </build>
</project>
Lucifer
  • 29,392
  • 25
  • 90
  • 143
Amrit Pal Singh
  • 7,116
  • 7
  • 40
  • 50
  • Did you also try http://stackoverflow.com/questions/19496939/maven-compilation-error-for-android-project-error-package-r-does-not-exist and http://stackoverflow.com/questions/13128169/r-java-will-not-be-generated-android-maven-plugin? It looks like that is a generated class – andyb Jan 10 '14 at 11:28
  • ya looked into that too..but didn't sort out my problem. – Amrit Pal Singh Jan 10 '14 at 11:35
  • It looks like that file is generated by a Maven Android plugin but the Maven compile phase is not seeing the generated file since it is in a non-standard Maven source directory location - see http://stackoverflow.com/questions/12771526/unable-to-build-android-project-with-maven-android-maven-plugin – andyb Jan 10 '14 at 11:37
  • yes the file is generated by Maven Android plugin, I have checked the link provided by you but the answers given their seems not working in my case. – Amrit Pal Singh Jan 10 '14 at 11:47
  • Try adding the `build` directory where the `R.class` exists as a resource in `pom.xml` - see http://stackoverflow.com/a/19974322/637889 – andyb Jan 10 '14 at 13:04

1 Answers1

1

You have added com.jayway.maven.plugins.android.generation2 plugin,

Adding packaging to apklib, like this:

<version>0.0.1-SNAPSHOT</version>
<packaging>apklib</packaging>

That's ok

Trinea
  • 649
  • 8
  • 10