/r/androiddev

Photograph via snooOG

News for Android developers with the who, what, where, when and how of the Android community.

News / Articles / Talks / Tools / Open source!

About

News for Android app developers with the who, what, where, when, and how of the Android community. Probably mostly the how.

Here, you'll find:

  • News for Android developers
  • Thoughtful, informative articles
  • Insightful talks and presentations
  • Useful libraries
  • Handy tools
  • Open source applications for studying

Alternatives

This sub-reddit isn't about phones' and apps' general functionality, support, or system software development (ROMs). For news and questions about these topics try using other subs like

New Developer Resources

Build your first app

Starting Android career in 2022

Android Job Interview Questions and Answers

App Portfolio Ideas, Tiered List

Awesome Android UI

Material Design Icons

7000 Icons for Jetpack

Weekly Threads Calendar

Autoposted at approx 9AM EST / 2PM GMT

Links

Rules!

Wiki and FAQ!

Discord!

/r/androiddev

246,361 Subscribers

1

Job openings

Hi ..Any one attended the Google interview for senior Android developer position (L5)...Please share your experience

0 Comments
2025/01/21
05:46 UTC

4

Created my first Maven Central library (0.0.1) but when I uploaded my second version (0.0.2) of it my test app in Android studio doesn't show the squiggly line for new version available?

6 Comments
2025/01/21
04:28 UTC

1

Trying To Run Media3 Demos, but encountering ERROR message.

For context these are the open source project demos I am trying to run, but I don't know how to fix the error of "Starting in Kotlin 2.0, the Compose Compiler Gradle plugin is required when compose is enabled." error.

I have already tried editing my build.gradle.kts, I also changed the build.gradle file of the module that is associated with the run config, I am trying to run.

I referenced this guide, which is the one that the console message references. I attached screenshots of the error message.

I've also attached screenshots of my build.gradle file, both for the cast module, and the media3 root project folder.

Would greatly appreciate any help on this issue.

https://preview.redd.it/vktiwm7g78ee1.png?width=3342&format=png&auto=webp&s=24cc6e2a32289a3dfbf0fac8a8ab3b60a76cee97

https://preview.redd.it/744y5hse78ee1.png?width=3682&format=png&auto=webp&s=015c06fe781c448f448645c552fe240dd290a7e1

EDIT: added photos, not sure why my original post didn't include them

2 Comments
2025/01/20
22:28 UTC

1

Account terminated after using app-testing service

Used a paid for testing service for testing the app on 20 devices before release, all went well. After a short while my GP account was terminated for high-risk behavior. What can i do about it, how should i formulate the appeal? Should i even try? I have not heard of 1 successful appeal of this kind..

6 Comments
2025/01/20
19:26 UTC

1

Help with android mirroring.

Hey, anyone know of a good Android screen mirroring tool that uses ADB and has keymapping? A while back I was using Mirroid, but it seems kinda dead now. I need to be able to map keys to touch inputs for some projects. I've looked around for decent options and the closest I've come to getting what I'm looking for is QTScrcpy and TC Games, but are there any other solid options out there? Thanks in advance!

0 Comments
2025/01/20
17:17 UTC

1

Navigation Drawer with nested navgraphs and topbar icons

