Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/353.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 根据maven android构建配置文件更新应用程序名称和徽标_Java_Android_Maven_Android Manifest - Fatal编程技术网

Java 根据maven android构建配置文件更新应用程序名称和徽标

Java 根据maven android构建配置文件更新应用程序名称和徽标,java,android,maven,android-manifest,Java,Android,Maven,Android Manifest,这是我的清单文件 <?xml version="1.0" encoding="UTF-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="20411" android:versionName="2.4.11-SNAPSHOT" package="com.customcompany"> <uses-percustomssi

这是我的清单文件

<?xml version="1.0" encoding="UTF-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="20411" android:versionName="2.4.11-SNAPSHOT" package="com.customcompany">

    <uses-percustomssion android:name="android.percustomssion.ACCESS_WIFI_STATE"/>
    <uses-percustomssion android:name="android.percustomssion.CHANGE_WIFI_STATE"/>
    <uses-percustomssion android:name="android.percustomssion.CHANGE_WIFI_MULTICAST_STATE"/>
    <uses-percustomssion android:name="android.percustomssion.ACCESS_NETWORK_STATE"/>
    <uses-percustomssion android:name="android.percustomssion.INTERNET"/>
    <uses-percustomssion android:name="android.percustomssion.READ_LOGS"/>
    <uses-percustomssion android:name="android.percustomssion.WRITE_SETTINGS"/>
    <uses-percustomssion android:name="android.percustomssion.RECORD_AUDIO"/>
    <uses-percustomssion android:name="android.percustomssion.WRITE_EXTERNAL_STORAGE"/>
    <uses-percustomssion android:name="com.customcompany.percustomssion.AUTHENTICATE_USER"/>
    <uses-percustomssion android:name="android.percustomssion.ACCESS_COARSE_LOCATION"/>
    <uses-percustomssion android:name="com.customcompany.percustomssion.LAUNCH_ACTIVITY"/>


    <!--<uses-percustomssion android:name="android.percustomssion.SET_DEBUG_APP"/>

    <percustomssion android:description="@string/percustomssion_launchActivity_description" android:label="@string/percustomssion_launchActivity_label" android:name="com.customcompany.percustomssion.LAUNCH_ACTIVITY" android:protectionLevel="signature"/>
    <percustomssion android:description="@string/percustomssion_authenticateUser_description" android:label="@string/percustomssion_authenticateUser_label" android:name="com.customcompany.percustomssion.AUTHENTICATE_USER" android:protectionLevel="signature"/>-->

    <uses-sdk android:customnSdkVersion="13" android:targetSdkVersion="13"/>

    <application android:allowBackup="false" android:debuggable="true" android:hardwareAccelerated="true" android:icon="@drawable/icon"  android:largeHeap="true" android:logo="@drawable/actionbarlogo" android:name="com.customcompany.application.CustomApplication" android:theme="@style/Theme.CustomAirline">
        <activity android:exported="true" android:name="com.customcompany.activities.ExternalLaunchActivity"  android:screenOrientation="portrait">
            <intent-filter>
                <category android:name="android.intent.category.LAUNCHER"/>
                <action android:name="android.intent.action.MAIN"/>
            </intent-filter>
        </activity>
        <activity android:name="com.customcompany.activities.CustomAirlineActivity" android:screenOrientation="sensorPortait" android:theme="@style/Theme.CustomAirline.ActionBar" android:windowSoftInputMode="adjustPan"/>
        <activity android:name="com.customcompany.payment.CardPaymentActivity" android:screenOrientation="sensorPortait" android:theme="@style/Theme.CustomAirline.ActionBar" android:windowSoftInputMode="adjustPan"/>
        <activity android:name="com.customcompany.payment.CashPaymentActivity" android:screenOrientation="sensorPortait" android:theme="@style/Theme.CustomAirline.ActionBar" android:windowSoftInputMode="adjustPan"/>
        <activity android:name="com.customcompany.chooseflight.FlightDataActivity" android:screenOrientation="sensorPortait"/>
        <activity android:name="com.customcompany.login.LoginActivity" android:screenOrientation="sensorPortait" android:theme="@style/Theme.CustomAirline.ActionBar" android:windowSoftInputMode="stateAlwaysVisible|adjustResize"/>
        <activity android:name="com.customcompany.forms.FormEntryActivity" android:screenOrientation="sensorPortait" android:theme="@style/Theme.CustomAirline.ActionBar"/>
        <activity android:configChanges="orientation|screenSize" android:name="com.customcompany.manual.reader.pdfreader.PDFReaderAct" android:theme="@style/Theme.CustomAirline.ActionBar"/>
        <activity android:configChanges="orientation"  android:name="com.customcompany.manual.reader.pdfreader.AndroidListViewActivity"/>
        <activity android:configChanges="orientation|screenSize"  android:name="com.customcompany.manual.CustomManualActivity" android:theme="@style/Theme.CustomAirline.ActionBar"/>
        <activity android:configChanges="orientation|screenSize" android:name="com.customcompany.manual.reader.genericreader.GenericReader" android:theme="@android:style/Theme.NoDisplay"/>
        <service android:enabled="true" android:exported="false" android:name="com.customcompany.service.ControlledReplicationService"/>
        <service android:enabled="true" android:exported="false" android:name="com.couchbase.android.CouchbaseService"/>
        <service android:enabled="true" android:exported="false" android:name="com.customcompany.service.LocalCouchService"/>
        <service android:enabled="true" android:exported="false" android:name="com.customcompany.ifs.discovery.InflightSyncService"/>
        <activity android:configChanges="orientation|screenSize" android:name="com.customcompany.manual.reader.htmlreader.HTMLReader" android:theme="@style/Theme.CustomAirline.ActionBar" android:windowSoftInputMode="stateHidden|adjustResize|adjustPan"/>
        <activity android:name="com.customcompany.payment.PreOrderActivity" android:screenOrientation="sensorPortait" android:theme="@style/Theme.CustomAirline.ActionBar" android:windowSoftInputMode="adjustPan"/>
    </application>
