I'm trying to add a push notification system to a react-native project, and I an trying to use react-native-notifications version 2.1.3.
My package.json file looks like this:
"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"
}
}
My project level build.gradle(android/build.gradle) looks like
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 version 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'
}
I know most of the code above is not needed, but I provided in case I had missed something.
My problem is that my project has a minSDK version of 16 but react-native-notifications has a minSDK version of 19. When trying to build I get this output:
* 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)
I have looked up solutions online, and I unsuccessfully tried shifting react-native-notifications minSDK version down to 16.
When I try to shift my project's minSDK to 19, I get
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
If anyone can help me fix this issue, I would really appreciate it.