react native依赖项的AAR元数据中指定的minCompileSdk(31)大于此模块的compileSdkVersion(android-30)

ijnw1ujt  于 2022-11-17  发布在  React
关注(0)|答案(3)|浏览(169)

我正在使用React原生。npxReact-原生运行-android。
我有许多其他的解决方案。像强制或更新targetsdk版本和编译sdk版本,但没有任何工作。
将compileSdkVersion 30更改为compileSdkVersion 31,将targetSdkVersion 30更改为targetSdkVersion 31,谢谢
发行人
依赖项的AAR元数据(META-INF/com/android/build/gradle/aar- www.example.com)中指定的minCompileSdk(31)metadata.properties高于此模块的compileSdkVersion(android-30)。依赖项:安卓系统。应用程序兼容:应用程序兼容:1.4.1.
我的builld.gradle文件
第一个
在我添加第一个解决方案后,新的错误再次:
当对应组件定义了Intent过滤器时,面向Android 12及更高版本的应用需要为android:exported指定显式值。https://developer.android.com/guide/topics/manifest/activity-element#exported有关详细信息,请参阅www.example.com。
我清单文件

<uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <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.FOREGROUND_SERVICE"/>
    <uses-permission android:name="android.permission.WAKE_LOCK" />
    <uses-permission android:name="android.permission.VIBRATE" />
    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
    <uses-permission android:name="android.permission.CAMERA" />
    <uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />

    <application
      android:name=".MainApplication"
      android:label="@string/app_name"
      android:icon="@mipmap/ic_launcher"
      android:roundIcon="@mipmap/ic_launcher_round"
      android:usesCleartextTraffic="true"
      android:allowBackup="false"
      android:theme="@style/SplashTheme"
      android:requestLegacyExternalStorage="true"
      >
       <!-- Change the value to true to enable pop-up for in foreground on receiving remote notifications (for prevent duplicating while showing local notifications set this to false) -->
        <meta-data  android:name="com.dieam.reactnativepushnotification.notification_foreground"
                    android:value="false"/>
        <!-- Change the resource name to your App's accent color - or any other color you want -->
        <meta-data  android:name="com.dieam.reactnativepushnotification.notification_color"
                    android:resource="@color/white"/> <!-- or @android:color/{name} to use a standard color -->

        <!-- <receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationActions" />
        <receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationPublisher" />
        <receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationBootEventReceiver"  android:exported="false">
            <intent-filter>
                <action android:name="android.intent.action.BOOT_COMPLETED" />
                <action android:name="android.intent.action.QUICKBOOT_POWERON" />
                <action android:name="com.htc.intent.action.QUICKBOOT_POWERON"/>
            </intent-filter>
        </receiver> -->
        <!-- <service
            android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationListenerService"
            android:exported="false" >
            <intent-filter>
                <action android:name="com.google.firebase.MESSAGING_EVENT" />
            </intent-filter>
        </service> -->

      <!-- <service android:name="com.asterinet.react.bgactions.RNBackgroundActionsTask" /> -->
      
      <activity
        android:name=".MainActivity"
        android:exported="true"
        android:label="@string/app_name"
        android:screenOrientation="portrait"
        android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode"
        android:launchMode="singleTask"
        android:windowSoftInputMode="adjustResize"
        >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
            <action android:name="android.intent.action.DOWNLOAD_COMPLETE"/>
        </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="conveyence" />
      </intent-filter>
      </activity>
        <meta-data
      android:name="com.google.android.geo.API_KEY"
      android:value=""/>
         <!-- You will also only need to add this uses-library tag -->
      <uses-library android:name="org.apache.http.legacy" android:required="false"/>
    </application>
    

</manifest>
7uhlpewt

7uhlpewt1#

这是因为Android build issue自2022年11月4日以来。我已经通过添加几行基于线程的代码解决了这个问题。
您可以在android/buld.gradle文件的allprojects区域中添加此文件。

def REACT_NATIVE_VERSION = new File(['node', '--print',"JSON.parse(require('fs').readFileSync(require.resolve('react-native/package.json'), 'utf-8')).version"].execute(null, rootDir).text.trim())

allprojects {
    configurations.all {
        resolutionStrategy {
            // Remove this override in 0.65+, as a proper fix is included in react-native itself.
            force "com.facebook.react:react-native:" + REACT_NATIVE_VERSION
        }
    }

在我的例子中,我已经在存储库下添加了。见下文。

allprojects {
    repositories {
        google()
        mavenCentral()
    }
    configurations.all {
        resolutionStrategy {
            // Remove this override in 0.65+, as a proper fix is included in react-native itself.
            force "com.facebook.react:react-native:" + REACT_NATIVE_VERSION
        }
    }
}
ve7v8dk2

ve7v8dk23#

有两种方法可以解决这个问题
1-通过将以下版本0.63.5用于react-native。它不会影响其他库。
2-通过在android/buld.gradle文件中添加以下内容。

allprojects {
 ...old config project
//add the following
    configurations.all {
        resolutionStrategy {
       
            force "com.facebook.react:react-native:{your_reactnative_version}" 
        }
    }
}

以下链接提供了有关此问题的完整详细信息

相关问题