Skip to main content

How to Make a Weather App

Copied to clipboard!
No boilerplate memorization required

How to Vibe Code a Native Android Weather App

Stay in your creative flow. Direct AI models with atmospheric design intent, stitch together a Jetpack Compose weather station with condition-reactive sky gradients, hourly carousels, 5-day range bars, and zero-key Open-Meteo sync in under 30 minutes.

Core Stack

Kotlin Compose

Weather Feed

Open-Meteo / JSON

AI Partner

Claude / Gemini

Target Time

20–30 Mins

The Philosophy

The Vibe Coding Mobile Philosophy

Traditional Android weather tutorials spend two hours configuring Retrofit interceptors, Gson adapters, and runtime location permissions before drawing a single cloud on screen. Vibe coding flips the priority: you design the atmospheric sky gradients, hourly forecast strip, multi-day range bars, and environmental metric tiles first with AI, and then wire live JSON feeds on demand.

Old-School Mobile Stress

  • Waiting for paid API keys to activate before testing UI layouts.
  • Writing 15 nested DTO data classes for a simple temperature readout.
  • Getting stuck when the Android Emulator returns null GPS coordinates.
  • Boring static text lists that don't reflect sunny, rainy, or sub-arctic skies.

The Vibe Coder Way

  • Prompt AI for dynamic Compose sky gradients that shift by weather condition.
  • Switch between curated global cities and Β°C / Β°F units with a single tap.
  • Render hourly forecast carousels, multi-day high/low bars, and Wind/Humidity/UV tiles.
  • Fetch real live forecasts via the free, zero-key Open-Meteo REST endpoint.
Execution

The 4-Step Blueprint

From an empty Android Studio project to a rich atmospheric weather dashboard.

Step 01

Empty Compose Setup

Create a fresh Empty Activity (Compose) project in Android Studio named VibeWeather. Standard Compose gradients and cards handle all atmospheric visuals.

πŸ’‘ Pro Vibe Tip: Pre-load 3 distinct cities (e.g., Sunny Coast, Evening Rain, Sub-Arctic Snow) so you can preview every sky palette immediately.
Step 02

Configure Your Forecast

Pick your weather aesthetic, data source, and environmental widgets in the configurator below, then paste the prompt into Claude or Gemini.

πŸ”‘ Key Constraint: Keep temperatures in Celsius internally and convert via a single helper function when the user toggles Β°F.
Step 03

Single-File Drop-In

Paste the generated code into MainActivity.kt to test multi-city switching, Β°C/Β°F conversion, hourly strips, and 5-day range bars.

✨ Iteration Secret: Use translucent dark glass cards (Color.Black.copy(alpha = 0.28f)) so white text stays crisp over any sky gradient.
Step 04

Connect Live Open-Meteo

Use the Prompt Vault below to attach live Open-Meteo HTTP fetching, Canvas rain/snow animations, and worldwide city geocoding.

πŸ† The Grand Payoff: A fast, ad-free weather station on your phone with zero API key setup or tracking.
Interactive Tool

Vibe Prompt Configurator

Select your atmospheric UI style, forecast data engine, and environmental telemetry tiles. Copy the generated prompt directly into Claude, Cursor, or Gemini.

Special Feature Vibe
Optional custom details added straight into your master prompt.
Generated Master Prompt
Ready to paste into Claude, Gemini, or ChatGPT Single-file Compose ready
Product Spec

Essential Elements of a Weather App

