Skip to content
This repository has been archived by the owner on Sep 24, 2021. It is now read-only.

compileSdkVersion is not specified. Please add it to build.gradle Affected Modules: notifee_react-native #145

Closed
zaweiswise opened this issue Sep 8, 2020 · 20 comments

Comments

@zaweiswise
Copy link

zaweiswise commented Sep 8, 2020

I want to implement notifee in my react native app.
I have paste Package.json , build.gradle (both) and Metro bundler error. I have tried updating my android sdk but still get this error . It is preventing me to build my app
System info:
Package.json

{
  "name": "AppName",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "android": "react-native run-android",
    "ios": "react-native run-ios",
    "start": "react-native start",
    "test": "jest",
    "lint": "eslint ."
  },
  "dependencies": {
    "@babel/plugin-external-helpers": "^7.2.0",
    "@babel/polyfill": "^7.6.0",
    **`"@notifee/react-native": "^0.12.3",`**
    "@react-native-community/async-storage": "^1.7.1",
    "@react-native-community/datetimepicker": "^2.6.0",
    "@react-native-community/geolocation": "^2.0.2",
    "@react-native-community/masked-view": "^0.1.6",
    "@react-native-community/netinfo": "^5.9.6",
    "@react-native-firebase/app": "^8.3.1",
    "@react-native-firebase/crashlytics": "^8.3.3",
    "emoji-utils": "^1.0.1",
    "es6-symbol": "^3.1.3",
    "i18n-js": "^3.5.1",
    "libphonenumber-js": "^1.7.29",
    "lodash": "^4.17.15",
    "moment": "^2.24.0",
    "native-base": "^2.13.12",
    "prop-types": "^15.7.2",
    "react": "16.11.0",
    "react-native": "0.62.2",
    "react-native-animatable": "^1.3.3",
    "react-native-background-timer": "^2.2.0",
    "react-native-calendars": "^1.269.0",
    "react-native-color-picker": "^0.5.2",
    "react-native-contacts": "^5.2.0",
    "react-native-country-picker-modal": "^1.9.8",
    "react-native-dialogbox": "^0.6.10",
    "react-native-document-picker": "^3.4.0",
    "react-native-draggable-flatlist": "^2.3.2",
    "react-native-exit-app": "^1.1.0",
    "react-native-fast-image": "^7.0.2",
    "react-native-geolocation-service": "^4.0.0",
    "react-native-gesture-handler": "^1.6.0",
    "react-native-google-places-autocomplete": "^1.7.2",
    "react-native-image-crop-picker": "^0.32.2",
    "react-native-image-picker": "^1.1.0",
    "react-native-linear-gradient": "^2.5.6",
    "react-native-localize": "^1.4.0",
    "react-native-maps": "0.26.1",
    "react-native-modal-datetime-picker": "^7.5.0",
    "react-native-modalize": "^1.3.6",
    "react-native-modals": "^0.19.9",
    "react-native-onesignal": "^3.9.0",
    "react-native-orientation": "^3.1.3",
    "react-native-paper": "^3.6.0",
    "react-native-raw-bottom-sheet": "^2.0.6",
    "react-native-reanimated": "^1.7.0",
    "react-native-responsive-fontsize": "^0.4.2",
    "react-native-restart": "0.0.15",
    "react-native-safe-area-context": "^0.7.3",
    "react-native-screens": "^2.0.0-alpha.29",
    "react-native-swift": "^1.2.3",
    "react-native-swipeout": "^2.3.6",
    "react-native-thumbnail-video": "^0.1.2",
    "react-native-touch-id": "^4.4.1",
    "react-native-track-player": "^1.2.3",
    "react-native-vector-icons": "^6.6.0",
    "react-native-webview": "^10.7.0",
    "react-native-youtube": "^2.0.1",
    "react-navigation": "^4.0.10",
    "react-navigation-props-mapper": "^1.0.2",
    "react-navigation-stack": "^2.0.16",
    "react-navigation-tabs": "^2.7.0",
    "react-navigation-transitions": "^1.0.12",
    "react-redux": "^7.2.0",
    "recyclerlistview": "^3.0.0",
    "redux": "^4.0.5",
    "redux-persist": "^6.0.0",
    "redux-saga": "^1.1.3",
    "rn-fetch-blob": "^0.12.0",
    "underscore": "^1.9.2"
  },
  "devDependencies": {
    "@babel/core": "^7.6.2",
    "@babel/runtime": "^7.6.2",
    "@react-native-community/eslint-config": "^0.0.5",
    "babel-jest": "^24.9.0",
    "eslint": "^6.5.1",
    "jest": "^24.9.0",
    "metro-react-native-babel-preset": "^0.58.0",
    "react-test-renderer": "16.11.0",
    "@babel/plugin-proposal-decorators": "^7.6.0",
    "@babel/preset-flow": "^7.0.0",
    "babel-core": "^6.26.3",
    "babel-eslint": "^10.0.3",
    "babel-plugin-transform-remove-console": "^6.9.4",
    "babel-runtime": "^6.26.0",
    "jetifier": "^1.6.4"
  },
  "jest": {
    "preset": "react-native"
  }
}

