[英]Is it better to have min, target and compile SDK set to equal version?
I'm learning Android and coming from the dark side of iOS, where everything is stricter handled.我正在学习 Android 并且来自 iOS 的阴暗面,在那里一切都得到了更严格的处理。
I have read about the differences between min sdk
, target sdk
and compile sdk
.我已经阅读了
min sdk
、 target sdk
和compile sdk
之间的差异。 However the following scenario is still not clear to me.但是,以下情况对我来说仍然不清楚。
If my min sdk is set to KitKat (19)
to allow 98% user base coverage, and my target sdk is set to Android 10+ (30)
, then I could be compiling with features that are not available on KitKat.如果我的 min sdk 设置为
KitKat (19)
以允许 98% 的用户群覆盖,并且我的目标 sdk 设置为Android 10+ (30)
,那么我可以使用 KitKat 上不可用的功能进行编译。
For example Material design is supposed to be supported from Lolipop (21)
.例如,材料设计应该得到
Lolipop (21)
支持。 But how comes I still can add it to my KitKat build.gradle project?但是为什么我仍然可以将它添加到我的 KitKat build.gradle 项目中?
dependencies {
implementation "com.google.android.material:material:$material_version"
}
So when a user with KitKat Android opens my app, it should crash because of Material Design, right?因此,当使用 KitKat Android 的用户打开我的应用程序时,它应该会因为 Material Design 而崩溃,对吗? So why is the compiler not complaining about this and let it pass?
那么为什么编译器不抱怨这个并让它通过呢?
Is better to have all three pointing to the minimum version that I want to support?让所有三个都指向我想要支持的最低版本会更好吗?
So when a user with KitKat Android opens my app, it should crash because of Material Design, right?
因此,当使用 KitKat Android 的用户打开我的应用程序时,它应该会因为 Material Design 而崩溃,对吗? So why is the compiler not complaining about this and let it pass?
那么为什么编译器不抱怨这个并让它通过呢?
Because the library is backward compatible and so it will not crash.因为库是向后兼容的,所以它不会崩溃。 The compiler will complain otherwise.
否则编译器会抱怨。
Is better to have all three pointing to the minimum version that I want to support?
让所有三个都指向我想要支持的最低版本会更好吗?
Depends on your requirement, but in my opinion it is better to have a min sdk to target maximum users.取决于您的要求,但在我看来,最好有一个最小的 sdk 来定位最大的用户。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.