Hi!, I'm trying to create a navigation drawer using compose. The drawer has a topbar with a burger icon to open/close it. However I want to hide the topbar or replace it with another based on the route and I'm having some trouble achieving this (although I feel maybe there's a better way of doing this)

Here's the full stackoverflow question -> https://stackoverflow.com/questions/79355718/navigation-drawer-with-nested-navgraphs-and-topbar-icons/79355823

Thanks.

0 Comments
2025/01/20
16:49 UTC

1

Timber in 2025, is it still worth it?

I recently saw this lib in an official video on the android channel, researching it I found the proposal and the problems it solves very interesting, however the repository on github has been running for 4 years with no updates to the project, is it still worth it and is it safe? or is it legacy? if it's not worth it, are there any alternatives?

1 Comment
2025/01/20
16:48 UTC

3

Why AS listens my mic ??

Since several updates Android Studio listens my mic and never stops. Any idea ?

https://preview.redd.it/4c8ibq5u37ee1.png?width=890&format=png&auto=webp&s=2a148f9af21a6f8184dfbdbda2eaf787d8aadd08

5 Comments
2025/01/20
18:53 UTC

1

IssueTracker issues not getting passed triage

For a long time now I haven't had any problems, but lately I've encountered a lot of issues that get closed with Won't fix (Infeasible) even after all of the requested information has been supplied. This used to be a massive problem, but someone at Google must have realized this because it's been pretty solid for the past few years.

For example, I filed an issue about running not deploying the app on the latest stable Android Studio (although it actually seems like it might be the dreaded issue where even when it does deploy it doesn't use the latest built APK). I didn't have logs when I filed the issue, so I mentioned that I'd send them when it happens again.

It happened again, so I took the time to collect the logs and posted them, and bam:

Status: Won't Fix (Infeasible)

Thanks for the feedback. At this point, our team does not have enough info to proceed with investigating this issue. Please read https://developer.android.com/studio/report-bugs.html carefully and supply all required information.

If for whatever reason I didn't provide enough information, just let me know, and I'll try to get it.

Anyone else seeing an uptick on these kinds of interactions?

10 Comments
2025/01/20
15:33 UTC

1

How to set SwipeRefreshLayout's setColorSchemeColors via XML style/theme?

Is there a way to change the color of animated circular progress of SwipeRefreshLayout via XML? I prefer setting it globally as theme so that I don't need to repeatedly define its color(s) in each Fragment or Activity, I also don't want to make an extension function of it nor want to create a custom SwipeRefreshLayout by extending it. Additionally I wanted to know what is the color mapping of that thing like is it depending on `colorPrimary`, `colorAccent`, etc. You can easily however change the background in XML by defining `swipeRefreshLayoutProgressSpinnerBackgroundColor` in your base theme.

0 Comments
2025/01/20
14:03 UTC

21

Build your component library in Jetpack Compose via CLI

I built a Gradle plugin (CLI utility) that you can use to build your component library.

https://github.com/nomanr/lumo-ui
https://lumo.nomanr.com/
how does it work?

It's not a packaged library. Instead, it generates the UI components directly in your codebase. Which allows you to:

- direct bug fixes; otherwise, you'll create a PR to the lib or wait for someone to fix and release it)
- can make any enhancement to the components
- easy adaptation to your app's design system.

The components are high quality, and the source code is influenced by how Material3 is built.

The components generally work in Compose Multiplatform but require minor adjustments. Full support is in progress.

10 Comments
2025/01/20
12:16 UTC

4

Bug on Material-You colors and/or UMP on Android 15: When both used, you can't use material colors on anything

Background

I've noticed this on my tiny app that is a live wallpaper that has a phase of testing whether the current device supports material-You, as it allows you to choose which colors you want to select for generation of Material You colors, no matter which content you show.

What I've found

It seems that in this combination of conditions, you won't be able to use material-You colors on anything, even if you create a new Activity:

  1. Use anything that fetches or uses the Material-You colors, including even DynamicColors.applyToActivityIfAvailable or query of them
  2. Android 15. On previous versions it's fine.
  3. Call various functions of the UMP SDK by Google (used for GDPR consent dialog), such as requestConsentInfoUpdate .

After you use the UMP SDK even for this simple query function, Material-You colors will fail to be fetched. You can see it by changing the wallpaper.

Reported about this on multiple places, as I don't know which one is causing this issue, and hopefully at least one of them will handle it as soon as possible

I find it weird it wasn't fixed by now. I can reproduce it on my Pixel 6 and also on emulator.

What can be done

I couldn't find a workaround that will work no matter what, except in my case I will probably try to skip this step in case those conditions are met.

Perhaps there is a way to reduce the chance of this scenario, by avoiding to use UMP when possible: when use has removed ads (purchased) or when you know you don't need UMP, but I don't know how to check if UMP needs to be used on the current device.

Has anyone noticed this issue and can share any idea of workarounds you've found?

2 Comments
2025/01/18
14:56 UTC

32

Viewmodel one-off events: can we agree this is a bad article?

Referring to this article:

https://medium.com/androiddevelopers/viewmodel-one-off-event-antipatterns-16a1da869b95

I fail to see the point.

Using a buffer/replay for underlivered events (in case the user backgrounds the app) makes the likelihood of this event not being collected very, very small - and we are not talking about mission critical apps in 99% of the cases.

Modeling a bunch of "this event happened" inside a state class seems very ugly to me, and then it has an added cost of having to nullify them, every single one, after it has been collected.

It also makes it confusing and hard to reason about a UI state when it has "this event happened" properties inside. When I see

`val paymentResult: PaymentResult? = null`

I would naturally think of this meaning there is a need to display a new composable with info about this result, and *NOT* the need to launch a new launched effect, then nullify the corresponding property in the viewmodel.

A similar one is given by the Android docs:

data class LoginUiState(
    val isLoading: Boolean = false,
    val errorMessage: String? = null,
    val isUserLoggedIn: Boolean = false
)

Am I the only one who finds this unintuitive? We are modeling specifically the UI *BEFORE* the user is logged in, with either a loader or an error, so what is the point of a `isUserLoggedIn` flag since the UI state for a logged in user is a different one?

Is anyone else of the same/opposite opinion? Obviously it is best practice to minimize events when possible, but I much rather have a single collector for events separated out from state.

52 Comments
2025/01/18
13:57 UTC

7

Partial data loss in android room sqlite database

I have an android application that runs on a slightly customized version of Android 10. The application persists data to Room db.

Recently, backend server has logged 40 cases of partial data loss where both newly inserted rows and updates done to existing rows have been deleted from the database.

My assumption is that since SQLite initially writes data to a WAL file, corruption of this file is resulting in loss of data that is not yet persisted to the original db.

I have tested this out by intentionally corrupting the WAL file by writing garbage data to it and sure enough, all the data that hasn't been checkpointed is lost.

Now, how do I identify what is corrupting the WAL file?

Links I've referenced while debugging this: How To Corrupt An SQLite Database File Debugging file corruption on iOS

PS: I posted the same on stackoverflow if you prefer to answer there: https://stackoverflow.com/questions/79367207/partial-data-loss-in-android-room-sqlite-database

29 Comments
2025/01/18
13:22 UTC

8

Networking library recommendations?

Assuming you aren't using something like GraphQL, what networking libraries are people using these days? In the past, I used Volley, Retrofit and OkHttp. Are Retrofit and OkHttp still popular or were they replaced by something else at some point?

Ktor seems to be the latest and greatest. What are some of its advantages over Retrofit, for example?

16 Comments
2025/01/18
07:21 UTC

13

Quick Guides Catalog

I just found out a new Quick Guides Catalog section in the new documentation. This is great! I just hope Google won't discontinue this experiment.

2 Comments
2025/01/18
05:19 UTC

1

ndk-samples won't build

I am a JNI and NDK noob !!

Official NDK-Samples

System specs:

Android Studio Ladybug Feature Drop | 2024.2.2

Build #AI-242.23726.103.2422.12816248, built on December 17, 2024

Runtime version: 21.0.4+-12422083-b607.1 aarch64

VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.

Toolkit: sun.lwawt.macosx.LWCToolkit

macOS 15.2, M1-Max Chip

GC: G1 Young Generation, G1 Concurrent GC, G1 Old Generation

Memory: 4096M

Cores: 10

Metal Rendering is ON

Registry:

ide.experimental.ui=true

i18n.locale=

Non-Bundled Plugins:

com.github.firebender.androidstudiocopilot (0.7.5)

The error I get is:

NDK_Samples.orderfile.app.main | debug | x86 Compiler exited with error code 1: 
$ANDROID_SDK_ROOT/ndk/27.1.12297006/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang++ 
-xc++ 
--target=i686-none-linux-android21 
--sysroot=$ANDROID_SDK_ROOT/ndk/27.1.12297006/toolchains/llvm/prebuilt/darwin-x86_64/sysroot 
-DGENERATE_PROFILES 
-Dorderfiledemo_EXPORTS 
-g 
-DANDROID 
-fdata-sections 
-ffunction-sections 
-funwind-tables 
-fstack-protector-strong 
-no-canonical-prefixes 
-D__BIONIC_NO_PAGE_SIZE_MACRO 
-mstackrealign 
-D_FORTIFY_SOURCE=2 
-Wformat 
-fno-limit-debug-info 
-fPIC 
-forder-file-instrumentation 
-O1 
-mllvm 
-fpch-preprocess 
-v 
-dD 
-E 
    Android (12285214, +pgo, -bolt, +lto, -mlgo, based on r522817b) 
    clang version 18.0.2 (https://android.googlesource.com/toolchain/llvm-project d8003a456d14a3deb8054cdaa529ffbf02d9b262) 
    Target: i686-none-linux-android21 
    Thread model: posix 
    InstalledDir: $ANDROID_SDK_ROOT/ndk/27.1.12297006/toolchains/llvm/prebuilt/darwin-x86_64/bin (in-process) 
    "$ANDROID_SDK_ROOT/ndk/27.1.12297006/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang++" 
    -cc1 
    -triple i686-none-linux-android21 
    -E 
    -disable-free 
    -clear-ast-before-backend 
    -disable-llvm-verifier 
    -discard-value-names 
    -main-file-name compiler-file14432936237958166499 
    -mrelocation-model pic 
    -pic-level 2 
    -fhalf-no-semantic-interposition 
    -mframe-pointer=none 
    -ffp-contract=on 
    -fno-rounding-math 
    -mconstructor-aliases 
    -funwind-tables=2 
    -target-cpu i686 
    -target-feature 
    +ssse3 
    -tune-cpu generic 
    -debug-info-kind=standalone 
    -dwarf-version=4 
    -debugger-tuning=gdb 
    -fdebug-compilation-dir=$WORKSPACE/ndk-samples/orderfile/app/.cxx/Debug/1t412i6g/x86 
    -v 
    -ffunction-sections 
    -fdata-sections 
    -fcoverage-compilation-dir=$WORKSPACE/ndk-samples/orderfile/app/.cxx/Debug/1t412i6g/x86 
    -resource-dir $ANDROID_SDK_ROOT/ndk/27.1.12297006/toolchains/llvm/prebuilt/darwin-x86_64/lib/clang/18 
    -D GENERATE_PROFILES 
    -D orderfiledemo_EXPORTS 
    -D ANDROID 
    -D __BIONIC_NO_PAGE_SIZE_MACRO 
    -D _FORTIFY_SOURCE=2 
    -D ___CIDR_DEFINITIONS_END 
    -isysroot $ANDROID_SDK_ROOT/ndk/27.1.12297006/toolchains/llvm/prebuilt/darwin-x86_64/sysroot 
    -internal-isystem $ANDROID_SDK_ROOT/ndk/27.1.12297006/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/include/c++/v1 
    -internal-isystem $ANDROID_SDK_ROOT/ndk/27.1.12297006/toolchains/llvm/prebuilt/darwin-x86_64/lib/clang/18/include 
    -internal-isystem $ANDROID_SDK_ROOT/ndk/27.1.12297006/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/local/include 
    -internal-externc-isystem $ANDROID_SDK_ROOT/ndk/27.1.12297006/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/include/i686-linux-android 
    -internal-externc-isystem $ANDROID_SDK_ROOT/ndk/27.1.12297006/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/include 
    -internal-externc-isystem $ANDROID_SDK_ROOT/ndk/27.1.12297006/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/include 
    -O1 
    -Wformat 
    -fdeprecated-macro 
    -ferror-limit 19 
    -femulated-tls 
    -stack-protector 2 
    -mstackrealign 
    -fgnuc-version=4.2.1 
    -fcxx-exceptions 
    -fexceptions 
    -dD 
    -mllvm 
    -fpch-preprocess 
    -forder-file-instrumentation 
    -mllvm 
    -enable-order-file-instrumentation 
    -D__GCC_HAVE_DWARF2_CFI_ASM=1 
    -o - 
    -x c++ /private/var/folders/x6/ddqnwb092gb74r0d975rsbcc0000gp/T/compiler-file14432936237958166499 
    clang (LLVM option parsing): Unknown command line argument '-fpch-preprocess'. Try: 'clang (LLVM option parsing) --help' clang (LLVM option parsing): Did you mean '--ddg-pi-blocks'? 

I suspect the last statement - Unknown command line argument '-fpch-preprocess'. Try: 'clang (LLVM option parsing) --help' clang (LLVM option parsing): Did you mean '--ddg-pi-blocks'?

Furthermore, I see two projects in the project-pane although `git-cloned` only one.

https://preview.redd.it/9hcjkaxzdmde1.png?width=246&format=png&auto=webp&s=78036b3f53603da5ff17eb2214c5b81f4551d796

Any pointers immensely appreciated.

13 Comments
2025/01/17
21:15 UTC

1

How to keep the scrolled bottom item visible when ime appears?

Hi all

Using Compose, I'm trying to make a column able to keep visible the bottom item when ime gets displayed

I have a text field at bottom of screen, and above is the column, filled with random text to make it scroll.

I tried a bit Modifier.imeNestedScroll(), but I struggle, I'm not even sure it would do the job

Here is my code currently, but it's kinda buggy...

ComposeTestTheme {
    Scaffold(modifier = Modifier.fillMaxSize())
    { innerPadding ->
        Column(
            modifier = Modifier
                .padding(innerPadding)
                .consumeWindowInsets(innerPadding)
                .fillMaxSize()
        )
        {
            LazyColumn(
                modifier = Modifier
                    .weight(1f)
                    .fillMaxWidth()
                    .border(2.dp, Color.Red)
                    .imeNestedScroll()

            )
            {
                items(50) { index ->
                    Text(text = "item: $index")
                }
            }
            TextField(
                value = "",
                onValueChange = {},
                modifier = Modifier
                    .fillMaxWidth()
                    .border(2.dp, Color.Black)
                    .imePadding()
            )
        }
    }
}

Could someone help?

Regards

1 Comment
2025/01/17
20:00 UTC

0

Questions about Closed testing on Google Play Console.

Hi,

Like many other new indy devs I have been coding an app for few months and I'm facing that unexpected wall, closed testing requirement.
You must invite 12 testers continously testing your app for 14 days.
I have read the doc but I'm still a bit confused.

About the 14 days:
Is this a global countdown from when you publish your closed testing and if you don't meet the requirement you have to test again your app for 14 days?
Or you don't actually have a limited time for closed testing and once a tester used your app for 14 days it count as one, meaning that you can close test as long as you want until you get those 12 tester using your app for 14 days?

About the in app purchases:
I would like to test out in app purchases and I don't know if that's a good idea because if my app is rejected how can I justify to my customer that I wont be able to assist them as Google won't release the app?
Should I just set all my tester as licensed (test payment)?

8 Comments
2025/01/17
19:45 UTC

6

'Exactly' when do we call it unit test

I have a viewmodel that takes a form filled from user and after making validations through various validation usecases it sends it to the server. I'm writing unit tests for this viewmodel but i cannot decide to whether or not i should mock or fake these validation use cases which are all pure kotlin code and never depend on anything external - except a resource provider class that helps to get system strings - (i am able to easily create an instance of them). Actually another issue i'm looking for to learn is if don't mock them and pass the actual instances of these usecases is it still 'unit testing that viewmodel' i really wonder this because in some way we can think of this tests as integration test since it communicates with usecases - can we ? -. is it ok for this unit test to communicate with some pure kotlin logic when being unit tested ?

Here is a simple example from one of my use cases

- Thanks in advance for your opinions.

https://preview.redd.it/6ak494z5klde1.png?width=1786&format=png&auto=webp&s=2c8778a34840918f4dcb2672d30f42b8267adab8

9 Comments
2025/01/17
18:28 UTC

22

Multiple apps in single monorepo

I've seen a few threads about monorepos here but not quite exactly what I am facing. I've inherited a repo which contains multiple different (and very large) Android apps. Countless modules (great,) some of which are shared (also ok,) but most are not. Apps are solidly different and not something that would ever merge. Seems to have more downsides and overhead than any actual benefits.

In your experience, is this normal to stuff a bunch of apps into a single repo like this? Personally I've never seen it or would ever consider it, but maybe I am missing something?

24 Comments
2025/01/17
18:00 UTC

5

DNS resolution with API 24

Hi everyone!

(TLDR in last paragraph)

I'm making an Android app and it needs to perform DNS resolution for domain names. The official Android documentation hints at using a class called DnsResolver which, however, is available only in API 29 and later.

I don't want to drop support for older versions, which is why my minimum API is set to 24. However, I also don't want to support versions older than 24 because I know there have been a lot of changes since the introduction of API 24.

TLDR: How do I resolve domain names in API 24? Is there a way that is usually considered better than the others (or a "best practice")? Do I need to rely on an external library, unless I implement DNS resolution by myself?

4 Comments
2025/01/17
17:12 UTC

1

Color Picker Kotlin Multiplatform Library

I have ported an android compose library to kotlin multiplatform library, you can check it out Color-Picker-KMP , your feedback and contributions are more than welcomed

https://preview.redd.it/nwbqikdifjde1.png?width=1000&format=png&auto=webp&s=bb98d03a03898c1781dae5ca432adcb690270080

1 Comment
2025/01/17
11:16 UTC

11

What is a proper way to change the color of an overlay behind a Dialog in Compose?

There is a scrimColor property in ModalBottomSheet, which allows to change the color behind a bottom sheet.

scrimColor - Color of the scrim that obscures content when the bottom sheet is open.

At the same time it seems like the only way to change the color behidn a regular Dialog is to use a fullscreen Box as a root view and adjust its background. Although I can't explain exactly why this method is wrong, something about it doesn't feel right. Is there a better solution?

13 Comments
2025/01/17
09:13 UTC

12

Is Jetpack Compose ready for production?

I'm considering using Jetpack Compose in a new project, but I'm not sure if it's mature enough to fully replace the traditional View。

93 Comments
2025/01/17
06:03 UTC

41

Function, KFunction, KCallable, and all those other function types in Kotlin

4 Comments
2025/01/15
16:13 UTC

5

Dynatrace and WorkManager Behavior When App Is Killed

Hello everyone!

I’m dealing with a scenario related to Dynatrace and WorkManager. My question is: If the app is killed, will the WorkManager task still execute successfully? My assumption is that Dynatrace may not be accessible in such a situation. Has anyone faced a similar issue or knows how this would behave? Would appreciate any insights or resources!

1 Comment
2025/01/15
13:46 UTC

Back To Top