Skip to content

Repository files navigation

Android WebView App - Configurable Education Website

A modern Android application built with Kotlin and Jetpack Compose that wraps any website in a WebView. Specifically optimized for WordPress-based education websites.

Features

  • Kotlin & Jetpack Compose: Modern Android development with declarative UI
  • Wide SDK Support: Compatible with Android 5.0 (API 21) and above, covering ~99% of devices
  • Responsive Design: Automatically adapts to all screen sizes (phones, tablets, foldables)
  • WordPress Optimized: Full support for WordPress features including:
    • JavaScript execution
    • Cookies and session management
    • LocalStorage
    • File uploads and downloads
    • Media playback
    • Form submissions
  • Easy Configuration: Change website URL in a single config file
  • Offline Caching: Intelligent caching for better performance
  • Back Button Support: Native Android back button navigates through web history

Project Structure

AdiClasses/
├── app/
│   ├── build.gradle.kts          # App-level dependencies and config
│   ├── proguard-rules.pro         # ProGuard configuration
│   └── src/
│       └── main/
│           ├── AndroidManifest.xml              # App manifest with permissions
│           ├── java/com/yourcompany/webviewapp/
│           │   ├── MainActivity.kt              # Main activity with WebView
│           │   └── ui/theme/                    # Compose UI theme files
│           │       ├── Theme.kt
│           │       ├── Color.kt
│           │       └── Type.kt
│           └── res/
│               ├── values/
│               │   ├── config.xml               # ⭐ CONFIGURATION FILE ⭐
│               │   └── themes.xml
│               └── xml/
│                   ├── backup_rules.xml
│                   └── data_extraction_rules.xml
├── build.gradle.kts              # Project-level build config
├── settings.gradle.kts           # Project settings
├── gradle.properties             # Gradle properties
└── README.md                     # This file

Quick Start Guide

1. Configure Your Website

Edit the configuration file at app/src/main/res/values/config.xml:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <!-- Change this URL to your website -->
    <string name="website_url">https://www.yourwebsite.com</string>

    <!-- Change the app name -->
    <string name="app_name">Your Education App</string>

    <!-- Allow external links to open in WebView (true/false) -->
    <bool name="allow_external_links">false</bool>

    <!-- Enable file downloads (true/false) -->
    <bool name="enable_downloads">true</bool>
</resources>

2. Customize Package Name (Optional)

To change the package name from com.yourcompany.webviewapp:

  1. Open app/build.gradle.kts
  2. Change namespace and applicationId to your desired package name
  3. Update the package declaration in all .kt files

3. Add App Icon (Optional)

Replace the default launcher icons:

  • Place your app icon in app/src/main/res/mipmap-*/ic_launcher.png
  • Or use Android Studio's Image Asset tool (Right-click res → New → Image Asset)

4. Build the App

Using Android Studio:

  1. Open the project folder in Android Studio
  2. Wait for Gradle sync to complete
  3. Click "Run" or press Shift+F10

Using Command Line:

# Debug build
./gradlew assembleDebug

# Release build (for production)
./gradlew assembleRelease

The APK will be generated in:

  • Debug: app/build/outputs/apk/debug/app-debug.apk
  • Release: app/build/outputs/apk/release/app-release.apk

System Requirements

Development:

  • Android Studio Hedgehog (2023.1.1) or newer
  • JDK 11 or newer
  • Gradle 8.7+

Runtime:

  • Minimum SDK: Android 5.0 (API 21)
  • Target SDK: Android 15 (API 35)
  • Device Coverage: ~99% of active Android devices

WordPress Compatibility

This app is specifically configured for WordPress websites with:

  • JavaScript: Fully enabled for dynamic content
  • Cookies: Persistent login sessions
  • DOM Storage: LocalStorage and SessionStorage support
  • File Uploads: Camera and gallery access for media uploads
  • Downloads: Automatic file download handling
  • Responsive Design: Viewport configuration for mobile optimization
  • Mixed Content: Allows both HTTP and HTTPS resources
  • Media Playback: Auto-play support for videos and audio

Permissions Explained

