gpt4 book ai didi

安卓:actionbarsherlock + maven + Intellij 创建apk

转载 作者:行者123 更新时间:2023-11-29 21:22:21 24 4
gpt4 key购买 nike

这是我在 intellij 中的项目结构:

enter image description here

这是我的 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>

这就是我为从我的项目创建 apk 而运行的:

enter image description here

当我使用 intellij 在模拟器中运行我的程序时一切正常,但是当我尝试创建 apk 时,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

我的设置有什么问题???

编辑:

<?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>

而且没有主题。这是 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>

最佳答案

这是一个工作示例 maven-intellij-sherlock:

enter image description here

pom.xml 是:

<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>

编辑:

<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>

关于安卓:actionbarsherlock + maven + Intellij 创建apk,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20580990/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com