如何在2019年开发Android应用程序:拥抱“新” Android

或Bitotsav '19应用程序如何成为现实 (or how the Bitotsav ’19 app became a reality)

背景:万神殿'17 (Background: Pantheon ’17 ⏪)

Almost two years ago, in September 2017, a friend, Ashank Anshuman convinced me to work on an app for the technical fest of our institute. We worked for about two weeks, day and night, getting it ready for release just in time for the fest. Although we were exhausted, it was an amazing feeling, getting something ‘out there’, in production, that people actually used! It served its purpose perfectly well, helping the organizers easily convey everything to the participants.

大约两年前,即2017年9月,一个朋友Ashank Anshuman说服我为我所的技术节开发了一个应用程序。 我们白天和黑夜都花了大约两个星期的时间,准备好及时发布以备不时之需。 尽管我们精疲力尽,但这是一种令人惊奇的感觉,在生产中得到人们实际使用的东西! 它很好地实现了其目的,帮助组织者轻松地将所有内容传达给参与者。

Pantheon '17 - Apps on Google Play

Pantheon '17-Google Play上的应用

Pantheon '17 - Apps on Google PlayIn its endeavor to provide a national platform for the youth to showcase their technical skills; displaying…play.google.com

Pantheon '17-Google Play上的应用程序 致力于为年轻人提供一个展示他们的技术技能的全国性平台; 显示… play.google.com

It was rated 4.9 with around 120 reviews, which Google’s bots removed for some reason, but that’s a story for another time. We received some requests to share the source of the app, but we declined, due to many reasons — but mostly because we weren’t that satisfied with the code, especially the parts rushed through near the end. We simply didn’t have enough time and experience to write code good enough for people to learn from and/or use.

大约有120条评论,它的评分为4.9分,谷歌的机器人出于某种原因将其删除,但这是另一个故事了。 我们收到了一些共享应用程序源的请求,但由于许多原因,我们拒绝了该请求-但主要是因为我们对代码不满意,特别是一些即将结束的部分。 我们只是没有足够的时间和经验来编写足以让人们学习和/或使用的代码。

再来一次! ? (Here We Go Again! ?)

Fast forward to November 2018: Ankit Agrawal (he’s that ‘fest guy’) asks me to join the team for Bitotsav, our annual socio-cultural fest, to which I agree, as I was looking for some excuse to revisit Android. This time I convinced Ashank (took a lot of convincing!) to work on the app.

快进到2018年11月:Ankit Agrawal(他是个``最帅气的家伙'')要我加入我们的年度社会文化盛宴Bitotsav的团队,我同意这一点,因为我一直在寻找重访Android的借口。 这次,我说服了Ashank(非常有说服力!)来开发该应用程序。

We didn’t do much in December, but I did start reading on things like Architecture Components, AndroidX, Jetpack etc. I had also been getting familiar with Kotlin over the past few months, with a couple courses being instrumental: A two-part course by the one and only Hadi Hariri and another more recent one by Svetlana Isakova and Andrey Breslav (which he introduced in KotlinConf 2018). Kotlin was thus the obvious choice for the app.

我们在12月做得并不多,但是我确实开始阅读诸如Architecture Components,AndroidX,Jetpack等内容。在过去的几个月中,我对Kotlin也很熟悉,其中有两门课程非常有用:两部分一个是唯一的Hadi Hariri ,另一个是最近的一个是Svetlana Isakova和Andrey Breslav(他在2018年的KotlinConf中引入)。 因此,Kotlin是该应用程序的明显选择。

Introduction to Kotlin Programming

Kotlin编程简介

Introduction to Kotlin ProgrammingKotlin 1.0 was released in February 2016, and since that time it's been embraced by developers around the world…shop.oreilly.com

Kotlin编程简介 Kotlin 1.0于2016年2月发布,从那时起,它被全世界的开发人员所接受…… shop.oreilly.com

Kotlin for Java Developers | Coursera

Java开发人员的Kotlin | Coursera

Kotlin for Java Developers | CourseraKotlin for Java Developers from JetBrains. The Kotlin programming language is a modern language that gives you more…www.coursera.org

Java开发人员的Kotlin | 来自JetBrains的Java开发人员的 Coursera Kotlin。 Kotlin编程语言是一种现代语言,可为您提供更多… www.coursera.org

