Android清单与@String参考 - 特别是安卓当局 [英] Android Manifest with @String reference - specifically android:authorities

查看:131
本文介绍了Android清单与@String参考 - 特别是安卓当局的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个问题的清单。

看起来这可能是一个欺骗: <一href="http://stackoverflow.com/questions/6461776/using-string-for-androidauthorities-in-a-contentprovider">Using @string为Android:在ContentProvider的当局

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

我有一个提供不同版本应用程序的单独的机构(使不同的变化可以是我存储这些机构的差目标资源的文件夹的字符串的文件夹内。

I have a provider with separate authorities for different versions of the app (so that the different variations can be I store these authorities within the string folders of the difference target res folders.

我的表现看起来就像这样:

My manifest looks as such:

   <provider android:authorities="@string/app_provider_auth" android:name="com.mecompany.myapp.provider.CachedFileProvider"/>

现在,这工作正常但是我看到一个错误清单问题,当它安装了2.1 OS设备上。这是问题,因为当我将其更改为它工作正常在2.1文本字符串。

NOW, this works fine however I am seeing a Bad Manifest issue when it is installed on a 2.1 OS device. This is the issue as when I change it to a text string it works fine on 2.1.

我要带它上2.1(7)或更早版本的清单不允许你从资源文件引用的字符串。所以,我可以创建一个单独的清单为7的版本,我可以有一个if语句中的表现?或者我必须提高minSDK(最后的手段)?

I'm taking it that on 2.1 (7) or earlier the manifest does not allow you to reference strings from the resource files. So, can I create a separate manifest for version 7-, can I have a if statement in the manifest? or do I have to raise the minSDK (last resort)?

在继续搜索OK好像我也许能设置/切换使用我的Maven构建的供应商身份验证字符串。我已经有一些配置文件和我压倒一切的资源文件夹。所以我很舒服的想法,但是它在我怎么不能让我的头左右。 像

OK on further searching seems like I might be able to set/switch the provider auth string using my Maven build. I already have a number of profiles and am overriding resource folders. So i am comfortable with the idea, however its the how I can't get my head around. something like

<replaceAuthority>${customerauthority}<replaceAuthority>

不过,我不知道该标记是什么,我应该使用,或者如果这样我上面假设的是,我需要走的路。

However I don't know what the tag is that I should use, or if the way i have hypothesized above is the way I need to go.

推荐答案

要改变从Maven的供应者,你可以使用&LT; providerAuthorities&GT;喜欢这里标签:

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>

这篇关于Android清单与@String参考 - 特别是安卓当局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