Android Manifest with @String reference - specifically android:authorities

别等时光非礼了梦想. 提交于 2019-12-02 00:42:30

To change provider from maven you can use <providerAuthorities> tag like here:

    <plugin>
        <groupId>com.jayway.maven.plugins.android.generation2</groupId>
        <artifactId>android-maven-plugin</artifactId>
        <version>3.5.0</version>
        <extensions>true</extensions>
        <configuration>

            <!-- Установка версии в манифест -->
            <manifest>
                <versionName>${project.version.name}</versionName>
                <versionCode>${project.version.code}</versionCode>

                <!-- провайдер -->
                <providerAuthorities>
                    <property>
                        <name>.database.DatabaseProvider</name>
                        <value>${project.package}.database.DatabaseProvider</value>
                    </property>                        
                </providerAuthorities>

            </manifest>
        </configuration>
    </plugin>
Aiden Fry

With a bit more help from here android-maven-plugin and resource filtering

here https://github.com/jayway/maven-android-plugin/pull/115

and @Konstantin Pridluda I came to an acceptable conclusion.

What I did was to create a new folder within parent project folder called manifests. Then created two sub folder customer1Manifest and customer2Manifest

Inside each of these folders i created a copy of the manifest file then replaced the @string reference with the appropriate hard string authorities. (the normal manifest file is the debug auth)

Then in the POM i switched out the manifests for the appropriate ones like this.

<profiles>
    <profile>
     <id>Customer1</id>
     <activation>
         <activeByDefault>true</activeByDefault>
     </activation>
     <properties>
  <customerManifest>../manifests/customer1Manifest/AndroidManifest.xml</customerManifest>
      </properties>
    </profile>
    <profile>
     <id>Customer2</id>
     <properties>
        <customerManifest>../manifests/customer2Manifest/AndroidManifest.xml</customerManifest>
      </properties>
      </profile>
</profiles>

then later on in the android-maven-plugin phase did this

 <plugin>
        <groupId>com.jayway.maven.plugins.android.generation2</groupId>
        <artifactId>android-maven-plugin</artifactId>
        <extensions>true</extensions>

        <inherited>true</inherited>
        <configuration>
         <androidManifestFile>${customerManifest}</androidManifestFile>
            .........
.......
        </configuration>
</plugin>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!