Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can not build android project using Maven-Android-Plugin

I was just trying to build my android project using Maven-Android-Plugin. But it's giving following error:

F:\Android\AsyncTaskSample>mvn clean install
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building AsyncTaskSample 1.0
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.4.1:clean (default-clean) @ asynctasksample ---
[INFO] Deleting F:\Android\AsyncTaskSample\target
[INFO]
[INFO] --- android-maven-plugin:3.5.0:generate-sources (default-generate-sources) @ asynctasksample ---
[INFO] ANDROID-904-002: Found aidl files: Count = 0
[INFO] ANDROID-904-002: Found aidl files: Count = 0
[INFO] Manifest merging disabled. Using project manifest only
[INFO] E:\Nitin\Android-SDK\Android\android-sdk\platform-tools\aapt.exe [package, -m, -J, F:\Android\AsyncTaskSample\target\generated-sources\r, -M, F:\Android\AsyncTaskSample\AndroidManifest.xml, -S, F:\Android\AsyncTaskSample\res, --auto-add-overlay, -A, F:\Android\AsyncTaskSample\assets, -I, E:\Nitin\Android-SDK\Android\android-sdk\platforms\android-4\android.jar]
[INFO] F:\Android\AsyncTaskSample\res\values-v11\styles.xml:3: error: Error retrieving parent for item: No resource found that matches the given name 'android:Theme.Holo.Light'.
[ERROR] Error when generating sources.
org.apache.maven.plugin.MojoExecutionException:
        at com.jayway.maven.plugins.android.phase01generatesources.GenerateSourcesMojo.generateR(GenerateSourcesMojo.java:468)
        at com.jayway.maven.plugins.android.phase01generatesources.GenerateSourcesMojo.execute(GenerateSourcesMojo.java:193)
        at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
        at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
        at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
        at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
        at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
Caused by: com.jayway.maven.plugins.android.ExecutionException: ANDROID-040-001: Could not execute: Command = cmd.exe /X /C "E:\Nitin\Android-SDK\Android\android-sdk\platform-tools\aapt.exe package -m -J F:\Android\AsyncTaskSample\target\generated-sources\r -M F:\Android\AsyncTaskSample\AndroidManifest.xml -S F:\Android\AsyncTaskSample\res --auto-add-overlay -A F:\Android\AsyncTaskSample\assets -I E:\Nitin\Android-SDK\Android\android-sdk\platforms\android-4\android.jar", Result = 1
        at com.jayway.maven.plugins.android.CommandExecutor$Factory$1.executeCommand(CommandExecutor.java:339)
        at com.jayway.maven.plugins.android.phase01generatesources.GenerateSourcesMojo.generateR(GenerateSourcesMojo.java:464)
        ... 22 more
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.427s
[INFO] Finished at: Wed Jan 09 16:58:50 IST 2013
[INFO] Final Memory: 6M/15M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.jayway.maven.plugins.android.generation2:android-maven-plugin:3.5.0:generate-sources (default-generate-sources) on project asynctasksample: MojoExecutionException: ANDROID-040-001: Could not execute: Command = cmd.exe /X /C "E:\Nitin\Android-SDK\Android\android-sdk\platform-tools\aapt.exe package -m -J F:\Android\AsyncTaskSample\target\generated-sources\r -M F:\Android\AsyncTaskSample\AndroidManifest.xml -S F:\Android\AsyncTaskSample\res --auto-add-overlay -A F:\Android\AsyncTaskSample\assets -I E:\Nitin\Android-SDK\Android\android-sdk\platforms\android-4\and
roid.jar", Result = 1 -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
F:\Android\AsyncTaskSample>

The pom.xml content 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.example</groupId>
    <artifactId>asynctasksample</artifactId>
    <version>1.0</version>
    <packaging>apk</packaging>
    <name>AsyncTaskSample</name>

    <dependencies>
        <dependency>
            <groupId>com.google.android</groupId>
            <artifactId>android</artifactId>
            <version>1.6_r2</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>
    <build>
        <finalName>${project.artifactId}</finalName>
        <sourceDirectory>src</sourceDirectory>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>com.jayway.maven.plugins.android.generation2</groupId>
                    <artifactId>android-maven-plugin</artifactId>
                    <version>3.5.0</version>

                    <extensions>true</extensions>
                </plugin>
            </plugins>
        </pluginManagement>
        <plugins>
            <plugin>
                <groupId>com.jayway.maven.plugins.android.generation2</groupId>
                <artifactId>android-maven-plugin</artifactId>
                <configuration>
                    <sdk>
                        <!-- platform or api level (api level 4 = platform 1.6)-->
                        <platform>4</platform>
                    </sdk>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

The settings.xml file contents @ "C:\Users\rsahu.m2" is as follows:

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
            http://maven.apache.org/xsd/settings-1.0.0.xsd">
        <pluginGroups>
            <pluginGroup>com.jayway.maven.plugins.android.generation2</pluginGroup>
        </pluginGroups>
        <profiles>
            <profile>
                <id>android</id>
                <properties>
                    <android.sdk.path>
                        E:\Nitin\Android-SDK\Android\android-sdk
                    </android.sdk.path>
                </properties>
            </profile>
        </profiles>
        <activeProfiles>
            <!--make the profile active all the time -->
            <activeProfile>android</activeProfile>
        </activeProfiles>
    </settings>

By looking into above file contents, is it possible to resolve the issue!!! Please let me know. Thanks.

like image 696
Rajeev Sahu Avatar asked Dec 05 '25 14:12

Rajeev Sahu


1 Answers

I noticed this error in the Maven output

No resource found that matches the given name 'android:Theme.Holo.Light'

And also that you are specifying the target Android OS as 1.6 in your pom.xml

<dependency>
    <groupId>com.google.android</groupId>
    <artifactId>android</artifactId>
    <version>1.6_r2</version>
    <scope>provided</scope>
</dependency>

You need to either change the theme to something like android:Theme.Light

or change the target Android version in the dependency to something higher. Holo only became available in Android 4.0 (level 16)

like image 167
jim Avatar answered Dec 07 '25 02:12

jim



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!