build.gradle (project)

buildscript {
    ext {
        buildToolsVersion = "29.0.2"
        minSdkVersion = 16
        compileSdkVersion = 29
        targetSdkVersion = 29
        supportLibVersion = "28.0.0"
        playServicesVersion = "17.0.0" 
        androidMapsUtilsVersion = "2.0.1"
    }
    repositories {
        google()
        jcenter()
        maven {
            url 'https://maven.fabric.io/public'
        }
    }
    dependencies {
        classpath 'com.google.gms:google-services:4.3.3'
        classpath('com.android.tools.build:gradle:4.0.1')
        classpath 'com.google.firebase:firebase-crashlytics-gradle:2.2.0'

        // 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()
        maven { url 'https://www.jitpack.io' }
    }
}

**build.gradle (app)**
buildscript {
    repositories {
        maven { url 'https://plugins.gradle.org/m2/' } // Gradle Plugin Portal
    }
    dependencies {
        classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:[0.12.6, 0.99.99]'
    }
}
apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'
apply plugin: "com.android.application"
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.google.firebase.crashlytics'

import com.android.build.OutputFile

/**
 * The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets
 * and bundleReleaseJsAndAssets).
 * These basically call `react-native bundle` with the correct arguments during the Android build
 * cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the
 * bundle directly from the development server. Below you can see all the possible configurations
 * and their defaults. If you decide to add a configuration block, make sure to add it before the
 * `apply from: "../../node_modules/react-native/react.gradle"` line.
 *
 * project.ext.react = [
 *   // the name of the generated asset file containing your JS bundle
 *   bundleAssetName: "index.android.bundle",
 *
 *   // the entry file for bundle generation. If none specified and
 *   // "index.android.js" exists, it will be used. Otherwise "index.js" is
 *   // default. Can be overridden with ENTRY_FILE environment variable.
 *   entryFile: "index.android.js",
 *
 *   // https://facebook.github.io/react-native/docs/performance#enable-the-ram-format
 *   bundleCommand: "ram-bundle",
 *
 *   // whether to bundle JS and assets in debug mode
 *   bundleInDebug: false,
 *
 *   // whether to bundle JS and assets in release mode
 *   bundleInRelease: true,
 *
 *   // whether to bundle JS and assets in another build variant (if configured).
 *   // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants
 *   // The configuration property can be in the following formats
 *   //         'bundleIn${productFlavor}${buildType}'
 *   //         'bundleIn${buildType}'
 *   // bundleInFreeDebug: true,
 *   // bundleInPaidRelease: true,
 *   // bundleInBeta: true,
 *
 *   // whether to disable dev mode in custom build variants (by default only disabled in release)
 *   // for example: to disable dev mode in the staging build type (if configured)
 *   devDisabledInStaging: true,
 *   // The configuration property can be in the following formats
 *   //         'devDisabledIn${productFlavor}${buildType}'
 *   //         'devDisabledIn${buildType}'
 *
 *   // the root of your project, i.e. where "package.json" lives
 *   root: "../../",
 *
 *   // where to put the JS bundle asset in debug mode
 *   jsBundleDirDebug: "$buildDir/intermediates/assets/debug",
 *
 *   // where to put the JS bundle asset in release mode
 *   jsBundleDirRelease: "$buildDir/intermediates/assets/release",
 *
 *   // where to put drawable resources / React Native assets, e.g. the ones you use via
 *   // require('./image.png')), in debug mode
 *   resourcesDirDebug: "$buildDir/intermediates/res/merged/debug",
 *
 *   // where to put drawable resources / React Native assets, e.g. the ones you use via
 *   // require('./image.png')), in release mode
 *   resourcesDirRelease: "$buildDir/intermediates/res/merged/release",
 *
 *   // by default the gradle tasks are skipped if none of the JS files or assets change; this means
 *   // that we don't look at files in android/ or ios/ to determine whether the tasks are up to
 *   // date; if you have any other folders that you want to ignore for performance reasons (gradle
 *   // indexes the entire tree), add them here. Alternatively, if you have JS files in android/
 *   // for example, you might want to remove it from here.
 *   inputExcludes: ["android/**", "ios/**"],
 *
 *   // override which node gets called and with what additional arguments
 *   nodeExecutableAndArgs: ["node"],
 *
 *   // supply additional arguments to the packager
 *   extraPackagerArgs: []
 * ]
 */

