Search packages, repositories and app categories

Package detailsv0.0.3

android_package_installer

A Flutter plugin for installing Android package from apk file. Plugin uses Android Package Installer and requires minimum API Level version 21.

Android
30-day downloads
7.9K
Likes
27
Pub points
160

Install package

flutter pub add android_package_installer

Package Overview

Package selection guidance compiled from public package information, community data, and project usage.

A Flutter plugin enabling the installation of Android APK files directly from within an app. It leverages the Android Package Installer API, requiring a minimum API level of 21. This allows developers to implement in-app updates or sideloading functionality securely and efficiently. The plugin is designed specifically for Android and integrates seamlessly with Flutter applications. It simplifies the process of installing packages without relying on external tools or system intents.

Use cases

  • In-app app updates
  • Sideloading APKs
  • Automated deployment in enterprise apps
  • Updating apps via direct APK download

Key features

  • Uses native Android Package Installer
  • Supports API level 21+
  • Simple Flutter integration
  • Secure installation workflow
  • No need for external intents

Suitable for

  • Developers building update systems
  • Enterprise app developers
  • Apps requiring APK installation
  • Flutter apps targeting Android

Considerations

  • Only works on Android
  • Requires API level 21 or higher
  • Needs user permission for installation
  • Limited to APK file format
  • Does not support iOS

Original README

Original README snapshot from the linked source repository. Visit the repository for the latest content.

android_package_installer

A Flutter plugin for installing Android package from apk file. Plugin uses Android Package Installer and requires minimum API Level version 21.

Using

import 'package:android_package_installer/android_package_installer.dart';

  int? statusCode = await AndroidPackageInstaller.installApk(apkFilePath: '/sdcard/Download/com.example.apk');
  if (statusCode != null) {
    PackageInstallerStatus installationStatus = PackageInstallerStatus.byCode(statusCode);
    print(installationStatus.name);
  }

To install the Android package the application will need permissions. You can use the permission_handler package to request them.

Setup

  1. Add the permissions to your AndroidManifest.xml file in <projectDir>/android/app/src/main/AndroidManifest.xml:
    • android.permission.REQUEST_INSTALL_PACKAGES - required for installing android packages.
    • android.permission.READ_EXTERNAL_STORAGE - required to access the external storage where the apk file is located.
<manifest xmlns:tools="http://schemas.android.com/tools" ...>

  <!-- ADD THESE PERMISSIONS: -->
  <!-- Android 10 Permissions -->
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
  <!-- Android 11+ Permissions -->
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES"/>
<uses-permission
android:name="android.permission.MANAGE_EXTERNAL_STORAGE"
tools:ignore="ScopedStorage"/>
  
  <application ...>
    <activity ...>

      ...

      <!-- ADD THIS INTENT FILTER -->
      <intent-filter>
        <action android:name="com.android_package_installer.content.SESSION_API_PACKAGE_INSTALLED"/>
      </intent-filter>
    </activity>

    <!-- ADD THIS PROVIDER -->
    <provider
      android:name="androidx.core.content.FileProvider"
      android:authorities="${applicationId}"
      android:grantUriPermissions="true">
      <meta-data
        android:name="android.support.FILE_PROVIDER_PATHS"
        android:resource="@xml/file_paths"/>
    </provider>
  </application>
</manifest>
  1. Check external path in your custom paths file. If it doesn't exist, create it in <projectDir>/android/app/src/main/res/xml/file_paths.xml:
<?xml version="1.0" encoding="utf-8"?>
<paths xmlns:android="http://schemas.android.com/apk/res/android">
    <external-path name="external_files" path="."/>
</paths>

Categories

Dependencies

Dependency list 1 items

  • plugin_platform_interface^2.1.8

Source repository

Projects using this package