决定 ? (Decisions ?)

The first half of January also went by with not much code being written, as I was preoccupied and couldn’t reach the college till 16th Jan. We did, however, make some major decisions:

一月份的前半段也没有编写太多的代码,因为我全神贯注,直到1月16日才上大学。但是,我们做了一些重大决定:

So basically, a hard reset from all the experience of developing an app in 2017 to the bleeding edge in 2019. It was really exciting, but also a big challenge.

因此,基本上,这是从2017年开发应用程序的全部经历到2019年发展前沿的一次硬复位。这确实令人兴奋,但同时也是一个巨大的挑战。

代码代码代码! ? (Code Code Code! ?)

We decided that Ashank would take care of the Backend of the app (DB & Networking, Notifications with FCM, Background Processing) and I’d take care of the Frontend and Integration, just like we did for Pantheon ’17. Many resources came in handy while getting started and as we worked, but the best by far were these awesome codelabs offered by Google:

我们决定Ashank将负责应用程序的后端(数据库和网络,FCM通知,后台处理),而我将负责前端和集成,就像我们对Pantheon '17所做的那样。 在开始使用和我们一起工作时,有许多资源派上用场,但到目前为止最好的是Google提供的这些出色的代码实验室:

Google Codelabs

Google Codelabs

Google CodelabsGoogle Developers Codelabs provide a guided, tutorial, hands-on coding experience. Most codelabs will step you through…codelabs.developers.google.com

Google Codelabs Google Developers Codelabs提供了指导性的,动手的编码经验。 大多数代码实验室都会带您逐步完成… codelabs.developers.google.com

Also, the Sunflower & Google IO 18 apps by Google were ideal codebases for the purpose of reference. Android Dev Summit app would also have been a good source for reference, had I known about it before!

同样,出于参考目的,Google的SunflowerGoogle IO 18应用程序也是理想的代码库。 如果我以前知道的话, Android Dev Summit应用程序也将是一个很好的参考来源!

googlesamples/android-sunflower

googlesamples / android-sunflower

googlesamples/android-sunflowerA gardening app illustrating Android development best practices with Android Jetpack. - googlesamples/android-sunflowergithub.com

googlesamples / android-sunflower 一个园艺应用程序,用于说明Android Jetpack的Android开发最佳做法。 -googlesamples / android-sunflower github.com

With these in our arsenal, we began coding. I decided to use the new Navigation architecture component to implement a single-Activity app architecture. Ashank started with Room and FCM. I had also been thinking about using Koin for IoC, but wasn’t so sure.

有了这些,我们开始编码。 我决定使用新的Navigation架构组件 来实现单一活动应用程序架构 。 Ashank从Room和FCM开始。 我也一直在考虑将Koin 用于IoC ,但并不确定。

Incidentally, Joe Birch launched a Koin course right around that time on caster.io (Features small, to the point courses by professionals, each free for a week on launch!), and decided to go with it. No regrets there! Seriously, the android support is amazing and the documentation is fabulous ❤️

顺便说一句,乔·伯奇(Joe Birch)当时在caster.io开设了一次Koin课程(功能小巧,由专业人士提供的重点课程,每期课程免费发布一个星期!),并决定继续使用。 没有遗憾! 认真地说,android的支持是惊人的,并且文档很棒❤️

Koin

科恩

KoinIn this course, we'll be learning about a dependency injection framework known as Koin by building a fully functional…caster.io

Koin 在本课程中,我们将通过构建功能全面的… Caster.io, 学习称为Koin的依赖项注入框架。

With Navigation and Koin setup, I began with the UI, deciding was to use material design components exclusively for UI for which the guidelines and docs came in handy. Also, I had to use Data Binding because I love it! Meanwhile Ashank implemented WorkManager, which we decided to use instead of Firebase Job Dispatcher, going full Jetpack!

通过导航和Koin设置,我从UI入手,决定要使用专门用于UI的材料设计组件 ,对于这些组件指南 文档非常方便。 另外,我必须 使用数据绑定,因为我喜欢它! 同时,Ashank实施了WorkManager我们决定使用它代替Firebase Job Dispatcher使用完整的Jetpack!

