# react-native-apk-installer-sdk

> Install an android APK from your react-native project. This project is based on `react-native-android-library-boilerplate` and `react-native-install-apk`

Latest version **1.0.2** (published 2019-09-21) · 0 weekly downloads

## Install

```sh
npm install react-native-apk-installer-sdk
pnpm add react-native-apk-installer-sdk
yarn add react-native-apk-installer-sdk
bun add react-native-apk-installer-sdk
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2019-09-21 |
| First published | 2019-06-12 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 44.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Maintainers | yantianping |
| Keywords | react-native, android, library, apk, installer, react-native-apk-installer |

## Links

- npm: https://www.npmjs.com/package/react-native-apk-installer-sdk
- Repository: https://github.com/null--/react-native-apk-installer
- Issues: https://github.com/null--/react-native-apk-installer/issues
- npm.io page: https://npm.io/package/react-native-apk-installer-sdk

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 1.0.2 (latest) — 2019-09-21
- 1.0.1 — 2019-06-13
- 1.0.0 — 2019-06-12

## README

# React Native APK Installer

Install an android APK from your react-native project.
This project is based on `react-native-android-library-boilerplate` and `react-native-install-apk`

# Installing ApkInstaller

1. Add `react-native-apk-installer` to your project

  - Install directly from npm: `npm install --save react-native-apk-installer`.
  - Or do `npm install --save git+https://github.com/null--/react-native-apk-installer.git` in your main project.

2. Link the library:

  - Add the following to `android/settings.gradle`:

    ```
      include ':react-native-apk-installer'
      project(':react-native-apk-installer').projectDir = new File(settingsDir, '../node_modules/react-native-apk-installer/android')
    ```

  - Add the following to `android/app/build.gradle`:

    ```xml
      ...

      dependencies {
          ...
          compile project(':react-native-apk-installer')
      }
    ```

  - Add the following to `android/app/src/main/java/**/MainApplication.java`:

    ```java
      ...
      import com.cnull.apkinstaller.ApkInstallerPackage;  // add this for react-native-apk-installer

      public class MainApplication extends Application implements ReactApplication {

          @Override
          protected List<ReactPackage> getPackages() {
              return Arrays.<ReactPackage>asList(
                  new MainReactPackage(),
                  ...
                  new ApkInstallerPackage()     // add this for react-native-apk-installer
              );
          }
      }
    ```

4. Simply `import ApkInstaller from 'react-native-apk-installer'` (You might also need to install `react-native-fs` package).

  ```javascript
    import RNFS from 'react-native-fs';
    import ApkInstaller from 'react-native-apk-installer'

     try {
         var filePath = RNFS.CachesDirectoryPath + '/com.example.app.apk';
         var download = RNFS.downloadFile({
           fromUrl: 'http://example.com/com.example.app.apk',
           toFile: filePath,
           progress: res => {
               console.log((res.bytesWritten / res.contentLength).toFixed(2));
           },
           progressDivider: 1
         });

         download.promise.then(result => {
           if(result.statusCode == 200) {
             console.log(filePath);
             ApkInstaller.install(filePath);
           }
         });
     }
     catch(error) {
         console.warn(error);
     }
  ```

---
_Source: https://npm.io/package/react-native-apk-installer-sdk · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