project.ext.react = [
    entryFile: "index.js",
    enableHermes: false,  // clean and rebuild if changing
]

apply from: "../../node_modules/react-native/react.gradle"

/**
 * Set this to true to create two separate APKs instead of one:
 *   - An APK that only works on ARM devices
 *   - An APK that only works on x86 devices
 * The advantage is the size of the APK is reduced by about 4MB.
 * Upload all the APKs to the Play Store and people will download
 * the correct one based on the CPU architecture of their device.
 */
def enableSeparateBuildPerCPUArchitecture = false

/**
 * Run Proguard to shrink the Java bytecode in release builds.
 */
def enableProguardInReleaseBuilds = false

/**
 * The preferred build flavor of JavaScriptCore.
 *
 * For example, to use the international variant, you can use:
 * `def jscFlavor = 'org.webkit:android-jsc-intl:+'`
 *
 * The international variant includes ICU i18n library and necessary data
 * allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that
 * give correct results when using with locales other than en-US.  Note that
 * this variant is about 6MiB larger per architecture than default.
 */
def jscFlavor = 'org.webkit:android-jsc:+'

/**
 * Whether to enable the Hermes VM.
 *
 * This should be set on project.ext.react and mirrored here.  If it is not set
 * on project.ext.react, JavaScript will not be compiled to Hermes Bytecode
 * and the benefits of using Hermes will therefore be sharply reduced.
 */
def enableHermes = project.ext.react.get("enableHermes", false);

android {

    dexOptions {
        javaMaxHeapSize "4g"
    }

    compileSdkVersion targetSdkVersion

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    defaultConfig {
        applicationId "com.appName"
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        versionCode 2
        versionName "2.0"
        multiDexEnabled true
    }
    splits {
        abi {
            reset()
            enable enableSeparateBuildPerCPUArchitecture
            universalApk false  // If true, also generate a universal APK
            include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
        }
    }
    signingConfigs {
        debug {
            storeFile file('debug.keystore')
            storePassword 'android'
            keyAlias 'androiddebugkey'
            keyPassword 'android'
        }
    }
    buildTypes {
        debug {
            signingConfig signingConfigs.debug
        }
        release {
            // Caution! In production, you need to generate your own keystore file.
            // see https://facebook.github.io/react-native/docs/signed-apk-android.
            signingConfig signingConfigs.debug
            minifyEnabled enableProguardInReleaseBuilds
            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
        }
    }

    packagingOptions {
        pickFirst "lib/armeabi-v7a/libc++_shared.so"
        pickFirst "lib/arm64-v8a/libc++_shared.so"
        pickFirst "lib/x86/libc++_shared.so"
        pickFirst "lib/x86_64/libc++_shared.so"
    }
    buildToolsVersion '29.0.2'

    // applicationVariants are e.g. debug, release
    applicationVariants.all { variant ->
        variant.outputs.each { output ->
            // For each separate APK per architecture, set a unique version code as described here:
            // https://developer.android.com/studio/build/configure-apk-splits.html
            def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4]
            def abi = output.getFilter(OutputFile.ABI)
            if (abi != null) {  // null for the universal-debug, universal-release variants
                output.versionCodeOverride =
                        versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
            }

        }
    }
}