The first thing I developed was the Schedule UI, which helped me get comfortable with Architecture Components. With that done, I moved on to the Registration-flow UI, probably the most complex part of the app, which featured advanced usage of LiveData and Navigation for implementing three steps with live-validated forms (Worth a blog post of its own, coming soon?!). This made me a lot more confident in these components, and it was a smooth ride from there on. We completed the planned features, discovered some gotchas, fixed some bugs.

我开发的第一件事是Schedule UI,它帮助我熟悉了Architecture Components。 完成此操作后,我进入了注册流程用户界面,它可能是应用程序中最复杂的部分,它具有LiveData和Navigation的高级用法,可通过实时验证的表单实现三个步骤(值得一提的是其博客文章,不久?!)。 这使我对这些组件更加自信,并且从那以后一切顺畅。 我们完成了计划的功能,发现了一些陷阱,并修复了一些错误。

发射? (Launch ?)

With major features implemented, we did some UI brush-ups, completed some final TODOs, and were ready for launch! As a finishing touch, I added something I had been planning for all along:

实施了主要功能后,我们进行了一些UI汇总,完成了一些最终的TODO,并准备好进行发布! 最后,我添加了我一直在计划的内容:

A different color theme on every configuration change! This was done to compliment the theme of the fest: “Colours of Asia”

每个配置更改都会有不同的颜色主题! 这样做是为了赞美电影节的主题:“ 亚洲色彩”

The app was live on the Play Store on Feb 11, 2019! ??

该应用程序于2019年2月11日在Play商店上线! ??

Bitotsav '19 - Apps on Google Play

Bitotsav '19-Google Play上的应用

Bitotsav '19 - Apps on Google PlayBitotsav '19 the 29th edition of Birla Institute of Technology, Mesra's annual socio-cultural fest is all set to take…play.google.com

Bitotsav '19-Google Play上的应用程序 Bitotsav '19是梅斯拉(Messra)年度社会文化盛宴的第29届比拉拉技术学院(Birla Institute of Technology),即将投入使用… play.google.com

修复与更新 (Fixes & Updates)

We faced (the only!) two bugs within hours, which we fixed right away. The first one was related to DAO methods being marked suspend, but I’m still not a 100% sure why exactly it was happening ?. The second one was caused by obfuscation causing a serialization failure, and was easily fixed with a Keep annotation.

我们在几个小时内遇到了(唯一!)两个错误,我们已立即修复。 第一个与DAO方法被标记为“ suspend ,但是我仍然不确定100%为什么会发生这种情况? 第二个是由混淆引起串行化故障引起的,并容易地固定用K EEP一个 nnotation。

Then I started working on the next update, in which I added the leaderboard in the feed and the night events for the fest in the schedule, along with some other changes. A third update followed adding some more minor features.

然后,我开始着手进行下一个更新,在该更新中,我在Feed中添加了排行榜,并为日程表中的节庆活动添加了夜间活动,以及其他一些更改。 随后进行了第三次更新,增加了一些次要功能。

The fest went well, and the app was used by over 1000 participants!

节日进行得很顺利,有1000多个参与者使用了该应用程序!

We did face a minor issue due to an incorrect DB entry in the servers by our friend Sushant Gupta, who later proceeded to write a rather dramatic blog post on the same.

我们确实遇到了一个小问题,因为我们的朋友Sushant Gupta在服务器中输入了错误的数据库条目,后来他在同一篇文章中继续撰写了一篇引人注目的博客文章。

DDoS Attack on Bitotsav '19 Website

对Bitotsav '19网站的DDoS攻击

DDoS Attack on Bitotsav '19 WebsiteThis is not a technical write up. This is a story that I want to share which might be a lesson for several Web & App…cs.sonudoo.com

Bitotsav '19网站上的DDoS攻击 这不是技术文章。 我想分享这个故事,这可能是一些Web和App的课程 。cs.sonudoo.com

After the fest, we released a final update, storing the event details, feed etc. as JSONs as part of the app and redacting the contact numbers of the organizers for privacy reasons.

节后,我们发布了最终更新,将事件详细信息,提要等作为JSON存储在应用程序中,并出于隐私原因编辑了组织者的联系电话。

公开! (Going Public!)

It was time to open source the code! This time around, we had taken care to write understandable code, and it was ready for the world. I prepared a slick README, and to remove the contact numbers from the history of the repository, we used the amazing BFG Repo Cleaner tool.

