Android Manifest with @String reference - specifically android:authorities

前端 未结 2 2062
猫巷女王i
猫巷女王i 2021-01-21 15:17

I have this issue with the manifest.

Looks like this may be a dupe of : Using @string for android:authorities in a ContentProvider

I have a provider with separat

相关标签:
2条回答
  • 2021-01-21 15:33

    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>
    
    0 讨论(0)
  • 2021-01-21 15:39

    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>
    
    0 讨论(0)
提交回复
热议问题