A great weather app turns raw meteorological telemetry into an instant visual snapshot. Make sure your app covers these 6 core elements:

  • Reliable Weather API Integration

    Connect to fast meteorological endpoints like Open-Meteo (zero API key required) or OpenWeatherMap with graceful offline caching.

  • Current Conditions Snapshot

    Lead with a bold current temperature readout, "Feels Like" apparent temperature, condition summary, and daily High/Low bounds.

  • Hourly & Multi-Day Forecast

    Pair a horizontal 24-hour forecast carousel with a 5-to-7 day outlook featuring visual min-to-max temperature range bars.

  • Precipitation & Radar Outlook

    Highlight rain and snow probability percentages on both hourly slots and daily rows so users know when to carry an umbrella.

  • Wind Speed, Humidity & Pressure

    Organize wind speed and cardinal direction, relative humidity percentage, UV index, and hPa barometric pressure into a clean 2x2 bento grid.

  • Multi-City Switcher & Unit Toggle

    Let users switch between saved cities around the world and toggle seamlessly between Celsius (Β°C) and Fahrenheit (Β°F).

UX Checklist Before Shipping: Transition the full-screen background gradient to match the selected city's sky condition, and keep all forecast cards inside translucent dark containers so white text remains legible.
Starter Template

The "Golden" Single-File Compose Template

Replace the contents of your MainActivity.kt with this to run a working Weather Station App right now.

app/src/main/java/.../MainActivity.kt
Kotlin + Compose
package com.example.vibeweather

import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.LazyRow
import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.*
import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Brush
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import kotlin.math.roundToInt

data class HourlySlot(val time: String, val icon: String, val tempC: Int, val rainProb: Int)
data class DailyForecast(val day: String, val icon: String, val lowC: Int, val highC: Int, val rainProb: Int)

data class CityWeather(
    val name: String,
    val condition: String,
    val icon: String,
    val tempC: Int,
    val feelsLikeC: Int,
    val windKmh: Int,
    val windDir: String,
    val humidity: Int,
    val uvIndex: String,
    val pressureHpa: Int,
    val skyColors: List<Color>,
    val hourly: List<HourlySlot>,
    val daily: List<DailyForecast>
)

class MainActivity : ComponentActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContent {
            MaterialTheme(colorScheme = darkColorScheme()) {
                WeatherDashboardScreen()
            }
        }
    }
}

@Composable
fun WeatherDashboardScreen() {
    val cities = remember {
        listOf(
            CityWeather(
                name = "San Francisco",
                condition = "Crisp Coastal Breeze",
                icon = "β›…",
                tempC = 19,
                feelsLikeC = 18,
                windKmh = 22,
                windDir = "WNW",
                humidity = 68,
                uvIndex = "6 High",
                pressureHpa = 1016,
                skyColors = listOf(Color(0xFF0F172A), Color(0xFF1E3A8A), Color(0xFF0284C7)),
                hourly = listOf(
                    HourlySlot("Now", "β›…", 19, 10),
                    HourlySlot("14:00", "β˜€οΈ", 21, 5),
                    HourlySlot("16:00", "β˜€οΈ", 20, 5),
                    HourlySlot("18:00", "πŸŒ₯", 17, 15),
                    HourlySlot("20:00", "πŸŒ™", 14, 20)
                ),
                daily = listOf(
                    DailyForecast("Today", "β›…", 12, 21, 10),
                    DailyForecast("Fri", "β˜€οΈ", 13, 23, 0),
                    DailyForecast("Sat", "🌧", 11, 16, 75),
                    DailyForecast("Sun", "🌀", 12, 19, 15),
                    DailyForecast("Mon", "β˜€οΈ", 14, 22, 5)
                )
            ),
            CityWeather(
                name = "Tokyo",
                condition = "Neon Evening Rain",
                icon = "🌧",
                tempC = 15,
                feelsLikeC = 13,
                windKmh = 18,
                windDir = "ENE",
                humidity = 88,
                uvIndex = "2 Low",
                pressureHpa = 1008,
                skyColors = listOf(Color(0xFF090D16), Color(0xFF1E1B4B), Color(0xFF312E81)),
                hourly = listOf(
                    HourlySlot("Now", "🌧", 15, 85),
                    HourlySlot("21:00", "🌧", 14, 80),
                    HourlySlot("23:00", "🌦", 13, 50),
                    HourlySlot("01:00", "☁️", 12, 25),
                    HourlySlot("03:00", "πŸŒ™", 12, 10)
                ),
                daily = listOf(
                    DailyForecast("Today", "🌧", 12, 16, 85),
                    DailyForecast("Fri", "🌀", 11, 20, 20),
                    DailyForecast("Sat", "β˜€οΈ", 14, 24, 5),
                    DailyForecast("Sun", "β˜€οΈ", 15, 25, 10),
                    DailyForecast("Mon", "β›…", 13, 21, 30)
                )
            ),
            CityWeather(
                name = "Reykjavik",
                condition = "Sub-Arctic Clear",
                icon = "❄️",
                tempC = 2,
                feelsLikeC = -3,
                windKmh = 31,
                windDir = "NNE",
                humidity = 74,
                uvIndex = "1 Low",
                pressureHpa = 1024,
                skyColors = listOf(Color(0xFF042F2E), Color(0xFF0F766E), Color(0xFF0E7490)),
                hourly = listOf(
                    HourlySlot("Now", "❄️", 2, 40),
                    HourlySlot("15:00", "🌨", 1, 60),
                    HourlySlot("17:00", "☁️", 0, 30),
                    HourlySlot("19:00", "🌌", -1, 10),
                    HourlySlot("21:00", "🌌", -2, 5)
                ),
                daily = listOf(
                    DailyForecast("Today", "❄️", -2, 3, 60),
                    DailyForecast("Fri", "🌌", -4, 1, 10),
                    DailyForecast("Sat", "🌨", -3, 2, 70),
                    DailyForecast("Sun", "β›…", -1, 4, 20),
                    DailyForecast("Mon", "β˜€οΈ", 0, 5, 10)
                )
            )
        )
    }

    var selectedCity by remember { mutableStateOf(cities.first()) }
    var useFahrenheit by remember { mutableStateOf(false) }

    fun formatTemp(c: Int): String {
        val value = if (useFahrenheit) (c * 9.0 / 5.0 + 32.0).roundToInt() else c
        return "$valueΒ°${if (useFahrenheit) "F" else "C"}"
    }

    Box(
        modifier = Modifier
            .fillMaxSize()
            .background(Brush.verticalGradient(selectedCity.skyColors))
    ) {
        LazyColumn(
            modifier = Modifier.fillMaxSize().padding(16.dp),
            verticalArrangement = Arrangement.spacedBy(14.dp)
        ) {
            // Top City Switcher & Unit Toggle
            item {
                Row(
                    modifier = Modifier.fillMaxWidth(),
                    horizontalArrangement = Arrangement.SpaceBetween,
                    verticalAlignment = Alignment.CenterVertically
                ) {
                    LazyRow(horizontalArrangement = Arrangement.spacedBy(8.dp), modifier = Modifier.weight(1f)) {
                        items(cities) { city ->
                            FilterChip(
                                selected = city.name == selectedCity.name,
                                onClick = { selectedCity = city },
                                label = { Text(city.name, color = Color.White, fontSize = 12.sp) }
                            )
                        }
                    }
                    Spacer(modifier = Modifier.width(8.dp))
                    FilledTonalButton(
                        onClick = { useFahrenheit = !useFahrenheit },
                        contentPadding = PaddingValues(horizontal = 12.dp, vertical = 6.dp)
                    ) {
                        Text(if (useFahrenheit) "Β°F" else "Β°C", fontWeight = FontWeight.ExtraBold)
                    }
                }
            }

            // Hero Current Weather Snapshot
            item {
                Column(
                    modifier = Modifier.fillMaxWidth().padding(vertical = 8.dp),
                    horizontalAlignment = Alignment.CenterHorizontally
                ) {
                    Text(selectedCity.name, fontSize = 28.sp, fontWeight = FontWeight.ExtraBold, color = Color.White)
                    Text("${selectedCity.icon} ${selectedCity.condition}", fontSize = 15.sp, color = Color.White.copy(alpha = 0.85f))
                    Spacer(modifier = Modifier.height(6.dp))
                    Text(formatTemp(selectedCity.tempC), fontSize = 64.sp, fontWeight = FontWeight.ExtraBold, color = Color.White)
                    val today = selectedCity.daily.first()
                    Text(
                        text = "Feels like ${formatTemp(selectedCity.feelsLikeC)} β€’ H: ${formatTemp(today.highC)}  L: ${formatTemp(today.lowC)}",
                        fontSize = 13.sp,
                        color = Color.White.copy(alpha = 0.8f)
                    )
                }
            }

            // Hourly Forecast Strip
            item {
                Surface(
                    color = Color.Black.copy(alpha = 0.28f),
                    shape = RoundedCornerShape(20.dp),
                    modifier = Modifier.fillMaxWidth()
                ) {
                    Column(modifier = Modifier.padding(14.dp)) {
                        Text("HOURLY FORECAST", fontSize = 11.sp, fontWeight = FontWeight.Bold, color = Color.White.copy(alpha = 0.7f))
                        Spacer(modifier = Modifier.height(10.dp))
                        LazyRow(horizontalArrangement = Arrangement.spacedBy(18.dp)) {
                            items(selectedCity.hourly) { slot ->
                                Column(horizontalAlignment = Alignment.CenterHorizontally) {
                                    Text(slot.time, fontSize = 12.sp, color = Color.White.copy(alpha = 0.85f))
                                    Spacer(modifier = Modifier.height(6.dp))
                                    Text(slot.icon, fontSize = 22.sp)
                                    Text("πŸ’§${slot.rainProb}%", fontSize = 10.sp, color = Color(0xFF38BDF8), fontWeight = FontWeight.Bold)
                                    Spacer(modifier = Modifier.height(4.dp))
                                    Text(formatTemp(slot.tempC), fontSize = 14.sp, fontWeight = FontWeight.Bold, color = Color.White)
                                }
                            }
                        }
                    }
                }
            }

            // 5-Day Forecast Range Card
            item {
                Surface(
                    color = Color.Black.copy(alpha = 0.28f),
                    shape = RoundedCornerShape(20.dp),
                    modifier = Modifier.fillMaxWidth()
                ) {
                    Column(modifier = Modifier.padding(14.dp), verticalArrangement = Arrangement.spacedBy(10.dp)) {
                        Text("5-DAY OUTLOOK", fontSize = 11.sp, fontWeight = FontWeight.Bold, color = Color.White.copy(alpha = 0.7f))
                        selectedCity.daily.forEach { d ->
                            Row(
                                modifier = Modifier.fillMaxWidth(),
                                verticalAlignment = Alignment.CenterVertically,
                                horizontalArrangement = Arrangement.SpaceBetween
                            ) {
                                Text(d.day, modifier = Modifier.width(54.dp), fontSize = 14.sp, fontWeight = FontWeight.SemiBold, color = Color.White)
                                Text("${d.icon} ${d.rainProb}%", modifier = Modifier.width(64.dp), fontSize = 12.sp, color = Color(0xFF38BDF8))
                                Text(formatTemp(d.lowC), fontSize = 13.sp, color = Color.White.copy(alpha = 0.7f))
                                Box(
                                    modifier = Modifier
                                        .weight(1f)
                                        .padding(horizontal = 10.dp)
                                        .height(6.dp)
                                        .clip(RoundedCornerShape(3.dp))
                                        .background(Brush.horizontalGradient(listOf(Color(0xFF38BDF8), Color(0xFFFBBF24))))
                                )
                                Text(formatTemp(d.highC), fontSize = 13.sp, fontWeight = FontWeight.Bold, color = Color.White)
                            }
                        }
                    }
                }
            }

            // 2x2 Environmental Telemetry Bento Grid
            item {
                Column(verticalArrangement = Arrangement.spacedBy(10.dp)) {
                    Row(horizontalArrangement = Arrangement.spacedBy(10.dp), modifier = Modifier.fillMaxWidth()) {
                        TelemetryTile("πŸ’¨ WIND", "${selectedCity.windKmh} km/h", "Direction: ${selectedCity.windDir}", Modifier.weight(1f))
                        TelemetryTile("πŸ’§ HUMIDITY", "${selectedCity.humidity}%", "Dew point steady", Modifier.weight(1f))
                    }
                    Row(horizontalArrangement = Arrangement.spacedBy(10.dp), modifier = Modifier.fillMaxWidth()) {
                        TelemetryTile("β˜€οΈ UV INDEX", selectedCity.uvIndex, "Protection advised", Modifier.weight(1f))
                        TelemetryTile("🧭 PRESSURE", "${selectedCity.pressureHpa} hPa", "Barometer steady", Modifier.weight(1f))
                    }
                }
            }
        }
    }
}