dependencies {
    implementation fileTree(dir: "libs", include: ["*.jar"])
    //noinspection GradleDynamicVersion
    implementation "com.facebook.react:react-native:+"  // From node_modules
    implementation 'com.google.firebase:firebase-analytics:17.2.2'
    implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0"
    implementation 'com.facebook.fresco:fresco:2.0.0'
    implementation 'com.facebook.fresco:animated-gif:2.0.0'
    implementation 'com.facebook.fresco:animated-webp:1.10.0'
    implementation 'com.facebook.fresco:webpsupport:1.10.0'
    implementation 'com.facebook.fresco:webpsupport:1.10.0'
    
    implementation(project(':react-native-maps')){
       exclude group: 'com.google.android.gms', module: 'play-services-base'
       exclude group: 'com.google.android.gms', module: 'play-services-maps'
   }
   implementation 'com.google.android.gms:play-services-base:17.2.1'
   implementation 'com.google.android.gms:play-services-maps:17.0.0'

    debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") {
      exclude group:'com.facebook.fbjni'
    }

    debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
        exclude group:'com.facebook.flipper'
    }

    debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") {
        exclude group:'com.facebook.flipper'
    }

    if (enableHermes) {
        def hermesPath = "../../node_modules/hermes-engine/android/";
        debugImplementation files(hermesPath + "hermes-debug.aar")
        releaseImplementation files(hermesPath + "hermes-release.aar")
    } else {
        implementation jscFlavor
    }
}

// Run this once to be able to run the application with BUCK
// puts all compile dependencies into folder libs for BUCK to use
task copyDownloadableDepsToLibs(type: Copy) {
    from configurations.compile
    into 'libs'
}

apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)

Metro-bundler error

\android\app\build\generated\rncli\src\main\java\com\facebook\react\PackageList.java:123: error: cannot find symbol
      new NotifeePackage(),
          ^
  symbol:   class NotifeePackage
  location: class PackageList
Note: D:\Projects\(appName)\android\app\src\debug\java\com\(appName)\ReactNativeFlipper.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
2 errors

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.

* 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 52s
@zaweiswise zaweiswise reopened this Sep 8, 2020
@mikehardy
Copy link
Collaborator