现在是时候开放代码了! 这次,我们非常注意编写易于理解的代码,并且已经为世界所用。 我准备了一个光滑的自述文件,并从存储库的历史记录中删除了联系电话,我们使用了令人惊叹的BFG Repo Cleaner工具。

The code for the Bitotsav ’19 app is now public, for anyone to review, refer to, learn from or use! Check it out and don’t forget to leave a ? ?

Bitotsav '19应用程序的代码现已公开,任何人都可以查看,参考,学习或使用! 检查一下,别忘了留下一个? ?

aksh1618/Bitotsav-19

aksh1618 / Bitotsav-19

aksh1618/Bitotsav-19Official app for Bitotsav '19. Contribute to aksh1618/Bitotsav-19 development by creating an account on GitHub.github.com

aksh1618 / Bitotsav-19 Bitotsav '19的官方应用程序。 通过在GitHub上创建一个帐户为aksh1618 / Bitotsav-19开发做出贡献。 github.com

挑战? (Challenges ?)

We did face some challenges during the development:

在开发过程中,我们确实面临一些挑战:

  • Time Limitations: The main challenge we faced was of having a very limited time to learn very new concepts and use them to create an app to be used by hundreds. This time constraint led to a lot of continuous hours being put in, leading to stress and fatigue, but we were able to power through and deliver!

    时间限制:我们面临的主要挑战是在非常有限的时间内学习非常新颖的概念并使用它们来创建可供数百人使用的应用程序。 这种时间限制导致投入大量连续时间,从而导致压力和疲劳,但是我们能够继续前进并提供服务!

  • WorkManager with Coroutines: On the technical side of things, we faced some minor challenges with WorkManager and Coroutines, but were able to overcome them. Hoping for a better support for coroutines throughout the Android SDK as development continues ?.

    使用协同程序的WorkManager:在技​​术方面,我们在使用WorkManager和协同程序时遇到了一些小挑战,但能够克服它们。 随着开发的继续,希望在整个Android SDK中为协程提供更好的支持。

  • API 21: We chose min API 21 to avoid having to adapt everything to work on older versions, as most android devices are on API 21 and above anyway. But surprisingly, some things refused to work on API 21, especially view backgrounds. It was really frustrating, making me wish we had set min API as 22, even more so when we found out that the app had been installed only on two API 21 devices: the ones we had tested on ?.

    API 21:我们选择了最小的API 21,以避免必须修改所有内容以使其在较旧的版本上运行,因为无论如何大多数android设备都在API 21及更高版本上。 但是令人惊讶的是, 某些事情拒绝在API 21上运行,尤其是视图背景。 真令人沮丧,我希望我们将min API设置为22,甚至更多,所以当我们发现该应用程序仅安装在两个API 21设备上:我们在?上测试过的设备。

  • Lack of Devices: Another challenge we faced was not having enough devices to test on. During Pantheon ’17, we had a hostel with ~200 people, and thus testing was easy. This time around most people were gone for internships, so we were left with relying on having confidence in the code!

    缺少设备:我们面临的另一个挑战是没有足够的设备进行测试。 在Pantheon '17期间,我们有一个约200人的旅馆,因此测试很容易。 这次,大多数人都去了实习,所以我们只剩下对代码有信心了!

  • No code reviewers: A lot of what we used was new to us, and we did our best to ensure we were doing everything right. But having a reviewer would have been very helpful. Even now, if you feel like you could do a quick review of the app’s code, we’d be very thankful!

    没有代码审查者:我们使用的很多东西对我们来说都是新的,我们尽力确保我们做的一切正确。 但是拥有审阅者将非常有帮助。 即使是现在,如果您希望可以快速查看该应用程序的代码,我们将非常感谢!

  • The Apocalypse: We did also face that ‘ DDoS ’ issue, read Sushant’s blog post linked above, you won’t regret it!

    启示录:我们也确实遇到了“ DDoS ”问题,请阅读上面链接的Sushant的博客文章,您将不会后悔!

