gradle 将compileSdkVersion和targetSdkVersion设置为31后出现“应用未安装”(Android 12)

au9on6nz  于 2022-11-24  发布在  Android
关注(0)|答案(2)|浏览(282)

我刚刚将我们的应用更新为以下构建设置:

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

我按照几个迁移指南,从针对android 11到现在针对android 12,我看不到任何我可能错过的东西。
有没有人遇到过这种情况,却想不出我需要做什么显而易见的事情。
我正在测试的手机 * 是 * 一个android 11手机,但这仍然不应该影响安装只是从改变目标编译版本,应该吗?
完整的Android清单. 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>
qoefvg9y

qoefvg9y1#

请在我们定义Intent过滤器的每个Activity、服务、接收器中添加android:exported=“false/true”(还请检查第三方库)。请参见下面的链接以获取开发者门户的指南。
https://developer.android.com/about/versions/12/behavior-changes-12#exported

q9rjltbz

q9rjltbz2#

步骤1:将targetSdkVersion和compileSdkVersion更改为31

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

步骤2:打开清单文件并

<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
        >

步骤3:(最重要的)打开android/app/build.gradle文件

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

相关问题