@Composable
fun TelemetryTile(label: String, value: String, subtitle: String, modifier: Modifier = Modifier) {
    Surface(
        color = Color.Black.copy(alpha = 0.28f),
        shape = RoundedCornerShape(18.dp),
        modifier = modifier
    ) {
        Column(modifier = Modifier.padding(14.dp)) {
            Text(label, fontSize = 10.sp, fontWeight = FontWeight.Bold, color = Color.White.copy(alpha = 0.7f))
            Spacer(modifier = Modifier.height(6.dp))
            Text(value, fontSize = 20.sp, fontWeight = FontWeight.ExtraBold, color = Color.White)
            Spacer(modifier = Modifier.height(2.dp))
            Text(subtitle, fontSize = 11.sp, color = Color.White.copy(alpha = 0.75f))
        }
    }
}
Troubleshooting

How to Debug Weather API & Location Glitches

Keep network weather fetches and emulator GPS testing smooth with these three fixes:

NetworkOnMainThreadException

Always run HTTP forecast fetches inside withContext(Dispatchers.IO) and declare Internet permission: <uses-permission android:name="android.permission.INTERNET" />

Null Location on Android Emulator

Fresh emulators often lack a cached last location. Provide a default city fallback so the UI never hangs: "If FusedLocationProviderClient.lastLocation is null, fall back to San Francisco (37.7749, -122.4194)."