外卖✅ (Takeaways ✅)

  • Kotlin + Jetpack = ❤️ : The main takeaway was that Android Development has come a long way and with Kotlin and Jetpack, it’s definitely a lot more fun and purely joyful! Seriously, there were multiple orgasmic moments during the coding process!

    Kotlin + Jetpack =❤️:主要的收获是Android开发已经走了很长一段路,而且与Kotlin和Jetpack相比,它肯定更加有趣,而且纯粹是快乐! 严重的是,在编码过程中有多个性高潮时刻!

  • Nothing is Impossible: Kinda cliché but true: if you have the will to work hard, you can do anything, no matter how difficult. Sure, there will be stressful phases, but keep powering through. Just believe in yourself!

    没有什么是不可能的:有点陈词滥调,但是是真的:如果您有努力工作的意志,那么无论多么困难,您都可以做任何事情。 当然,会有压力阶段,但要继续加油。 要相信你自己!

遗憾? (Regrets ?)

  • No Instant App / App Bundles: We just straight up missed this one. Didn’t even think about it. Ah well, maybe next time.

    没有即时应用程式/应用程式组合 :我们只是直接错过了这个。 甚至都没想过。 嗯,也许下次吧。

  • No tests: I know, this is a big one! Having proper tests in place could have helped us a lot, but due to the time constraints, we decided not to write tests until a ‘later’ time, which hasn’t yet come ?.

    没有测试 :我知道,这是一个很大的测试 ! 进行适当的测试可能对我们有很大帮助,但是由于时间限制,我们决定直到“以后”才开始编写测试,这还没有到来?

TL; DR。 ? (TL;DR. ?)

Starting with an app with 2019?

从2019年的应用程序开始?

使用Kotlin和协程 (Use Kotlin & Coroutines)
将Jetpack组件与AndroidX结合使用 (Use Jetpack Components with AndroidX)
  • Learn to use Navigation Component for Single-Activity Architecture.

    了解将导航组件用于单一活动体系结构。

  • Learn to use Lifecycle Components for UI & Room for persistence.

    了解如何将 Lifecycle Components用于UI和Room以获得持久性。

  • Do yourself a favor and use Data Binding!

    帮自己一个忙,并使用数据绑定!

  • Learn to use WorkManager for background processing.

    了解如何使用 WorkManager进行后台处理。

使用材料组件 (Use Material Components)
编写测试! (Write Tests!)

Well we couldn’t but you definitely should! Do NOT skip tests.

好吧,我们不能,但是您绝对应该! 不要跳过测试。

参考源代码 (Refer to Source Code)

.. of apps that do these things: Sunflower App, IO App, Dev Summit App or, of course, the Bitotsav ‘19 App! (also, leave a star ?)

..具有以下功能的应用程序: 向日葵应用程序IO应用程序开发峰会应用程序,或者,当然是Bitotsav '19应用程序 ! (还要留下星星吗?)

保持最新 (Stay up to date)

Subscribe to blogs and newsletters to stay up to date! Here are some to start with: Android Weekly, ProAndroidDev, AndroidPub, Kotlin Weekly. Overwhelmed? Check out this awesome talk by Huyen Tue Dao:

订阅博客和新闻通讯以保持最新! 从这里开始: Android Weekly, ProAndroidDevAndroidPub Kotlin Weekly 。 不知所措? 看看Huyen Tue Dao的精彩演讲:

Be Like Water: Keeping up with Android

像水一样:紧跟Android

Be Like Water: Keeping up with AndroidIf you enjoy talks from 360 AnDev, please support the conference via Patreon! The one constant of working in mobile is…academy.realm.io

像水一样 :跟上Android的 步伐如果您喜欢360 AnDev的演讲,请通过Patreon支持会议! 在移动领域工作的一个常数是… academy.realm.io

Well, there we go. This is a great time for Android Development, so go get started with your new app, and don’t forget to have fun while doing it!

好吧,我们去。 这是Android开发的绝佳时机,因此请开始使用您的新应用,别忘了在玩过程中玩乐!

If you learned something, leave a comment. Constructive criticism welcome ?

如果您学到了什么,请发表评论。 建设性的批评欢迎吗?

Catch me on Twitter ? , LinkedIn ? or GitHub ??

Twitter上找到我吗? , LinkedIn ? 还是GitHub?

Until next time ??

直到下一次 ??

翻译自: https://www.freecodecamp.org/news/developing-an-android-app-in-2019-embracing-the-new-android/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值