LoginSignup
4
2

More than 1 year has passed since last update.

【Android 12】Google Play ストアでFlutter製アプリがインストールできなかった問題を解消

Last updated at Posted at 2022-01-18

はじめに

今回Flutterで実装したアプリで、Androidユーザーから「プレイストアからアプリがインストールできないよ〜!」とフィードバックを受けまして、解消法を自分への備忘録として残しておきます。

ストアからアプリがインストールできない

dlerror

今回ユーザーからフィードバックいただいた内容として、画像のように「<アプリ名>をインストールできません」とダイアログが表示されている状態です。
インストールできない場合のガイドラインとして、Google公式では下記のような対処法を紹介しています。

  1. ストレージの空き容量を確認する
  2. データ接続を確認する
  3. SD カードを確認する
  4. ダウンロード マネージャーからキャッシュとデータを削除する
  5. Google Play 開発者サービスからキャッシュとデータを削除する
  6. Play ストアのアップデートをアンインストールして再インストールする

今回は上記内容をすべて確認してもらって、対応していただきましたが、それでもダウンロードできない。
また、自分の開発環境・Android実機(Pixel3a Android9 API Level29)の環境では再現しない。
インストールできない旨のダイアログが出るだけで、それ以上のエラーログや何らかのメッセージが出るわけでもなく苦労しました・・・:disappointed:

原因

どうやら直近のコミットで、compileSdkVersionを31に上げたことにより、Android 12の端末でビルドした際にエラーが発生していました。

エラーログ

adb: failed to install /Users/example_app/build/app/outputs/flutter-apk/app.apk: 
Failure [INSTALL_PARSE_FAILED_MANIFEST_MALFORMED: Failed parse during installPackageLI: 
/data/app/vmdl1651832701.tmp/base.apk (at Binary XML file line #49): 
com.example.example_app.MainActivity: Targeting S+ (version 31 and above) requires that an explicit value for android:exported be defined when intent filters are present]
Error launching application on sdk gphone64 x86 64.

解消法

結論として、AndroidManifestファイルにandroid:exported="true"を設定することでビルドにも成功し、Android 12ユーザーでもストアからもインストールできるようになりました。

android/app/src/main/AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="com.sample.example.example_app">
    <uses-permission android:name="android.permission.INTERNET" />
    <application
        tools:replace="android:label"
        android:usesCleartextTraffic="true" 
        android:allowBackup="false"
        android:label="@string/app_name"
        android:icon="@mipmap/ic_launcher">
        <activity
            android:exported="true" // activityタグ内に書く
            android:name=".MainActivity"

リファレンス

4
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
2