◉ANTIGRAVITY LABJP
Articles/App Development
▣ App Development/2026-07-17Advanced

Android 17's Local Network Permission: Inventory Every LAN Call Site Before You Hand the Fix to an Agent

Apps targeting Android 17 (API 37) need the ACCESS_LOCAL_NETWORK runtime permission to reach the LAN. A grep for private IPs found 2 of my 11 LAN paths. Here is the detector that found all 11, and how I turned its output into eleven checkable tasks for an agent.

Android 17Permissions3Migration10Agents27Local LLM8

✦ Premium Article

The host in settings had not changed, yet the app could no longer reach my local Ollama instance.

When that report came in, my first suspect was my own configuration. I retyped the IP. I checked the port. A browser on the same machine answered the endpoint without complaint. Still nothing from the app — and no exception in the log either. Just an empty response, returned politely.

Apps targeting Android 17 (API level 37) can no longer reach the local network without an explicit grant from the user. What makes this awkward is the shape of the failure: it rarely arrives as an exception you would recognise. TCP connects time out. UDP sends come back with EPERM. The Cast device list stays empty. None of those, at a glance, look any different from a slow network or a server that simply is not running.

Maintaining apps as an indie developer, I usually handle changes like this the lazy way — I notice them after something breaks. That is exactly how Android 16's edge-to-edge enforcement went for me. This time I wanted the inventory first, so I sat down and did the work.

What changes, and what to decide first

The scope is apps whose targetSdk is 37 or higher. Traffic to other devices on the same LAN now requires an explicit user grant. Internet and mobile-network traffic are untouched; only communication that stays inside a home or office network is affected.

Here is what I confirmed on the Android Developers page, Local network permission, as of November 2026, set side by side with Android 16.

AspectAndroid 16 (targetSdk 36)Android 17 (targetSdk 37+)
DefaultLocal network access is openBlocked by default once you raise targetSdk
PermissionNEARBY_WIFI_DEVICES used temporarily for opt-in testing (now deprecated)android.permission.ACCESS_LOCAL_NETWORK (runtime)
Permission groupNEARBY_DEVICES. If the user already granted another permission in that group, such as Bluetooth, they are not prompted again
Apps on targetSdk 36 or lowerImplicitly granted through INTERNET. The docs say plainly: don't declare or request ACCESS_LOCAL_NETWORK before targeting 37
When deniedTCP typically times out; UDP and general denials return EPERM. In the NDK, android_getnetworkblockedreason() returns ANDROID_NETWORK_BLOCKED_REASON_LNP
ExceptionsPort 53 to a DNS server on the LAN, Cast through the Output Switcher as the in-app picker, and connections to a device chosen through the NsdManager system picker

The first version of this article called the permission LOCAL_NETWORK_ACCESS. When I went back to the official page, the real name was ACCESS_LOCAL_NETWORK — same words, opposite order. The detector further down was looking for my wrong name too, so a correct declaration kept it reporting "undeclared," while the misspelt one would have sailed through. Both the prose and the code are fixed now.

Permission strings get pasted from the official page, never typed from memory. That is the one rule I hold myself to around this. Beyond that, what I want to pin down here is something more durable: being able to answer "where does my app touch the LAN?" from a machine rather than from memory.

Take the permission, or let a picker do it

The docs lay out two paths, and which one you pick changes almost everything you do after the inventory.

PathFits whenWhat the app getsWhat the user sees
A. System pickerCasting (Output Switcher), or connecting to one device found over mDNSA connection to the one device the user choseA system device-chooser dialog
B. Request ACCESS_LOCAL_NETWORKHome automation, IoT management, continuous NAS sync — broad, persistent LAN accessThe whole local networkThe "Nearby devices" permission prompt

If "pick one device and connect" covers it, take A; reach for B only when the app genuinely needs to watch the whole LAN. B means designing around refusal from day one, so if I can avoid it, both the user and I carry less.

To size the blast radius, I first wrote out every way an app leaves for the LAN.

PathHow it appears in codeWhat you see without permission
Private address literal192.168.x.x / 172.16-31.x.x / 10.x.x.xTCP typically times out (official)
mDNS name resolutionollama.local and friendsResolving .local itself needs the permission (official)
NSD service discoveryNsdManager.discoverServicesListed as affected; not needed via the picker (FLAG_SHOW_PICKER)
Multicast receivecreateMulticastLockUDP receive and send both need it (official)
Cast / MediaRouterActive scan via addCallbackDevice list stays empty; Output Switcher needs no permission
UDP broadcastSends to 255.255.255.255EPERM (official)
Host from settingsbaseUrl supplied at runtimeDepends on what the user typed
WebViewloadUrl against a LAN URLInherits the host app's permission state (official)

One thing struck me the moment the table was finished: from the app's side, most of that right-hand column does not look like a permission error. A timeout. An empty list. An EPERM that some helper swallowed into an empty result. Every one of them wears the same face as a slow network or an offline peer. The app never learns that permission was withheld, and the user keeps seeing "nothing found" forever.

The docs also note that the restriction sits deep in the networking stack, so it applies to every networking API — OkHttp and Cronet included. "We go through a library" is not an exemption.

✦

Thank you for reading this far.

Continue Reading

What follows includes implementation code, benchmarks, and practical content we hope you'll find useful. This site runs without ads — server and development costs are supported entirely by members like you. If it's been helpful, we'd be truly grateful for your support.

WHAT YOU'LL LEARN
✦A grep for '192.168' caught 2 of 11 LAN paths — mDNS, Cast, and configurable hosts carry no IP literals at all
✦Full source for lan_scan.py: route-shaped detection, three confidence tiers, exit 1 when the permission is undeclared
✦lan_tasks.py turns 'make it Android 17 ready' into eleven tasks an agent has to answer one by one
Secure payment via Stripe · Cancel anytime
✦

Unlock This Article

Get full access to the rest of this article. Buy once, read anytime. This site is ad-free — your support goes directly toward keeping it running.

or
Unlock all articles with Membership →
Share

Thank You for Reading

Antigravity Lab is ad-free, supported entirely by members like you. We publish practical guides daily with implementation code, benchmarks, and production-ready patterns. If you've found it useful, we'd love to have you on board.

  • ✦Copy-paste ready implementation code
  • ✦New advanced guides published daily
  • ✦$5/mo or $10 for lifetime access
View Membership →

Related Articles

◈ Agents & Manager2026-09-24
A Small Guard Script That Catches an Unattended Agent Rewriting Its Own Settings
After reading a report of an agent widening its own read-only limits by editing settings.json, I wrapped my overnight headless runs in an outside guard. Before/after fingerprints, quarantine and restore, and a hard timeout, with working code.
◈ Agents & Manager2026-07-29
A Typo in agent.md Quietly Widened My Permissions — Writing a Strict Frontmatter Lint
Misspelled keys in agent.md frontmatter do not raise errors. They fall back to defaults, and for permission fields that fallback points the wrong way. Here is the failure I hit, the lint I wrote to catch it, and what the measurements showed.
▣ App Dev2026-11-24
Two Times Inlining CSS Made FCP Slower, and How I Now Decide Per Site Whether to Inline
I inlined CSS into the HTML to clear PageSpeed Insights' render-blocking warning, and FCP got almost a second slower. The font preload had been pushed down to byte 28,672 of the head. Even after fixing the placement, the same change made a second site with 88KB of CSS slower, and I rolled it back. Here is a script that counts byte offsets inside the head, an inliner with a size cap, and the pattern I use on the larger site instead.