简体   繁体   中英

"App not installed" after setting compileSdkVersion & targetSdkVersion to 31 (Android 12)

I just updated our app to the following build settings:

buildToolsVersion = "30.0.2"
minSdkVersion = 23
compileSdkVersion = 31
targetSdkVersion = 31
ndkVersion = "21.4.7075529"
androidXCore = "1.0.2"
playServicesVersion = "17.0.0"

And the app no longer installs with the message simply being "App not installed". I followed a couple of migration guides in order to go from targeting android 11 to now targeting android 12, and I can't see anything I might have missed.

Has anyone encountered this and can't think of something glaringly obvious I need to do.

The phone I am testing on is an android 11 phone, but that still shouldn't affect installation just from changing the target compile version, should it?

Full AndroidManifest.xml

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="uk.co.mycompany">

    <uses-permission android:name="android.permission.CAMERA" />
    <uses-permission android:name="android.permission.INTERNET" />
    
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.DOWNLOAD_WITHOUT_NOTIFICATION" />
    <uses-permission android:name="android.permission.DOWNLOAD_COMPLETE" />

    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

    <queries>
        <intent>
            <action android:name="android.intent.action.VIEW" />
            <data android:mimeType="*/*" />
        </intent>
    </queries>
    
    <application
      android:name="uk.co.mycompany.MainApplication"
      android:label="@string/app_name"
      android:icon="@mipmap/ic_launcher"
      android:roundIcon="@mipmap/ic_launcher_round"
      android:allowBackup="false"
      android:usesCleartextTraffic="true"
      android:theme="@style/BootTheme"
      android:screenOrientation="portrait"
      android:requestLegacyExternalStorage="true"
    >
      <meta-data
        android:name="com.google.android.geo.API_KEY"
        android:value="@string/GOOGLE_GEO_API_KEY"
      />
      <meta-data
        android:name="com.google.android.gms.wallet.api.enabled"
        android:value="true" 
      />
      <meta-data 
        android:name="com.facebook.sdk.ApplicationId" 
        android:value="@string/facebook_app_id"
      />

      <activity
        android:name="uk.co.mycompany.MainActivity"
        android:label="@string/app_name"
        android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode"
        android:launchMode="singleTask"
        android:windowSoftInputMode="adjustResize"
        android:exported="true">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
        <intent-filter>
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />
            <data android:scheme="mycompany" />
        </intent-filter>
      </activity>
      
      <activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
    </application>

</manifest>

please add android:exported="false/true" in every Activity, service, receiver where we define an intent filter (Please check for third party libraries also). see below link for guide line from the developer portal.

https://developer.android.com/about/versions/12/behavior-changes-12#exported

在此处输入图像描述

Step 1: change targetSdkVersion & compileSdkVersion to 31

buildscript {
    ext {
        buildToolsVersion = "30.0.2"
        minSdkVersion = 21
        compileSdkVersion = 33
        targetSdkVersion = 33    
    }
}

Step 2: open manifest file and

    <manifest
      xmlns:android="http://schemas.android.com/apk/res/android"
      package=".. "
      android:exported="true" <-- add this
    >

   <activity
      android:name=".MainActivity"
      android:label="@string/app_name"
      android:exported="true". <-- add this
    >
        <intent-filter
          android:exported="false" <-- add this
        >

Step 3: (most important) open android/app/build.gradle file

 implementation 'androidx.work:work-runtime:2.7.1' <-- add this in dependencies

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM