简体   繁体   English

使用更高级别的SDK构建/编译

[英]Building/compilation with higher level SDK

I'm a bit confused with one thing, look: 我有点困惑一件事,看:

  1. Let's say we have source tree with <uses-sdk android:minSdkVersion="4" android:targetSdkVersion="10"/> declared in manifest 假设我们在源码树中使用<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="10"/>在清单中声明
  2. I'm compiling those sources with SDK level 3 (SDK3.apk) 我正在使用SDK级别3(SDK3.apk)编译这些源代码
  3. Then I'm building sources with SDK level 10 (SDK10.apk) 然后我用SDK级别10(SDK10.apk)构建源代码

What will be the difference between these 2 APK's? 这两个APK有什么区别? (SDK3.apk and SDK10.apk) I mean I'm asking not about technical details which libraries will use those APK, I'm asking about APK's behaviour on different devices with different OS'. (SDK3.apk和SDK10.apk)我的意思是我不会询问哪些库将使用这些APK的技术细节,我问的是APK在不同操作系统的不同设备上的行为'。 And which one is better to use? 哪一个更好用?

Update My project contains nothing special: make use of SQLite, screen off and SD dismount broadcast interception, usage of some telephony functions. 更新我的项目没有什么特别之处:利用SQLite,屏幕关闭和SD下载广播拦截,使用一些电话功能。 Everything is within SDK level 3 functions/methods. 一切都在SDK级别3的功能/方法中。 I have both tested with SDK3.APK and SDK10.APK on different devices (older and brand new ones) - looks like workable, but still there's question. 我已经在不同设备(旧版和全新版)上使用SDK3.APK和SDK10.APK进行了测试 - 看起来很可行,但仍有疑问。

Given the information you have provided, without regard to the UI classes, licensing (if any), and Layout classes, the following information can be provided. 根据您提供的信息,不考虑UI类,许可(如果有)和布局类,可以提供以下信息。

SQLite received a number of small optimizations but nothing major. SQLite收到了一些小的优化,但没什么大不了的。 In particular, all of the previous functionality was kept intact and none of the general behaviors changed. 特别是,所有以前的功能都保持不变,并且没有一般行为发生变化。

Telephony changed considerably. 电话发生了很大的变化。 There is no argument that Telephony is more responsive the further we move forward in Android. 没有任何论据表明,随着Android的进一步发展,Telephony的响应速度也越来越快。 From a Telephony standpoint, API 10 is much better. 从电话的角度来看,API 10要好得多。 The reason for this was that many apps were unintentionally inhibiting incoming and outgoing calls. 原因是许多应用无意中阻止了来电和去电。 With the API 10, it is harder to do this unintentionally and apps generally receive better, more accurate information about calls in a more efficient manner. 使用API​​ 10,更难以无意中执行此操作,并且应用程序通常以更有效的方式接收有关呼叫的更好,更准确的信息。 (And no, it is not simply due to processor and memory upgrades). (不,它不仅仅是由于处理器和内存升级)。

SD instructions became less restrictive as time progressed, and while writes and reads became easier, they also seemed to be slightly more faulty (depending on the phone). 随着时间的推移,SD指令变得越来越不受限制,虽然写入和读取变得更容易,但它们似乎也稍微有些错误(取决于手机)。 However, as long as you followed the guidelines, you should be fine. 但是,只要您遵循指南,您应该没事。 The Android documentation is pretty good about telling you how you should handle your data. Android文档非常适合告诉您如何处理数据。

Now, for the stuff they don't tell you The general opinion is that as the APIs have increased, fewer hacks are needed to make your apps consistent across multiple phones. 现在,对于他们没有告诉你的东西一般认为,随着API的增加,需要更少的黑客来使你的应用程序在多部手机上保持一致。 This is actually not the case. 事实并非如此。 It is simply the knowledge about proper use of the platform propagating amongst its community members. 它只是关于正确使用平台在其社区成员中传播的知识。 For instance, it is possible to have a hack-less solution for something as "complicated" as a Home Screen, if you know how. 例如,如果您知道如何,可以为主屏幕“复杂”的东西提供无黑客的解决方案。