@zaweiswise I added formatting to your post so it's easier to read - you may use triple back-ticks ('```') to enclose large code blocks in markdown and especially if you add a language specifier you get great, syntax highlighted results even

To your problem:

    defaultConfig {
        applicationId "com.appName"
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        versionCode 2
        versionName "2.0"
        multiDexEnabled true
    }

This is a block from android/build.gradle, you should add compileSdkVersion rootProject.ext.compileSdkVersion there and it should work?

Please let us know how it goes

@burhanDebug
Copy link

I am also having the same issue when Sync Project with Gradle file it says

compileSdkVersion is not specified. Please add it to build.gradle
Affected Modules: notifee_react-native

and when i build project it gives this error

android/app/build/generated/rncli/src/main/java/com/facebook/react/PackageList.java:15: error: package io.invertase.notifee does not exist
import io.invertase.notifee.NotifeePackage;
                           ^

Screenshot 2020-09-08 at 9 57 29 PM

Please resolve this issue as soon as possible i have already added rootProject.ext.compileSdkVersion in android/build.gradle and my default config look likes

 defaultConfig {
        applicationId "com.appName"
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        compileSdkVersion rootProject.ext.compileSdkVersion
        versionCode 2
        versionName "2.0"
        multiDexEnabled true
    }

i have also tried downgrading the library but got no success

@mikehardy
Copy link
Collaborator

Okay, you have added that in the defaultConfig block but @burhanDebug you are jumping on someone else's issue and I don't know what you have in the top-level build.config ext block. So I don't know if they relate.

I can tell you that I use notifee in my work project and it is compiling successfully, so this is not a "fix your module" problem.

This is a "you have not integrated the module successfully and we are troubleshooting your project-specific problem" problem. Please shift to that perspective and maintain the idea that you need to examine your build.gradle files very carefully, as the solution will be changes to them, not to the module.

@burhanDebug
Copy link

@mikehardy my gradle files project level and app level are exactly same
My package.json file is also almost same having same react native version i am also successfully using One Signal Library and firebase crashlytics with the same version posted by @zaweiswise
Could you please look into it now

But when i create a new React native blank project Notifee installed successfully and project runs without any issue

Is there any conflicts with One Signal libray or firebase crashlytics ?

@mikehardy
Copy link
Collaborator

There should not be an incompatibility

I want to focus on this line:

But when i create a new React native blank project Notifee installed successfully and project runs without any issue

That matches my experience - fresh projects (and my work project) build fine. We can't reproduce this, so I don't know what is going on.

If you could publish a repository that reproduces this, we could investigate. When I do web searches it is a bunch of vague answers (in my opinion) that might help but all indicate something not-well-understood is happening. Without a reproduction we'll be lost here I'm afraid

https://stackoverflow.com/questions/59357028/android-error-cause-compilesdkversion-is-not-specified

@zaweiswise
Copy link
Author

zaweiswise commented Sep 9, 2020

@mikehardy I have implemented your solution but didn't get any success. I am getting same issue as @burhanDebug has pointed. I am really stuck at this point. Please try to troubleshoot this issue. Also check the similar issue that is already closed without any solution .Issue #124
Here is the repository link from where you can reproduce the same error.
https://github.com/zaweiswise/notifee-bug.git

@mikehardy
Copy link
Collaborator

@zaweiswise I do not believe #124 has bearing though I am watching that as well.
Thanks for attempting a reproduction - I see your invite to that repo and I'll clone it and investigate

@mikehardy
Copy link
Collaborator

mikehardy commented Sep 9, 2020

@zaweiswise I am unable to make that project work, but I noticed several odd things about it - the settings.gradle contains all sorts of unnecessary things and MainApplication has unneeded imports as well, plus many of the dependencies are very out of date. Every person's project is special to them but as a maintainer it is extremely inefficient to go into projects like that and attempt to find out why the project is broken.

What I did after seeing that was to make a quick script that takes every single one of your package.json dependencies and adds them all to a demonstrator project.

It compiles fine. In a clean project with all your dependencies, I cannot reproduce

#!/bin/bash
set -e 

# Basic template create, rnfb install, link
\rm -fr notifeedemo

echo "Testing react-native current + @notifee/react-native current"

npx react-native init notifeedemo --version="0.62.2"
cd notifeedemo

# # I have problems in my country with the cocoapods CDN sometimes, use github directly
# sed -i -e $'s/def add_flipper_pods/source \'https:\/\/github.com\/CocoaPods\/Specs.git\'\\\n\\\ndef add_flipper_pods/' ios/Podfile
# rm -f ios/Podfile.??

# Add notifee package
echo "Installing Notifee package"
yarn add @notifee/react-native

# Installing a pile of other packages to test compilation
yarn add \
  @react-native-community/async-storage \
  @react-native-community/datetimepicker \
  @react-native-community/geolocation \
  @react-native-community/masked-view \
  @react-native-community/netinfo \
  @react-native-firebase/app \
  @react-native-firebase/crashlytics \
  emoji-utils \
  es6-symbol \
  i18n-js \
  libphonenumber-js \
  lodash \
  moment \
  native-base \
  prop-types \
  react-native-animatable \
  react-native-background-timer \
  react-native-calendars \
  react-native-color-picker \
  react-native-contacts \
  react-native-country-picker-modal \
  react-native-dialogbox \
  react-native-document-picker \
  react-native-draggable-flatlist \
  react-native-exit-app \
  react-native-fast-image \
  react-native-geolocation-service \
  react-native-gesture-handler \
  react-native-google-places-autocomplete \
  react-native-image-crop-picker \
  react-native-image-picker \
  react-native-linear-gradient \
  react-native-localize \
  react-native-maps \
  react-native-modal-datetime-picker \
  react-native-modalize \
  react-native-modals \
  react-native-onesignal \
  react-native-orientation \
  react-native-paper \
  react-native-raw-bottom-sheet \
  react-native-reanimated \
  react-native-responsive-fontsize \
  react-native-restart \
  react-native-safe-area-context \
  react-native-screens \
  react-native-swift \
  react-native-swipeout \
  react-native-thumbnail-video \
  react-native-touch-id \
  react-native-track-player \
  react-native-vector-icons \
  react-native-webview \
  react-native-youtube \
  react-navigation \
  react-navigation-props-mapper \
  react-navigation-stack \
  react-navigation-tabs \
  react-navigation-transitions \
  react-redux \
  recyclerlistview \
  redux \
  redux-persist \
  redux-saga \
  rn-fetch-blob \
  underscore

# Copy in our demonstrator App.js
# echo "Copying demonstrator App.js"
# rm ./App.js && cp ../App.js ./App.js

# Set the Java application up for multidex (needed for API<21 w/Firebase)
echo "Configuring Android MultiDex for API<21 support - gradle toggle, library dependency, Application object inheritance"
sed -i -e $'s/defaultConfig {/defaultConfig {\\\n        multiDexEnabled true/' android/app/build.gradle
rm -f android/app/build.gradle??
sed -i -e $'s/dependencies {/dependencies {\\\n    implementation "androidx.multidex:multidex:2.0.1"/' android/app/build.gradle
rm -f android/app/build.gradle??
sed -i -e $'s/import android.app.Application;/import androidx.multidex.MultiDexApplication;/' android/app/src/main/java/com/notifeedemo/MainApplication.java
rm -f android/app/src/main/java/com/notifeedemo/MainApplication.java??
sed -i -e $'s/extends Application/extends MultiDexApplication/' android/app/src/main/java/com/notifeedemo/MainApplication.java
rm -f android/app/src/main/java/com/notifeedemo/MainApplication.java??

# Another Java build tweak - or gradle runs out of memory during the build
echo "Increasing memory available to gradle for android java build"
echo "org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8" >> android/gradle.properties

# In case we have any patches
# echo "Running any patches necessary to compile successfully"
# cp -rv ../patches .
# npx patch-package

# Run the thing for iOS
if [ "$(uname)" == "Darwin" ]; then
  echo "Installing pods and running iOS app"
  cd ios && pod install --repo-update && cd ..
  npx react-native run-ios
  # workaround for poorly setup Android SDK environments
  USER=`whoami`
  echo "sdk.dir=/Users/$USER/Library/Android/sdk" > android/local.properties
fi

echo "Configuring Android release build for ABI splits and code shrinking"
sed -i -e $'s/def enableSeparateBuildPerCPUArchitecture = false/def enableSeparateBuildPerCPUArchitecture = true/' android/app/build.gradle
rm -f android/app/build.gradle??
sed -i -e $'s/def enableProguardInReleaseBuilds = false/def enableProguardInReleaseBuilds = true/' android/app/build.gradle
rm -f android/app/build.gradle??
sed -i -e $'s/universalApk false/universalApk true/' android/app/build.gradle
rm -f android/app/build.gradle??

# Run it for Android (assumes you have an android emulator running)
echo "Running android app"
npx react-native run-android --variant release

# Let it start up, then uninstall it (otherwise ABI-split-generated version codes will prevent debug from installing)
sleep 10
pushd android
./gradlew uninstallRelease
popd

# may or may not be commented out, depending on if have an emulator available
# I run it manually in testing when I have one, comment if you like
npx react-native run-android

@zaweiswise
Copy link
Author

@mikehardy I created a new project updated all my project dependencies and build it again still the issue was same.
Now:
#124 As @ashokkumar88 suggested the library certainly has some issues with OneSignal or vice versa.
so as @ashokkumar88 suggested : 'Onesignal gradle plugin mentioned in their documentation. After removing this plugin the build was successful.'
This solved the error. I also configured my previous project it also worked without any issue. So the issue was not with the outdated libraries. It was Onesignal conflict with notifee. I hope you will fix that issue and make an alternate solution for that.

@mikehardy
Copy link
Collaborator

We will are doing everything according to Android docs, the troubleshooting difficulties were because we have nothing to do. It's my understanding from the other issue that one signal has work to do, and that is out of our control. We can document this though, it's very helpful to know that an incompatibility in a popular library exists and now we have a workaround - a lot of value in that

@mikehardy
Copy link
Collaborator

OneSignal integration docs changed here - working on getting them out to the live site now, thanks for helping figure this out! notifee/documentation@7249b1d

@N0v1a
Copy link

N0v1a commented Aug 4, 2021

IMG_20210804_064346.jpg

Can anyone please help me...

@N0v1a
Copy link

N0v1a commented Aug 4, 2021

IMG_20210804_064503.jpg

And this too

@mikehardy
Copy link
Collaborator

@N0v1a - not enough for anyone to help - https://stackoverflow.com/help/minimal-reproducible-example

@N0v1a
Copy link

N0v1a commented Aug 7, 2021

IMG_20210806_045356.jpg

This is the error

@N0v1a
Copy link

N0v1a commented Aug 7, 2021

apply plugin: 'com.android.application'
apply plugin: 'com.chaquo.python'
buildscript {
ext.kotlin_version = "1.5.21"
repositories {
google()
mavenCentral()
maven { url "https://chaquo.com/maven" }
//noinspection JcenterRepositoryObsolete
}
dependencies {
//noinspection AndroidGradlePluginVersion
classpath 'com.android.tools.build:gradle:4.1.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "com.chaquo.python:gradle:9.1.0"

}

}

allprojects {
repositories {
google()
mavenCentral()
//noinspection JcenterRepositoryObsolete
jcenter()

}

}

//task clean(type: Delete) {
// delete rootProject.buildDir
//}

@N0v1a
Copy link

N0v1a commented Aug 7, 2021

↓my build.gradle(:app)

@N0v1a
Copy link

N0v1a commented Aug 7, 2021

plugins {
id 'com.android.application'
id 'kotlin-android'
}

android {
compileSdkVersion 30
buildToolsVersion "30.0.3"

defaultConfig {
    applicationId "com.nova.chmlimp"
    minSdkVersion 16
    targetSdkVersion 30
    versionCode 1
    versionName "1.0"

    testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    ndk {
        abiFilters "armeabi-v7a", "x86"
    }
    python {
        buildPython "C:/Users/Sayan/AppData/Local/Programs/Python/Python37-32/python.exe"
    }
    sourceSets {
        main {
            python.srcDir ["src/main/python"]
        }
    }
}

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
    }
}
compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
    jvmTarget = '1.8'
}

}

dependencies {

implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.6.0'
implementation 'androidx.appcompat:appcompat:1.3.1'
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.0'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'

}

@mikehardy
Copy link
Collaborator

Start with this: https://github.com/mikehardy/rnfbdemo/blob/master/make-demo.sh
It works
Add what you need to until it breaks, post that as a repo

@AmirDiafi
Copy link

This happens to me when I upgrade the Gradle version.
what I did is I uninstall the library and clean, then install it again, and boom its works as sharp.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants