gpt4 book ai didi

android - minSdk兼容性错误使用react-native 0.60.0设置react-native-notifications@2.1.3

转载 作者:行者123 更新时间:2023-12-03 05:05:46 24 4
gpt4 key购买 nike

我正在尝试将推送通知系统添加到react-native项目,并且尝试使用2.1.3版本的react-native-notifications。

我的package.json文件如下所示:

"dependencies": {
"@react-native-community/async-storage": "^1.6.3",
"jetifier": "^1.6.4",
"react": "16.8.6",
"react-native": "0.60.0",
"react-native-camera": "^3.11.1",
"react-native-elements": "^1.2.7",
"react-native-gesture-handler": "^1.5.1",
"react-native-notifications": "^2.1.3",
"react-native-permissions": "^2.0.3",
"react-native-qrcode-scanner": "^1.3.1",
"react-native-vector-icons": "^6.6.0",
"react-navigation": "^1.0.0-beta.27",
"react-redux": "^5.1.2",
"redux": "^4.0.4",
"redux-thunk": "^2.3.0",
"rn-fetch-blob": "^0.10.16"
},
"devDependencies": {
"@babel/core": "7.5.0",
"@babel/runtime": "7.5.0",
"@react-native-community/eslint-config": "0.0.3",
"babel-jest": "24.8.0",
"eslint": "6.0.1",
"jest": "24.8.0",
"metro-react-native-babel-preset": "0.54.1",
"react-test-renderer": "16.8.6"
},
"jest": {
"preset": "react-native"
}
}

我的项目级别build.gradle(android / build.gradle)看起来像
buildscript {
ext {
buildToolsVersion = "28.0.3"
minSdkVersion = 16
compileSdkVersion = 28
targetSdkVersion = 28
supportLibVersion = "28.0.0"
}
repositories {
google()
jcenter()
}
dependencies {
classpath("com.android.tools.build:gradle:3.4.1")

classpath 'com.google.gms:google-services:4.3.3'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}

allprojects {
repositories {
mavenLocal()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url("$rootDir/../node_modules/react-native/android")
}
maven {
// Android JSC is installed from npm
url("$rootDir/../node_modules/jsc-android/dist")
}

google()
jcenter()
}
}
subprojects { subproject ->
afterEvaluate {
if ((subproject.plugins.hasPlugin('android') || subproject.plugins.hasPlugin('android-library'))) {
android {
variantFilter { variant ->
def names = variant.flavors*.name
if (names.contains("reactNative59")) {
setIgnore(true)
}
}
}
}
}
}

react-native-notifications版本2.1.3 android / build.gradle
buildscript {
repositories {
mavenLocal()
mavenCentral()
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath 'com.google.gms:google-services:4.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}

allprojects {
repositories {
mavenLocal()
mavenCentral()
google()
jcenter()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
}
}

react-native-notifications android / app / build.gradle
apply plugin: 'com.android.library'
apply from: '../prepare-robolectric.gradle'

android {
compileSdkVersion 27
buildToolsVersion '28.0.3'

defaultConfig {
minSdkVersion 19
targetSdkVersion 27
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
debuggable true
}
}
testOptions {
unitTests.all { t ->
reports {
html.enabled true
}
testLogging {
events "PASSED", "SKIPPED", "FAILED", "standardOut", "standardError"
}
afterSuite { desc, result ->
if (!desc.parent) { // will match the outermost suite
def output = " ${result.resultType} (${result.successfulTestCount} successes, ${result.failedTestCount} failures, ${result.skippedTestCount} skipped) "
def repeatLength = output.length()
println '\n\n' + ('-' * repeatLength) + '\n' + output + '\n' + ('-' * repeatLength) + '\n'

println "see report at file://${t.reports.html.destination}/index.html"
}
}
}
}

flavorDimensions "RNNotifications.reactNativeVersion"
productFlavors {
reactNative59 {
dimension "RNNotifications.reactNativeVersion"
}
reactNative60 {
dimension "RNNotifications.reactNativeVersion"
}
}
}

dependencies {
implementation "com.google.firebase:firebase-messaging:17.3.0"
implementation 'com.facebook.react:react-native:+'

// tests
testImplementation 'junit:junit:4.12'
testImplementation 'org.robolectric:robolectric:3.5.1'
testImplementation 'org.assertj:assertj-core:3.8.0'
testImplementation 'com.squareup.assertj:assertj-android:1.1.1'
testImplementation 'org.mockito:mockito-core:2.13.0'
}

MainApplication.java的 片段:

protected List<ReactPackage> getPackages() {
@SuppressWarnings("UnnecessaryLocalVariable")
List<ReactPackage> packages = new PackageList(this).getPackages();
// Packages that cannot be autolinked yet can be added manually here, for example:
// packages.add(new MyReactNativePackage());
return packages;
}

从PackageList.java中获取(MainApplication getPackages()返回什么)

public ArrayList<ReactPackage> getPackages() {
return new ArrayList<>(Arrays.<ReactPackage>asList(
new MainReactPackage(),
new AsyncStoragePackage(),
new RNCameraPackage(),
new RNGestureHandlerPackage(),
new RNPermissionsPackage(),
new VectorIconsPackage(),
new RNFetchBlobPackage()
));
}

我知道上面的大多数代码都是不需要的,但是我提供了以防万一。

我的问题是我的项目的minSDK版本为16,但是react-native-notifications的minSDK版本为19。在尝试构建时,得到以下输出:
* What went wrong:
Execution failed for task ':app:processDebugManifest'.
> Manifest merger failed : uses-sdk:minSdkVersion 16 cannot be smaller than version 19 declared in library [:react-native-notifications] Project-Root\node_modules\react-native-notifications\an
droid\app\build\intermediates\library_manifest\reactNative60Debug\AndroidManifest.xml as the library might be using APIs not available in 16
Suggestion: use a compatible library with a minSdk of at most 16,
or increase this project's minSdk version to at least 19,
or use tools:overrideLibrary="com.wix.reactnativenotifications" to force usage (may lead to runtime failures)

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 14s

at checkExecSyncError (child_process.js:621:11)
at execFileSync (child_process.js:639:15)
at runOnAllDevices (Project-Root\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\runOnAllDevices.js:75:39)
at buildAndRun (Project-Root\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\index.js:137:41)
at Project-Root\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\index.js:103:12
at processTicksAndRejections (internal/process/task_queues.js:93:5)
at async Command.handleAction (Project-Root\node_modules\react-native\node_modules\@react-native-community\cli\build\cliEntry.js:160:7)


我已经在线查找了解决方案,但尝试将react-native-notifications minSDK版本降低到16,但未成功。

当我尝试将项目的minSDK更改为19时,我得到
error Failed to install the app. Make sure you have the Android development environment set up: https://facebook.github.io/react-native/docs/getting-started.html#android-development-environment. Run CLI with --verbose flag for more de
tails.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
C:\Users\nvashakidze\dev\BRAND-NEW\Micromeritics-Final\android\app\build\generated\rncli\src\main\java\com\facebook\react\PackageList.java:66: error: constructor RNNotificationsPackage in class RNNotificationsPackage cannot be applied
to given types;
new RNNotificationsPackage(),
^
required: Application
found: no arguments
reason: actual and formal argument lists differ in length
1 error

如果有人可以帮助我解决此问题,我将不胜感激。

最佳答案

您必须传递应用程序上下文。作为引用,请检查此https://github.com/wix/react-native-notifications/blob/master/docs/installation.md#-android

关于android - minSdk兼容性错误使用react-native 0.60.0设置react-native-notifications@2.1.3,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59276585/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com