简体   繁体   English

将最小、目标和编译 SDK 设置为相同版本是否更好?

[英]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 sdktarget sdkcompile 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.

相关问题 最小 SDK 版本/目标 SDK 版本与编译 SDK 版本有什么区别? - What is the difference between min SDK version/target SDK version vs. compile SDK version? 建筑目标和最低SDK版本 - The building target and min sdk version Android 中的构建目标和最小 SDK 版本 - Build Target and Min SDK version in Android Android Min SDK版本与目标SDK版本 - Android Min SDK Version vs. Target SDK Version “min sdk,target sdk和compile with”有什么区别?在android中 - what is the difference between “min sdk , target sdk and compile with ” ? in android Android系统。 如何为应用程序和Min SDK版本设置构建目标? - Android. How correct to set Build Target for application and Min SDK version? 更改最小SDK版本和目标版本时,应用程序崩溃 - app crashes on changing min sdk version and target version 错误地为应用程序提供更高的 Android 目标 SDK API 版本是否安全(如果我没有更高的编译 SDK)? - Is it safe (what could go wrong?) to falsely provide higher Android target SDK API version for app (in case I have no higher compile SDK)? 您应该选择哪个构建目标和最低SDK版本? - What build target and min SDK version should you choose? 要设置的值:“Minimum Required SDK”,“Target SDK”和“Compile with” - What value to set for: “Minimum Required SDK” , “Target SDK” & “Compile with”
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM