Search code examples
androidmavenintellij-ideaactionbarsherlock

Android: actionbarsherlock + maven + Intellij create apk


This is my project structure in intellij:

enter image description here

and this is my pom.xml:

<?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>P....</groupId>
    <artifactId>P...</artifactId>
    <version>1.0</version>
    <packaging>jar</packaging>
    <name>P...</name>

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

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

        <dependency>
            <groupId>com.actionbarsherlock</groupId>
            <artifactId>actionbarsherlock</artifactId>
            <version>4.4.0</version>
            <type>apklib</type>
        </dependency>

        <dependency>
            <groupId>net.lingala.zip4j</groupId>
            <artifactId>zip4j</artifactId>
            <version>1.3.1</version>
        </dependency>

        <dependency>
            <groupId>org.apache.jackrabbit</groupId>
            <artifactId>jackrabbit-webdav</artifactId>
            <version>2.5.2</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>com.jayway.maven.plugins.android.generation2</groupId>
                <artifactId>android-maven-plugin</artifactId>
                <version>3.8.0</version>
                <configuration>
                    <sdk>
                        <path>${env.ANDROID_HOME}</path>
                        <platform>16</platform>
                    </sdk>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

and this is what i run for create an apk from my project:

enter image description here

everything is ok when i run my program inside emulator using intellij but when i try to create an apk, this error is shown from maven:

[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building P... 1.0
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- android-maven-plugin:3.8.0:apk (default-cli) @ P.... ---
[INFO] Copying local assets files to combined assets directory.
[INFO] Enabling debug build for apk.
[INFO] C:\Users\...\android-sdk\build-tools\18.1.0\aapt.exe [package, -f, -M, D:\Projects\P....\AndroidManifest.xml, -S, D:\Projects\P....\res, --auto-add-overlay, -A, D:\Projects\P...\target\generated-sources\combined-assets\assets, -I, C:\Users\...\android-sdk\platforms\android-16\android.jar, -F, D:\Projects\P....\target\P....-1.0.ap_, --debug-mode]
[INFO] D:\Projects\P....\res\values\styles.xml:5: error: Error retrieving parent for item: No resource found that matches the given name 'Theme.Sherlock.Light.DarkActionBar'.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.118s
[INFO] Finished at: Sat Dec 14 11:23:35 IRST 2013
[INFO] Final Memory: 6M/13M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.jayway.maven.plugins.android.generation2:android-maven-plugin:3.8.0:apk (default-cli) on project P....: MojoExecutionException: ANDROID-040-001: Could not execute: Command = cmd.exe /X /C "C:\Users\...\android-sdk\build-tools\18.1.0\aapt.exe package -f -M D:\Projects\P...\AndroidManifest.xml -S D:\Projects\P....\res --auto-add-overlay -A D:\Projects\P...\target\generated-sources\combined-assets\assets -I C:\Users\...\android-sdk\platforms\android-16\android.jar -F D:\Projects\P....\target\P...-1.0.ap_ --debug-mode", 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

what is wrong in my settings???

Edit:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
          package="com.................."
          android:versionCode="1"
          android:versionName="1.0" >

    <uses-permission android:name="android.permission.GET_ACCOUNTS"/>
    <uses-permission android:name="android.permission.USE_CREDENTIALS"/>
    <uses-permission android:name="android.permission.MANAGE_ACCOUNTS"/>
    <uses-permission android:name="android.permission.AUTHENTICATE_ACCOUNTS"/>
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.WRITE_SETTINGS"/>
    <uses-permission android:name="android.permission.READ_SYNC_STATS"/>
    <uses-permission android:name="android.permission.READ_SYNC_SETTINGS"/>
    <uses-permission android:name="android.permission.WRITE_SYNC_SETTINGS"/>
    <uses-permission android:name="android.permission.BROADCAST_STICKY"/>
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
    <uses-permission android:name="android.permission.READ_PHONE_STATE"/>
    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
    <uses-permission android:name="android.permission.WAKE_LOCK"/>
    <uses-permission android:name="android.permission.READ_SMS"/>
    <uses-permission android:name="android.permission.WRITE_SMS"/>
    <uses-permission android:name="android.permission.READ_CONTACTS"/>
    <uses-permission android:name="android.permission.READ_CALL_LOG"/>
    <uses-permission android:name="android.permission.READ_CALENDAR"/>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>

    <uses-sdk
            android:minSdkVersion="8"
            android:targetSdkVersion="16" />

    <application
            android:icon="@drawable/icon"
            android:label="@string/app_name"
            android:theme="@style/AppTheme">
        <activity
                android:name=".MainActivity"
                android:label="@string/app_name"
                android:exported="true"
                android:launchMode="singleTask">
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
            <intent-filter>
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE"/>
            </intent-filter>
        </activity>
        <activity android:name=".authentication.AuthenticateActivity"/>
        <activity android:name=".ui.activity.DisplayInfoActivity"/>
        <activity android:name=".ui.activity.Preferences"/>
        <activity android:name=".ui.activity.ParentActivity"/>
    </application>
</manifest>

and there is no theme. This is styles.xml:

<?xml version="1.0" encoding="utf-8"?>

<resources>
    <style name="Animations" />
    <style name="AppTheme" parent="Theme.Sherlock.Light.DarkActionBar"/>
    <style name="OAuthDialog" parent="@android:style/Theme.Dialog">
        <item name="android:windowNoTitle">false</item>
    </style>

    <color name="setup_text_hint">#777777</color>
    <color name="setup_text_typed">#000000</color>
</resources>

Solution

  • This is an working example maven-intellij-sherlock:

    enter image description here

    And the pom.xml is:

    <parent>
        <groupId>.................</groupId>
        <artifactId>..........-parent</artifactId>
        <version>0.0.4</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>
    
    <artifactId>..........-android</artifactId>
    <packaging>apk</packaging>
    
    <name>.............| Android apk</name>
    
        <dependencies>
           <dependency>
            <groupId>com.actionbarsherlock</groupId>
            <artifactId>actionbarsherlock</artifactId>
            <type>apklib</type>
            <exclusions>
                <exclusion>
                    <groupId>com.google.android</groupId>
                    <artifactId>support-v4</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        </dependencies>
    

    edit:

    <plugin>
                        <groupId>com.jayway.maven.plugins.android.generation2</groupId>
                        <artifactId>android-maven-plugin</artifactId>
                        <extensions>true</extensions>
                        <executions>
                            <execution>
                                <id>lint</id>
                                <goals>
                                    <goal>lint</goal>
                                </goals>
                                <phase>package</phase>
                            </execution>
                        </executions>
                        <configuration>
                            <release>true</release>
                            <sdk>
                                <platform>${android.api.version}</platform>
                            </sdk>
                            <lint>
                                <skip>false</skip>
                                <failOnError>false</failOnError>
                            </lint>
                            <proguard>
                                <skip>false</skip>
                                <jvmArguments>
                                    <jvmArgument>-Xms1G</jvmArgument>
                                    <jvmArgument>-Xmx2G</jvmArgument>
                                </jvmArguments>
                            </proguard>
                        </configuration>
                    </plugin>