</manifest>

Pom文件

           <plugin>
                <groupId>com.jayway.maven.plugins.android.generation2</groupId>
                <artifactId>android-maven-plugin</artifactId>
                <version>3.8.0</version>
                <dependencies>
                    <dependency>
                        <groupId>net.sf.proguard</groupId>
                        <artifactId>proguard-base</artifactId>
                        <version>${proguard.version}</version>
                    </dependency>
                </dependencies>
                <executions>
                    <execution>
                        <id>manifestUpdate</id>
                        <phase>process-resources</phase>
                        <goals>
                            <goal>manifest-update</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>alignApk</id>
                        <phase>package</phase>
                        <goals>
                            <goal>zipalign</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <release>true</release>
                    <sign>
                        <debug>false</debug>
                    </sign>
                    <zipalign>
                        <skip>false</skip>
                        <verbose>false</verbose>
                        <inputApk>${project.build.directory}/${project.artifactId}-${project.version}.apk
                        </inputApk>
                        <outputApk>
                            ${project.build.directory}/${project.artifactId}-${project.version}-signed-aligned.apk
                        </outputApk>
                    </zipalign>
                    <manifest>
                        <debuggable>false</debuggable>
                        <!-- note: below is set to false for testing. Feel free to use auto-increment
                            if you are sure about using auto-increment -->
                        <versionCodeAutoIncrement>false</versionCodeAutoIncrement>
                    </manifest>
                    <proguard>
                        <!-- Set the skip to false when making a proguard release -->
                        <skip>true</skip>
                        <config>${proguard.config}</config>
                        <jvmArguments>
                            <jvmArgument>-Xms512m</jvmArgument>
                            <jvmArgument>-Xmx1024m</jvmArgument>
                        </jvmArguments>
                    </proguard>
                    <manifestApplicationLabel>CrewApp-CD</manifestApplicationLabel>
                </configuration>
            </plugin>

com.jayway.maven.plugins.android.generation2
安卓maven插件
3.8.0
net.sf.proguard
前卫基地
${proguard.version}
声明更新
过程资源
清单更新
alignApk
包裹
优化
真的
假的
假的
假的
${project.build.directory}/${project.artifactId}-${project.version}.apk
${project.build.directory}/${project.artifactId}-${project.version}-signed-aligned.apk
假的
假的
真的
${proguard.config}
-Xms512m
-Xmx1024m
CrewApp CD

我想根据我选择构建Android项目的maven配置文件来控制应用程序的名称和徽标。这是一项受支持的功能吗?如果是的话,我们如何做到这一点?

您可以使用android maven插件(至少在3.80版中)实现这一点。以下是pom中配置文件的蓝图:

<profile>
        <id>yourProfile</id>
        <build>
            <plugins>
                <plugin>
                    <groupId>com.jayway.maven.plugins.android.generation2</groupId>
                    <artifactId>android-maven-plugin</artifactId>
                    <executions>
                        <execution>
                            <id>manifestUpdate</id>
                            <phase>process-resources</phase>
                            <goals>
                                <goal>manifest-update</goal>
                            </goals>
                        </execution>
                    </executions>
                    <configuration>
                        <manifestApplicationLabel>yourLabel</manifestApplicationLabel>
                        <manifestApplicationIcon>yourIcon</manifestApplicationIcon>
                    </configuration>
                </plugin>
            </plugins>
        </build>
    </profile>

你的个人资料
com.jayway.maven.plugins.android.generation2
安卓maven插件
声明更新
过程资源
清单更新
你的标签
你的偶像

有关其他参数,请参阅maven插件。

感谢您的更新。你能分享这个项目的文档吗?很抱歉,我找不到这个项目的文档。我想知道支持的其他选项这不起作用,因为应用程序名称是在
application
标记下指定的。我认为它适用于manifest标记下的所有属性。我正在更新我的pom和清单文件。它对我有效。尝试摆脱
中的
android:label
,而
标记中不需要
${manifestApplicationLabel}
。坦率地说,我不知道
的顺序是否重要,但也许你应该改变它。我发现您的pom中有两次
清单更新
目标。我会尝试一下,让您知道我从清单中删除了label属性,更改了pm中的顺序,并删除了重复的更新。但是,当应用程序生成时,应用程序名称现在就是activityName。已使用最新清单和pom进行更新