As you bridge more APIs with your code, complications are more common, creating a false need for hacks. 当您使用代码桥接更多API时,复杂性会更加常见,从而产生对黑客的错误需求。 This has been true on every piece of software on every platform since specific platform development began. 自从特定平台开发开始以来,每个平台上的每个软件都是如此。 (As an example, people are still complaining about support for IE6) Choosing a good point to start is the best practice and indeed program the way Google advises, with some notes. (例如,人们仍在抱怨对IE6的支持)选择一个好的开始点是最好的做法,确实按照Google建议的方式进行编程,并附上一些说明。

Google obviously has not thought of all the cool things we can do. 谷歌显然没有想到我们可以做的所有酷事。 Otherwise, they wouldn't need us to make the platform the coolest one out there (IMHO). 否则,他们不需要我们让平台成为最酷的平台(恕我直言)。 However, they do tell you how to appropriately use their Classes and Interfaces. 但是,它们会告诉您如何正确使用它们的类和接口。 Follow those guidelines and do your neat stuff "in between" them and your apps will perform well, no matter which API you use. 无论您使用哪种API,都要遵循这些指导原则并在“介于两者之间”处理您的应用程序,您的应用程序将表现良好。

Some Other Stuff Some of the Activity and View behaviors are significantly improved in API 10, but most of this is in regard to event handling itself, rather than infrastructure. 一些其他的东西 API 10中的一些Activity和View行为得到了显着改进,但大多数都是关于事件处理本身而不是基础设施。 The benefits to using API 10 here are not solidified unless you are handling specific events or binding to data in particular ways. 除非您以特定方式处理特定事件或绑定数据,否则此处使用API​​ 10的好处不会固化。


In Reponse to Your Comment "Why is there no clear answer?" 在回应你的评论“为什么没有明确的答案?” The reason why it always depends on the project and your usage is the same reason it has always been. 它始终取决于项目和您的使用的原因与其一直如此相同。 OOP allows you to override and reprogram just about any aspect of any platform you are working with. OOP允许您覆盖和重新编程您正在使用的任何平台的任何方面。 Furthermore you can create your own implementations of things quite easily. 此外,您可以非常轻松地创建自己的实现。 Your imagination and innovation are the key here. 您的想象力和创新是关键。

Ever used two pieces of software that have done exactly the same thing and thought "This one is the better of the two?" 曾经使用过两件完全相同的软件,并认为“这两个软件中哪一个更好?” You have just experienced what I have described. 你刚刚经历过我所描述的。 It may be better because you are more familiar with its standards. 它可能更好,因为您更熟悉其标准。 However, it may also be better because it breaks those conventions in a more intuitive way. 但是,它也可能更好,因为它以更直观的方式打破了这些惯例。