The app requests the following permissions:

  • INTERNET: Required for loading website content
  • ACCESS_NETWORK_STATE: Check if device is online
  • WRITE_EXTERNAL_STORAGE: File downloads (Android 9 and below only)
  • CAMERA: For photo/video uploads through website forms
  • READ_MEDIA_IMAGES/VIDEO: Access media files on Android 13+

Configuration Options

Allow External Links

Set allow_external_links to:

  • false (recommended): Only URLs from your domain open in the app
  • true: All links open in the WebView

Enable Downloads

Set enable_downloads to:

  • true (recommended): Users can download files from the website
  • false: Disable file downloads

Advanced Customization

Modify WebView Settings

Edit MainActivity.kt at line ~84 to customize:

  • Zoom controls
  • Cache behavior
  • User agent string
  • JavaScript settings

Change Theme Colors

Edit app/src/main/java/com/yourcompany/webviewapp/ui/theme/Color.kt to customize app colors

Add Splash Screen

  1. Create a new Activity for splash screen
  2. Set it as the launcher activity in AndroidManifest.xml
  3. Navigate to MainActivity after delay

Troubleshooting

Website Not Loading

  • Check internet connection
  • Verify URL in config.xml is correct and includes https://
  • Check if website is accessible in a regular browser

Login Not Persisting

  • Ensure cookies are enabled (they are by default)
  • Check if website uses third-party cookies

Downloads Not Working

  • Verify enable_downloads is set to true in config.xml
  • Check storage permissions are granted
  • Ensure Android Download Manager is enabled

Screen Size Issues

  • The app uses responsive viewport settings by default
  • Website should have responsive meta tags
  • Test on different screen sizes

Gradle Distribution Download Error

If you see an error like "Could not create parent directory for lock file" or Gradle cannot download:

Solution 1: Change Gradle User Home (Recommended)

  1. In Android Studio, go to File → Settings (or Ctrl+Alt+S)
  2. Navigate to Build, Execution, Deployment → Build Tools → Gradle
  3. Under "Gradle user home", change it to a directory where you have write permissions
    • Example: C:\Users\YourUsername\.gradle
  4. Click Apply and OK
  5. Click File → Sync Project with Gradle Files

Solution 2: Run Android Studio as Administrator

  1. Close Android Studio
  2. Right-click on Android Studio icon
  3. Select "Run as administrator"
  4. Reopen the project

Solution 3: Set GRADLE_USER_HOME Environment Variable

  1. Open System Environment Variables
  2. Create new variable: GRADLE_USER_HOME = C:\Users\YourUsername\.gradle
  3. Restart Android Studio

Building for Production

  1. Generate Signing Key:
keytool -genkey -v -keystore my-release-key.keystore -alias my-key-alias -keyalg RSA -keysize 2048 -validity 10000
  1. Configure Signing in app/build.gradle.kts:
signingConfigs {
    create("release") {
        storeFile = file("my-release-key.keystore")
        storePassword = "your-password"
        keyAlias = "my-key-alias"
        keyPassword = "your-password"
    }
}
  1. Build Release APK:
./gradlew assembleRelease

Publishing to Google Play Store

  1. Build a signed release APK
  2. Create a Google Play Developer account ($25 one-time fee)
  3. Create a new app listing
  4. Upload the APK
  5. Fill in store listing details (description, screenshots, etc.)
  6. Submit for review

Support

For issues or questions:

  • Check the troubleshooting section
  • Review Android WebView documentation
  • Test website in mobile browser first

License

This is a template project. You can use it freely for your education website.

Technical Stack

  • Language: Kotlin 2.0.0
  • UI Framework: Jetpack Compose
  • Build System: Gradle 8.13 with Kotlin DSL
  • Android Gradle Plugin: 8.13.1
  • WebView Library: Accompanist WebView 0.34.0
  • Material Design: Material 3 (Material You)
  • Minimum API: 21 (Android 5.0 Lollipop)
  • Target API: 34 (Android 14)

Credits

Created for educational website deployment with minimal development costs.

About

Adis Classes app

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages