• Breaking News

    Wednesday, December 15, 2021

    Android Dev - The Neverending Use Case Story

    Android Dev - The Neverending Use Case Story


    The Neverending Use Case Story

    Posted: 14 Dec 2021 10:45 PM PST

    Is anyone using TDD on a significant Android app? Any tips?

    Posted: 15 Dec 2021 04:57 AM PST

    I had another discussion about test driven development and how impractical it is on Android today.

    TDD works well in dynamically typed languages were the unit tests can take 1 second to run no matter the size of the project. In statically typed Android, I find running a single unit test method of a single class takes about 1 minute. That's even if the change is only in one class in the main code or one line in the test code.

    On top of that there is so much more hassle of code not compiling in the test if you call a method that isn't yet on the class or add an extra parameter a method doesn't have yet. It's not remotely the same pleasant, fast flow you get with TDD in languages like JavaScript, Python and Ruby.

    I've only seen one major Android team claim they use TDD: Moonpig. Though when I tried to ask them simple questions at a talk they gave like how long it takes to run their tests while they are doing TDD, they didn't give an answer. So I've no idea if they just put up with the tests taking a minute to run or they have found a special way to structure their code to make the tests run in a reasonable time.

    I've used TDD occasionally for some very complex business logic where the pain of the tests taking a long time to run was made up for the extra sense of clarity and security of using TDD. These talks suggest even Kent Beck, the creator of TDD, thinks that you should only use TDD for hard code where you will see the benefit, not in run-of-the-mill code you've written many times before. https://martinfowler.com/articles/is-tdd-dead/

    I've read through past discussions on Reddit of TDD in Android and searched Google but I've not found anything. I think a single unit test would need to run in less than 5 seconds for TDD to be something that could be regularly used.

    A few years back I spent about 10 hours doing an unattended test for interview from scratch. It was a tiny app: a list activity and a detail activity. I went beyond what was requested by adding features for caching from a remote endpoint. Even in that tiny app, TDD was horribly slow and I imagine without TDD the same work would have taken 5 hours. I'm guessing code generation may be a major part of the issue.

    Is there a way to make TDD more practical in Android? I've heard it suggested that adding more interfaces everywhere will mean less code needs to recompile. I guess M1 Pro/Max laptops might reduce the test run time but I'm guessing to 20-30 seconds, which is still too long. Is anyone working on a team that heavily uses TDD in native Android Kotlin development for a large app (or have you in the past)? How long does it take to run the tests during TDD? Any tips? If giving test times, how big is your app? e.g.

    git ls-files | xargs -n100 wc -l | awk -F ' +|\\.' \ '/\./ { sumlines[$NF] += $2 } END { for (ext in sumlines) print ext, sumlines[ext] }' | grep 'kt\|java' 
    submitted by /u/Mic-Ric
    [link] [comments]

    create a Android UI framework... Live with "Code With The Italians"

    Posted: 15 Dec 2021 02:15 AM PST

    Two Italian coders live-stream their sweary, mostly unsuccessful attempts at coding stuff and learning Jetpack Compose.
    The app source code is here: https://cwti.link/bundel
    Support the channel for free if you already have Amazon Prime: https://cwti.link/prime-sub
    Or by buying our merch: https://cwti.link/spaccio

    https://www.youtube.com/watch?v=KF_s62vEPGY

    submitted by /u/Due_Leader1391
    [link] [comments]

    How about Android Studio preventing screen lock using Smart Lock?

    Posted: 14 Dec 2021 11:31 PM PST

    It is annoying that the device which is connected by a USB cable gets locked whilst I am using Android Studio. My phone has the fingerprint sensor on the back, so it is not easy to unlock it when it is laid on the desk.

    I have searched a way to disable the lock during debugging, and this old question was asking for the same thing. The easiest answer was "Settings > Developer Options > Stay awake when charging", but since it has an AMOLED screen, I do not think it is an ideal option to keep the screen on for the whole time whilst I am coding.

    Doesn't Android have Smart Lock or Trusted Agent or something that has the ability to prevent screen locking (but not preventing the screen from turning off due to inactivity)? Can't Android Studio somehow utilise that feature to prevent the phone from locking itself whilst Android Studio is running when the phone is connected to a computer via USB?

    In order to connect the phone with Android Studio in the first place, I must unlock the phone first, so I do not think hackers can run Android Studio to unlock an arbitrary phone.

    submitted by /u/evolution2015
    [link] [comments]

    Jetpack Compose Sweet Toast

    Posted: 15 Dec 2021 04:55 AM PST

    I published ComposableSweetToast lib. It includes kotlin, s.o.l.i.d principles, material design n custom view with composable. Click the link for more info in readMe n dont forget to give a star.

    ComposableSweetToast

    submitted by /u/talhafaki
    [link] [comments]

    Jetpack Compose Sweet Toast

    Posted: 15 Dec 2021 04:51 AM PST

    I published ComposableSweetToast lib. It includes kotlin, s.o.l.i.d principles, material design n custom view with composable. Click the link for more info in readMe n dont forget to give a star.

    ComposableSweetToast

    submitted by /u/talhafaki
    [link] [comments]

    Koin for Compose proposal (Jetpack and Multiplatform)

    Posted: 15 Dec 2021 04:44 AM PST

    What would you improve in handling Bluetooth on Android?

    Posted: 15 Dec 2021 04:43 AM PST

    I see many developers having trouble with handling Bluetooth and I'm wondering what would you like to see in a library that is intended for making working with Bluetooth more of a 🙂 than a 😡?

    Any specific problems you have or had in the past are more than welcome!

    submitted by /u/Gericop
    [link] [comments]

    Issue with new Android Splash Screen API 31 on Xiaomi MIUI

    Posted: 15 Dec 2021 01:03 AM PST

    Good morning everyone. On one of my projects, I implemented the new Android Splash Screen, with the animated icon on Android 12. BTW, I encountered an issue only with Xiaomi devices (Android 10 and 11) that have activated Dark Theme. It seems the dark option on MIUI overrides the application theme, and I have a black circle instead of my icon. I already tried to implement a different night style for the Theme.SplashScreen, and the forceDarkAllowed option, but both don't work. Does anyone find a solution? Thank you!

    https://i.imgur.com/F9fCUuf.jpg

    submitted by /u/sainz89
    [link] [comments]

    Jetpack Navigation placeholder in deeplink URI host?

    Posted: 15 Dec 2021 12:57 AM PST

    I am using Jetpack Navigation do define deeplinks to my destinations and cannot get how to change deeplink URI host during compilation time according to build flavor. It's was absolutely possible to do for deeplink intent filters in Manifest.xml but apparently it's forbidden to do in navigation.xml

    <deepLink android:id="@+id/deepLink" app:uri="myapp://com.example.test/fragment_one/{uuid}" />

    I want to change "myapp" according to flavor during compilation

    submitted by /u/Sensitive_Muffin_555
    [link] [comments]

    Any suggestions how to build a navigation graph programmatically using the Kotlin DSL for bottom navigation with multiple stack?

    Posted: 14 Dec 2021 11:45 PM PST

    Hi there!

    I am using latest Jetpack Navigation with native support of multiple stack for bottom navigation and it works fine. The only limitation for me that I have to define all navigation in navigation.xml and cannot change it during the runtime.

    Apparently I found out that there is an Kotlin DSL for building navigation graph programmatically https://developer.android.com/guide/navigation/navigation-kotlin-dsl

    Unfortunately I cannot find any examples of using this Kotlin DSL for bottom navigation with multiple stack.

    I would be glad if you could share your thoughts.

    Thank you.

    submitted by /u/Sensitive_Muffin_555
    [link] [comments]

    No comments:

    Post a Comment