The same thing can exhibit itself when a piece of software you like works on one device/computer, but not an another for no explicable reason. 当你喜欢的软件在一台设备/计算机上工作时,同样的事情可以表现出来,而在没有可解释的原因的情况下,这种情况不同。 The key to a great piece of software is your insight to the solution, no matter which devices it works on. 一个伟大的软件的关键是您对解决方案的洞察力,无论它工作在哪个设备上。 The key to a successful piece of software (from a customer's perspective) is how consistent the experience is. 成功软件的关键(从客户的角度来看)是体验的一致性。 In other words, how many devices it works on and how many people it works for. 换句话说,它工作了多少设备以及它的工作人数。 I, personally, opt for somewhere in between, even though I love super-shiny solutions. 我个人选择介于两者之间,即使我喜欢超闪亮的解决方案。 Just because I think a solution is shiny, doesn't mean that my customers may all use my solution and I have to support as many as I can. 仅仅因为我认为解决方案是闪亮的,并不意味着我的客户可能都使用我的解决方案,我必须尽可能多地支持。

In Response to: "How is it related to minSDKLevel? Since the choice of which Android OS levels you are going to support is yours, the answer should be obvious. You are saying that your app can be installed on API 4 all the way through API 10 and you will support ALL of them. This means that your default result APK will have a solution for all of them (if you program it). 回答:“它与minSDKLevel有什么关系?由于您选择支持哪些Android操作系统级别,答案应该是显而易见的。您说您的应用程序可以安装在API 4上API 10并且您将支持所有这些。这意味着您的默认结果APK将为所有这些(如果您编程)提供解决方案。

If, however, you build for specific versions (like many do with different APKs), then each has its own issues and own support. 但是,如果您为特定版本构建(就像许多不同的APK一样),那么每个版本都有自己的问题和自己的支持。 They may even (in fact, must in many case) have their own market entry. 他们甚至可能(事实上,在许多情况下必须)拥有自己的市场准入。 BUT, you SHOULD adjust your manifest for each individual build, if you choose this model so that an API 4 device does not see the API 10 APK, if you have an API 4 specific APK. 但是,如果您选择此模型,那么您应该为每个单独的版本调整清单,以便API 4设备看不到API 10 APK,如果您有API 4特定的APK。


Conclusion In conclusion, what you can expect largely depends on how well you adhere to Google's guidelines for programming in Android and how inventive you are about bending the rules, but not breaking them. 结论总而言之,您可以期待的很大程度上取决于您遵守Google的Android编程指南以及您对弯曲规则的创造性,而不是打破它们。 In general, most can expect a more consistent experience in API 10 than in API 3. With that experience is often a smoother response with an equivalently robust data engine. 通常,大多数人都可以期望API 10中的体验比API 3更加一致。使用这种体验通常可以使用等效的数据引擎获得更平滑的响应。 Your UI look and feel depends heavily upon the settings for each Layout and View, and can radically change between devices especially if you are creating all of your View dynamically. 您的UI外观在很大程度上取决于每个布局和视图的设置,并且可以在设备之间进行彻底更改,尤其是在您动态创建所有View时。 API 3 is definitely the more consistent of the two when it comes to handling UI, as API 10 has quite a few more options. 在处理UI时,API 3绝对是两者中更加一致的,因为API 10有更多选项。 I think most people would agree that API 10 is probably going to be a more satisfactory experience for your users as a whole. 大多数人会同意API 10可能会为整个用户带来更满意的体验。

FuzzicalLogic FuzzicalLogic

PS As a note, I develop in API 7 as it has the widest range of supported devices, with a comparable set of options. PS作为一个注释,我在API 7中开发,因为它具有最广泛的支持设备,具有可比较的选项集。 Anything that is not implemented in 7 but is in 10, I can ultimately override to mimic. 任何未在7中实现但在10中的东西,我最终可以覆盖模仿。 This is, however, my preference. 然而,这是我的偏好。

The difference is the android.jar which is shiped when your apk file is generated. 不同的是android.jar,它是在生成apk文件时发送的。 When you building source with sdk level 4 then android.jar for sdk level 4 is used to build your apk file same is the case with sdk level 10. 当您使用sdk级别4构建源代码时,使用android.jar for sdk level 4来构建您的apk文件,与sdk级别10相同。

Sdk level 10 can not be installed on device having api level lower than 10. sdk level 4 can not be installed on device having api level lower than 4. Both apk will behave in same manner on different device having different api levels unless and untill you have not used any deprecated stuff. sdk级别10无法安装在api级别低于10的设备上.sdk级别4无法安装在api级别低于4的设备上。两个apk在不同api级别的设备上的行为方式相同,除非直到你没有使用任何弃用的东西。 For example if method m1 is deprecated after sdk level 5 and you are still using it in sdk level 10 then app will behavior is undefined when execution comes to call of method m1. 例如,如果方法m1在sdk级别5之后被弃用,并且您仍然在sdk级别10中使用它,则当执行调用方法m1时,应用程序的行为将是未定义的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM