2016-08-27 215 views
4

當我創建一個Android庫,默認情況下它會給我的清單文件下面圖書館清單中的`android:supportsRtl =「true」`必不可少?這是造成錯誤有時

<application android:allowBackup="true" 
    android:label="@string/app_name" 
    android:supportsRtl="true"/> 

後它作爲Bintray庫之後和被別人利用,才意識到如果應用程序,包括該庫具有以下在其清單

android:supportsRtl="false" 

將發佈如下錯誤gradle這個同步或編譯期間。

Error:Execution failed for task ':app:processProductionDebugManifest'. 
> Manifest merger failed : Attribute [email protected] value=(false) from AndroidManifest.xml:23:9-36 
is also present at [com.mylibrarypackage:mylibrary:1.0.0] AndroidManifest.xml:14:9-35 value=(true). 
Suggestion: add 'tools:replace="android:supportsRtl"' to <application> element at AndroidManifest.xml:18:5-67:19 to override. 

爲了解決這個問題,我想我需要從我的媒體庫清單中移除android:supportsRtl="true"

只是想知道爲什麼Android有這個默認的庫清單?如果我從我的書庫清單中刪除android:supportsRtl="true",會不會有任何潛在的問題?

回答

9

工具:替換=」 X,Y」

更換的x,y從任何較低優先級聲明屬性與 所提供的值(必須存在於同一節點上)。

當導入具有較低的目標SDK比項目庫,可能有必要明確授予的權限(也許會讓其他的變化)的庫在後期運行正常。這將由清單合併器自動執行。

你得到

清單合併失敗:從AndroidManifest.xml中屬性的應用程序@ supportsRtl 值=(假):23:9-36

您可以添加

tools:replace="android:supportsRtl" 

最後

<application android:allowBackup="true" 
android:label="@string/app_name" 
android:supportsRtl="true" 
tools:replace="android:supportsRtl"/> 
+1

謝謝!我有問題在http://stackoverflow.com/questions/39178543/can-toolsreplace-androidsupportsrtl-go-along-with-toolsignore-allowback。希望你能檢查出來,如果你知道這個答案... – Elye

0

如果您要支持從右向左(RTL)佈局,則需要此參數。 如果設置爲true並且targetSdkVersion設置爲17或更高,則系統將激活並使用各種RTL API,以便您的應用可以顯示RTL佈局。如果設置爲false或者targetSdkVersion設置爲16或更低,則RTL API將被忽略或無效,並且無論與用戶的Locale選項關聯的佈局方向如何,您的應用程序都會表現相同(您的佈局將始終保留-to-右)。

此屬性的默認值爲false。在API級別加入

此屬性17.

(來源:http://developer.android.com/guide/topics/manifest/application-element.html

+0

謝謝@ gaurav4sarma。我知道RTL的含義。只是想,如果我們可以決定不在庫中設置它,並讓應用程序設置它或覆蓋它。 – Elye

+0

感謝您的回覆。看起來你的答案已經在上面提出過了。祝你好運。 –