A simple starter template that turns any website into an Android app!
This template creates an Android app that displays your website inside a native app wrapper. Think of it like putting a website inside a phone app - it looks and feels like a regular Android app, but it shows your web content.
Perfect for:
- Turning your website into a downloadable Android app
- Creating a simple mobile app without learning Android development
- Testing mobile versions of websites
- Building app prototypes quickly
- Full-screen WebView display
- Automatic URL loading on app start
- JavaScript and DOM storage support
- Progress indicator during page loads
- Error handling with retry functionality
- Back navigation support within WebView
- State preservation on configuration changes
- HTTPS support with network security configuration
Checklist - make sure you have these ready:
- Android Studio installed (download free from https://developer.android.com/studio)
- A website URL (if using Option 1) OR HTML files (if using Option 2)
- 10-30 minutes for first-time setup (downloads required)
- Optional: An Android phone or emulator for testing
Don't have Android Studio yet?
- Download it from the official website
- Install it (the installer handles everything)
- Open it once and let it complete setup
- Come back to this guide when ready!
-
Open the project in Android Studio
-
Find the file: In the left panel, navigate to
app > java > com.example.webviewpixel > MainActivity.kt -
Edit the URL: Scroll to the bottom of the file (around line 297), you'll see this line:
private const val HARDCODED_URL = "https://example.com"
Pro tip: Press
Ctrl+F(Windows/Linux) orCmd+F(Mac) and search for "HARDCODED_URL" to jump straight to it! -
Replace the URL: Change
https://example.comto your website's addressprivate const val HARDCODED_URL = "https://yourwebsite.com"
-
Run the app: Click the green play button in Android Studio
That's it! Your app will now load your website when it opens.
Instead of loading a website from the internet, you can include HTML/CSS/JavaScript files inside the app.
Step-by-Step Instructions:
-
Find the website folder (it already exists!):
- In the left panel, navigate to
app > src > main > assets > website - This folder is already created for you
- In the left panel, navigate to
-
Add your website files:
- Copy your HTML, CSS, and JavaScript files into the
websitefolder - Important: Your main file must be named
index.html - You can drag and drop files directly into Android Studio
- Copy your HTML, CSS, and JavaScript files into the
-
Your folder structure should look like:
app/ └── src/ └── main/ └── assets/ └── website/ ├── index.html ← Your main HTML file (required!) ├── css/ ← Optional: your CSS files │ └── style.css ├── js/ ← Optional: your JavaScript files │ └── app.js └── images/ ← Optional: your images └── logo.png -
Run the app: Click the green play button
How it works: The app automatically checks if you have local files. If index.html exists in the assets folder, it loads those files. Otherwise, it loads the website URL from Option 1.
To use this project, you need:
-
Android Studio (version Hedgehog 2023.1.1 or newer)
- Download from: https://developer.android.com/studio
- It's free and includes everything you need
-
A computer running Windows, Mac, or Linux
-
Basic knowledge of using your computer (opening files, copying/pasting)
What these technical terms mean:
- Minimum SDK: API 24: Your app works on Android 7.0 and newer phones (covers 99%+ of devices)
- Target SDK: API 34: Your app is designed for and tested on Android 14
- Kotlin: The programming language used (don't worry, you don't need to learn it!)
Good news - you don't need to install Java! Android Studio comes with its own built-in Java Development Kit (JDK), so you don't need to install Java separately. Just install Android Studio and you're ready to go!
Follow these simple steps:
-
Open the project
- Launch Android Studio
- Click "Open an Existing Project"
- Navigate to where you saved this project and select it
- Click "OK"
-
Wait for setup to complete
- Android Studio will automatically download necessary tools
- Look for the progress bar at the bottom saying "Gradle Build Running..."
- This may take 5-15 minutes on first run (depending on your internet)
⚠️ Don't interrupt this process!
-
Check for problems
- If you see a red banner at the top about SDK location
- Click the "Install SDK" button that appears
- Android Studio will guide you through it
-
Build your app
- In the top menu:
Build > Make Project - Wait for "BUILD SUCCESSFUL" message at the bottom
- In the top menu:
-
Run your app
- Connect your Android phone with USB (or use the emulator)
- Click the green
▶️ play button in the toolbar - Or press
Shift + F10on Windows/Linux,Control + Ron Mac
Tips:
- First build takes longer, subsequent builds are much faster
- If something goes wrong, try
File > Invalidate Caches > Invalidate and Restart
If you prefer using the terminal/command prompt:
# Build debug APK
./gradlew assembleDebug
# Build release APK
./gradlew assembleRelease
# Install on connected device
./gradlew installDebugapp/
├── src/main/
│ ├── java/com/example/webviewpixel/
│ │ └── MainActivity.kt # Main activity with WebView configuration
│ ├── res/
│ │ ├── layout/
│ │ │ └── activity_main.xml # Main UI layout
│ │ ├── values/
│ │ │ ├── colors.xml # Color definitions
│ │ │ ├── strings.xml # String resources
│ │ │ ├── themes.xml # App theme
│ │ │ └── styles.xml # Custom styles
│ │ ├── xml/
│ │ │ └── network_security_config.xml # Network security configuration
│ │ ├── drawable/ # Image resources
│ │ └── mipmap-*/ # Launcher icons (auto-generated)
│ └── AndroidManifest.xml # App manifest with permissions
└── build.gradle.kts # App-level build configuration
assets/
├── logo.png # Your app logo (add this!)
├── generate_icons.py # Icon generation script
└── README.md # Detailed customization guide
The app requires the following permissions:
INTERNET- To load web contentACCESS_NETWORK_STATE- To check network connectivity
The easy way - automatic icon generation:
-
Prepare your logo
- Get a square image (PNG works best)
- Recommended size: 1024x1024 pixels
- Simple, clean logos work best
-
Add your logo file
- Put your logo file here:
assets/logo.png - Just replace the existing logo.png file
- Put your logo file here:
-
Run the icon generator
- Windows: Double-click
generate-icons.bat - Mac/Linux: Double-click
generate-icons.shor run it from terminal - Any OS: Run
python assets/generate_icons.pyin your terminal
- Windows: Double-click
-
Build your app
- The generator automatically creates all the different icon sizes
- Just click the green play button in Android Studio
What the generator creates for you:
- ✅ App icons for all phone screen sizes
- ✅ Special adaptive icons for modern Android phones
- ✅ Splash screen image (shown while app loads)
- ✅ Monochrome icons for Android 13+
Requirements:
- Python must be installed on your computer
- Install the imaging library:
pip install Pillow
Manual customization (if you prefer doing it yourself): See assets/README.md
Make your app show your chosen name instead of "WebViewPixel":
- In Android Studio, find:
app > src > main > res > values > strings.xml - Look for this line:
<string name="app_name">WebViewPixel</string>
- Change
WebViewPixelto your app name:<string name="app_name">My Awesome App</string>
- Rebuild the app and the new name will appear on your phone!
Customize the colors used throughout your app:
- Find:
app > src > main > res > values > colors.xml - You'll see color definitions like:
<color name="splash_background">#FFFFFF</color>
- Change the color codes (hex values) to your preferred colors
- Use a color picker tool to find hex codes
- Example:
#FF5733= red-orange,#3498DB= blue
- Key colors you can change:
splash_background- Background color while app loadssplash_icon_background- Color behind your icon during loading
The package name (currently com.example.webviewpixel) is your app's unique identifier. It's important to change this before publishing to the Google Play Store.
Step-by-Step Instructions:
-
Open the refactor tool
- In Android Studio, click on the package name in the Project panel:
app > java > com.example.webviewpixel - Or click directly on the folder name in the left panel
- In Android Studio, click on the package name in the Project panel:
-
Start the refactor
- Right-click on the package name (folder)
- Select
Refactor > Rename... - Or press
Shift + F6on Windows/Linux,Fn + Shift + F6on Mac
-
Choose rename scope
- Select
Rename package - Click
Renamebutton
- Select
-
Enter your new package name
- Use reverse domain notation:
com.yourcompany.yourappname - Example:
com.mycompany.mywebsite - Format rules:
- Must be all lowercase
- Use dots to separate parts
- No spaces or special characters
- Usually follows:
com.[company].[appname]
- Use reverse domain notation:
-
Confirm the changes
- Android Studio will show you a preview of all files that will be changed
- Review the changes to make sure everything looks correct
- Click
Do Refactor
-
Wait for Gradle sync
- Android Studio will automatically sync the project
- Wait for "Gradle sync finished" message at the bottom
What this changes:
- ✅ Package name in all your source files
- ✅
applicationIdin build.gradle.kts - ✅
namespacein build.gradle.kts - ✅ All imports and references throughout the project
Common package name examples:
com.google.maps→ Google's Maps appcom.instagram.android→ Instagramcom.mycompany.myapp→ Your company's app
Update your app's version number when you release updates:
-
Find the version file:
app > build.gradle.kts(in the Project panel, it's under "Gradle Scripts") -
Look for these lines (around line 14-15):
versionCode = 1 versionName = "1.0"
-
Update the version numbers:
-
versionCode: A whole number that must increase with each release
- Start at 1, then 2, 3, 4, etc.
- Google Play uses this to detect updates
- Example:
versionCode = 2(for your second release)
-
versionName: A string that users see (can be anything you want)
- Typically uses semantic versioning:
major.minor.patch - Examples:
"1.0","1.1","2.0","1.0.1" - Example:
versionName = "1.1"(for a minor update)
- Typically uses semantic versioning:
-
-
Version number examples:
// First release versionCode = 1 versionName = "1.0" // Bug fix release versionCode = 2 versionName = "1.0.1" // New feature release versionCode = 3 versionName = "1.1" // Major update versionCode = 4 versionName = "2.0"
-
Rebuild the app after making changes
Version Number Tips:
- versionCode must always increase - never reuse old numbers
- versionName is for humans - make it meaningful (e.g., "1.0 - First Release", "1.1 - New Features")
- Common versioning strategy:
1.0.0= First major release1.0.1= Bug fix1.1.0= New features2.0.0= Major update/redesign
What it looks like: Red banner at top of Android Studio saying "Gradle sync failed"
Try these fixes (in order):
- Check your internet connection - Gradle needs to download files
- Wait longer - First-time setup can take 10-15 minutes
- Try again:
File > Sync Project with Gradle Files - Clean and rebuild:
Build > Clean Project, thenBuild > Rebuild Project - Check SDK location:
File > Settings > Appearance & Behavior > System Settings > Android SDK- Make sure an SDK path is selected
- If not, click "Edit" and let Android Studio install it
What it looks like: App opens briefly then closes, or you see "Unfortunately, [App] has stopped"
Try these fixes:
-
Check your URL (if using Option 1):
- Make sure the website address is correct
- Test the URL in your regular browser first
- Make sure it starts with
https://orhttp://
-
Check your index.html (if using Option 2):
- Make sure you have an
index.htmlfile inapp/src/main/assets/website/ - Try opening it in a browser to make sure it works
- Make sure you have an
-
View error messages:
- In Android Studio, click the "Logcat" tab at the bottom
- Look for red text showing what went wrong
- Copy the error message and search for it online
What it looks like: App opens but shows white screen or loading spinner forever
Try these fixes:
-
Test your internet connection:
- Open your phone's web browser
- Try loading any website
- If it doesn't work, check your Wi-Fi or mobile data
-
Check the URL in MainActivity.kt:
- Make sure it's exactly right (no typos!)
- Test it in a regular web browser first
-
Clear app data:
- On your phone:
Settings > Apps > [Your App] > Storage > Clear Data - Then try reopening the app
- On your phone:
Where to get help:
- Search for your error message on Google or Stack Overflow
- Check the official Android documentation: https://developer.android.com/guide/webapps/webview
- Make sure you're using the latest version of Android Studio
Q: Can I put this app on the Google Play Store? A: Yes! Once you've customized it with your content, you can publish it. You'll need a Google Play Developer account ($25 one-time fee).
Q: Do I need to know how to code? A: Not for basic usage! If you just want to wrap a website, you only need to change the URL in MainActivity.kt. For more advanced features, some programming knowledge helps.
Q: Will this work on all Android phones? A: It works on Android 7.0 and newer, which covers 99%+ of active Android devices.
Q: Can I use this for commercial purposes? A: Yes! This project is open source under the MIT License, which allows commercial use.
Q: The app loads slowly. What can I do? A: This usually depends on your website's speed. Try optimizing your website for mobile, or consider using local files (Option 2) for instant loading.
Q: Can I add a custom loading screen? A: The app includes a default loading indicator. For a custom splash screen, use the icon generator tool mentioned above.
Q: Does the app work offline? A: Only if you use Option 2 (local files). If loading from a website, internet connection is required.
Q: How do I update my website in the app? A: If using Option 1 (website URL), just update your website normally - the app will automatically show the latest version. If using Option 2 (local files), you'll need to rebuild the app with updated files.
This project is open source and available under the MIT License. You're free to use it for personal or commercial projects.
- Official Android WebView Documentation: https://developer.android.com/guide/webapps/webview
- Android Studio User Guide: https://developer.android.com/studio/intro
- Search for help: Try searching your question on Google or Stack Overflow