Low Contrast on Bright Sky Gradients

Wrap forecast cards in semi-transparent dark glass surfaces so white typography stays legible over any sky color: Surface(color = Color.Black.copy(alpha = 0.28f), shape = RoundedCornerShape(20.dp))

Extensions

The Vibe Prompt Vault

Copy-paste prompts to connect live zero-key Open-Meteo forecasts, animated Canvas rain/snow particles, and worldwide city search.

🌐 Prompt: Connect Live Zero-Key Open-Meteo Forecast API
Prompt Template

"Add a suspend function fetchOpenMeteoForecast(lat: Double, lon: Double) using Dispatchers.IO and HttpURLConnection to query 'https://api.open-meteo.com/v1/forecast?latitude=$lat&longitude=$lon&current_weather=true&hourly=temperature_2m,precipitation_probability&daily=temperature_2m_max,temperature_2m_min&timezone=auto'. Parse the response with org.json.JSONObject and update WeatherDashboardScreen live."

🌧️ Prompt: Add Animated Canvas Raindrops, Snowflakes & Sun Rays
Prompt Template

"Create a background WeatherParticleCanvas Composable using rememberInfiniteTransition. When the selected city's condition is Rain, draw falling diagonal raindrop streaks; when Snow, draw drifting translucent snowflakes; when Sunny, draw a pulsing radial sun glow in the top corner."

πŸ” Prompt: Add Worldwide City Search with Open-Meteo Geocoding API
Prompt Template

"Add a 'Search City' button that opens a search dialog querying 'https://geocoding-api.open-meteo.com/v1/search?name=$query&count=5'. When the user taps a result, fetch its live Open-Meteo weather forecast and add the city to the top LazyRow switcher."

We use cookies for ads and analytics.