[英]Android AppCompat dependency in custom library
I just created a new library, Powerful Image View . 我刚刚创建了一个新库Powerful Image View 。
My library is a custom AppCompatImageView, so I need the appcompat-v7 library. 我的库是自定义的AppCompatImageView,因此我需要appcompat-v7库。 And here comes the question: 问题来了:
How should I add it to my library? 我应该如何将其添加到我的书架中?
Should I use 'compile', or 'provided' and let the user add the library to its own dependencies? 我应该使用“编译”还是“提供”并让用户将库添加到其自己的依赖项中?
And how should i handle different versions of the libraries used, since i'm not depending on a specific version? 由于我不依赖于特定版本,因此应该如何处理所使用库的不同版本?
I added to the library's gradle file this line: 我将这一行添加到库的gradle文件中:
provided 'com.android.support:appcompat-v7:+'
I'd like to know your thoughts about this :) 我想知道你对此的想法:)
Should I use 'compile', or 'provided' and let the user add the library to its own dependencies? 我应该使用“编译”还是“提供”并让用户将库添加到其自己的依赖项中?
I would use compile
and make sure that the developer using your library understands that your library relies upon appcompat-v7
, as that in turn places lots of other requirements (eg, using AppCompatActivity
, using Theme.AppCompat
). 我将使用compile
并确保使用您的库的开发人员了解您的库依赖于appcompat-v7
,因为这反过来又提出了许多其他要求(例如,使用AppCompatActivity
,使用Theme.AppCompat
)。
And how should i handle different versions of the libraries used, since i'm not depending on a specific version? 由于我不依赖于特定版本,因此应该如何处理所使用库的不同版本?
Well, you are requiring some version. 好吧,您需要一些版本。 AppCompatImageView
does not exist in all versions of appcompat-v7
. AppCompatImageView
并非在所有版本的appcompat-v7
中都存在。 I recommend depending upon a concrete version (ie, not +
), ideally the latest-and-greatest version. 我建议根据具体版本(即不是+
),最好是最新和最新版本。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.