Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Expo] Could not find any matches for app.notifee:core:+ as no versions of app.notifee:core are available. #941

Closed
jp4u opened this issue Dec 21, 2023 · 16 comments

Comments

@jp4u
Copy link

jp4u commented Dec 21, 2023

I tried following the instructions here:
https://github.com/invertase/notifee/blob/main/docs-react-native/react-native/docs/installation.md

I tried following the solutions in this thread:
#350

These don't exist in my gradle-
org.gradle.parallel=true
org.gradle.configureondemand=true

I tried adding this-

maven {
            url "$rootDir/../node_modules/@notifee/react-native/android/libs"
        }

I tried following the solutions in this thread:
#911

I tried adding this-

"plugins": [
[
"expo-build-properties",
{
"android": {
"extraMavenRepos": [
"../../node_modules/@notifee/react-native/android/libs"
]
}
}
],
}

I am using react native with expo. The error message I'm getting:

FAILURE: Build failed with an exception.

* What went wrong:
Could not determine the dependencies of task ':app:processDebugResources'.
> Could not resolve all task dependencies for configuration ':app:debugRuntimeClasspath'.
   > Could not find any matches for app.notifee:core:+ as no versions of app.notifee:core are available.
     Searched in the following locations:
       - file:/Users/james/Documents/Workspace/.../apps/mobile/node_modules/@notifee/react-native/android/libs/app/notifee/core/maven-metadata.xml
       - file:/Users/james/Documents/Workspace/.../node_modules/react-native/android/app/notifee/core/maven-metadata.xml
       - file:/Users/james/Documents/Workspace/.../node_modules/jsc-android/dist/app/notifee/core/maven-metadata.xml
       - https://dl.google.com/dl/android/maven2/app/notifee/core/maven-metadata.xml
       - https://repo.maven.apache.org/maven2/app/notifee/core/maven-metadata.xml
       - https://www.jitpack.io/app/notifee/core/maven-metadata.xml
       - https://oss.sonatype.org/content/repositories/snapshots/app/notifee/core/maven-metadata.xml
     Required by:
         project :app > project :notifee_react-native

I am using expo 49, notifee 7.8.2, react native 72.6, api 34 on android

@mikehardy
Copy link
Contributor

Pathing issue perhaps

It helpfully tells you where it's looking, for example:

       - file:/Users/james/Documents/Workspace/Ultraviolet/ultraviolet-next/apps/mobile/node_modules/@notifee/react-native/android/libs/app/notifee/core/maven-metadata.xml
       - file:/Users/james/Documents/Workspace/Ultraviolet/ultraviolet-next/node_modules/react-native/android/app/notifee/core/maven-metadata.xml
       - file:/Users/james/Documents/Workspace/Ultraviolet/ultraviolet-next/node_modules/jsc-android/dist/app/notifee/core/maven-metadata.xml

What do you find when you actually look there yourself? Where is the notifee/core/maven-metadata.xml file? If you locate it and make sure that location is in the extra repos, should work...

@jp4u
Copy link
Author

jp4u commented Dec 21, 2023

Pathing issue perhaps

It helpfully tells you where it's looking, for example:

       - file:/Users/james/Documents/Workspace/Ultraviolet/ultraviolet-next/apps/mobile/node_modules/@notifee/react-native/android/libs/app/notifee/core/maven-metadata.xml
       - file:/Users/james/Documents/Workspace/Ultraviolet/ultraviolet-next/node_modules/react-native/android/app/notifee/core/maven-metadata.xml
       - file:/Users/james/Documents/Workspace/Ultraviolet/ultraviolet-next/node_modules/jsc-android/dist/app/notifee/core/maven-metadata.xml

What do you find when you actually look there yourself? Where is the notifee/core/maven-metadata.xml file? If you locate it and make sure that location is in the extra repos, should work...

Nvm it's actually NOT searching the correct folder it should be

file:/Users/james/Documents/Workspace/Ultraviolet/ultraviolet-next/node_modules/@notifee/react-native/android/libs/app/notifee/core/maven-metadata.xml

How do I configure it to search that appropriate path?

@jp4u
Copy link
Author

jp4u commented Dec 21, 2023

I tried adding this to my repositories, but its still not finding it

maven {
    url "/Users/james/Documents/Workspace/Ultraviolet/ultraviolet-next/node_modules/@notifee/react-native/android/libs"
}

@jp4u
Copy link
Author

jp4u commented Dec 22, 2023

I tried editing again by specifying the version and updated the maven url. Can you please point me how to fix this

The new error

Could not determine the dependencies of task ':app:processDebugResources'.
> Could not resolve all task dependencies for configuration ':app:debugRuntimeClasspath'.
   > Could not find app.notifee:core:202108261754.
     Searched in the following locations:
       - file:/Users/james/Documents/Workspace/Ultraviolet/ultraviolet-next/apps/mobile/node_modules/@notifee/react-native/android/libs/app/notifee/core/202108261754/core-202108261754.pom
       - file:/Users/james/Documents/Workspace/Ultraviolet/ultraviolet-next/node_modules/react-native/android/app/notifee/core/202108261754/core-202108261754.pom
       - file:/Users/james/Documents/Workspace/Ultraviolet/ultraviolet-next/node_modules/jsc-android/dist/app/notifee/core/202108261754/core-202108261754.pom
       - https://dl.google.com/dl/android/maven2/app/notifee/core/202108261754/core-202108261754.pom
       - https://repo.maven.apache.org/maven2/app/notifee/core/202108261754/core-202108261754.pom
       - https://www.jitpack.io/app/notifee/core/202108261754/core-202108261754.pom
       - https://oss.sonatype.org/content/repositories/snapshots/app/notifee/core/202108261754/core-202108261754.pom
     Required by:
         project :app > project :notifee_react-native

Gradle to specified version dependency and updated maven url


import java.nio.file.Paths

buildscript {
  // The Android Gradle plugin is only required when opening the android folder stand-alone.
  // This avoids unnecessary downloads and potential conflicts when the library is included as a
  // module dependency in an application project.
  if (project == rootProject) {
    repositories {
      google()
      mavenCentral()
    }

    dependencies {
      classpath("com.android.tools.build:gradle:7.0.3")
    }
  }
}

plugins {
  id "io.invertase.gradle.build" version "1.5"
}

// https://github.com/facebook/react-native/blob/a70354df12ef71aec08583cca4f1fed5fb77d874/ReactAndroid/build.gradle#L168-L201
def findNodeModulePath(baseDir, packageName) {
  def basePath = baseDir.toPath().normalize()
  // Node's module resolution algorithm searches up to the root directory,
  // after which the base path will be null
  while (basePath) {
    def candidatePath = Paths.get(basePath.toString(), "node_modules", packageName)
    if (candidatePath.toFile().exists()) {
      return candidatePath.toString()
    }
    basePath = basePath.getParent()
  }
  return null
}

def notifeeDir = findNodeModulePath(projectDir, "@notifee/react-native") ?: "$rootDir/../node_modules/@notifee/react-native"
println ":${project.name} @notifee/react-native found at $notifeeDir"

if (project.hasProperty('reactNativeProjects')) {
  reactNativeProjects.each { dependent ->
    project.evaluationDependsOn(dependent)
  }
} else {
  project.evaluationDependsOn(':app')
}

project.ext {
  set('react-native', [
    versions: [
      android: [
        minSdk    : 20,
        targetSdk : 33,
        compileSdk: 33,
        // optional as gradle.buildTools comes with one by default
        // overriding here though to match the version RN uses
        // buildTools: "29.0.2"
      ],
    ],
  ])
}

android {
  def agpVersion = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION
  // Check AGP version for backward compatibility w/react-native versions still on gradle plugin 6
  if (agpVersion.tokenize('.')[0].toInteger() >= 7) {
    namespace = "io.invertase.notifee"
  }

  defaultConfig {
    multiDexEnabled true
  }
  lintOptions {
    disable 'GradleCompatible'
    abortOnError false
  }
  compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
  }
  buildTypes {
    release {
      consumerProguardFiles 'proguard-rules.pro'
    }
  }
  compileSdkVersion = 33
  buildToolsVersion = '33.0.0'
}

repositories {
  google()
  mavenCentral()
}

dependencies {
  implementation 'androidx.concurrent:concurrent-futures:1.1.0' // https://developer.android.com/jetpack/androidx/releases/concurrent
  implementation 'com.google.android.gms:play-services-tasks:18.0.1' // https://developers.google.com/android/guides/releases
  implementation 'androidx.work:work-runtime:2.8.0' // https://developer.android.com/jetpack/androidx/releases/work
  implementation 'org.greenrobot:eventbus:3.3.1' // https://github.com/greenrobot/EventBus/releases
  implementation 'androidx.lifecycle:lifecycle-process:2.3.1'
  implementation "app.notifee:core:202108261754"
}

ReactNative.shared.applyPackageVersion()
ReactNative.shared.applyDefaultExcludes()
ReactNative.module.applyAndroidVersions()
ReactNative.module.applyReactNativeDependency("api")
rootProject.allprojects {
  repositories {
    maven {
        url "file:/Users/james/Documents/Workspace/Ultraviolet/ultraviolet-next/node_modules/@notifee/react-native/android/libs"
    }
  }
}

@mikehardy
Copy link
Contributor

No I can't help directly sorry, I don't use Expo. But it looks like you are attempting to use a fully-qualified path, note the attempts above were with relative paths either to ../../ etc or rootDir
Play around with those until it's pointing in the right spot where you found the file

You know where the file is
The build system is telling you where it is looking
Playing with it until those two line up should be possible ?

@jp4u
Copy link
Author

jp4u commented Dec 22, 2023

I was able to fix it by editing my app.json under expo-build properties, I modified the property extraMavenRepos

    "plugins": [
      [
        "expo-build-properties",
        {
          "android": {
            "kotlinVersion": "1.8.0",
            "minSdkVersion": 24,
            "extraMavenRepos": [
              "../../../../node_modules/@notifee/react-native/android/libs"
              ]
          },
          "ios": {
            "deploymentTarget": "13.0"
          }
        }
      ],

I needed to add extra depth to the extraMavenRepos

@mikehardy
Copy link
Contributor

@jp4u that is applicable if you are, for instance, in a monorepo and the package was hoisted. Makes sense I think

Copy link

Hello 👋, to help manage issues we automatically close stale issues.

This issue has been automatically marked as stale because it has not had activity for quite some time.Has this issue been fixed, or does it still require attention?

This issue will be closed in 15 days if no further activity occurs.

Thank you for your contributions.

@dtyrrell
Copy link

I was able to fix it by editing my app.json under expo-build properties, I modified the property extraMavenRepos

    "plugins": [
      [
        "expo-build-properties",
        {
          "android": {
            "kotlinVersion": "1.8.0",
            "minSdkVersion": 24,
            "extraMavenRepos": [
              "../../../../node_modules/@notifee/react-native/android/libs"
              ]
          },
          "ios": {
            "deploymentTarget": "13.0"
          }
        }
      ],

I needed to add extra depth to the extraMavenRepos

Thanks, this also resolved my issue - with a slight adjustment to the path:

extraMavenRepos: [
            "../../node_modules/@notifee/react-native/android/libs",
          ],

@LVExMachina
Copy link

I was able to fix it by editing my app.json under expo-build properties, I modified the property extraMavenRepos

    "plugins": [
      [
        "expo-build-properties",
        {
          "android": {
            "kotlinVersion": "1.8.0",
            "minSdkVersion": 24,
            "extraMavenRepos": [
              "../../../../node_modules/@notifee/react-native/android/libs"
              ]
          },
          "ios": {
            "deploymentTarget": "13.0"
          }
        }
      ],

I needed to add extra depth to the extraMavenRepos

I tried but I still have the same problem...

@coyksdev
Copy link

coyksdev commented Mar 12, 2024

I have this same issue with expo 50 even though I added the extraMavenRepos

update: it is now working, I just fixed the path

@LVExMachina
Copy link

I have this same issue with expo 50 even though I added the extraMavenRepos

update: it is now working, I just fixed the path

@coyksdev How did you fixed the path? It's not working for me :(

@coyksdev
Copy link

coyksdev commented Mar 12, 2024

@LVExMachina your path should start at android/build.gradle. for me it is '../../node_modules/@notifee/react-native/android/libs'

@LVExMachina
Copy link

@coyksdev Thank you!

Copy link

github-actions bot commented Apr 9, 2024

Hello 👋, to help manage issues we automatically close stale issues.

This issue has been automatically marked as stale because it has not had activity for quite some time.Has this issue been fixed, or does it still require attention?

This issue will be closed in 15 days if no further activity occurs.

Thank you for your contributions.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Apr 24, 2024
@BearingMe
Copy link

I'm feeling a little dumb for making it too complex. I came out with a plugin and a whole bunch of regex nonsense. At least it works

const { withProjectBuildGradle } = require("@expo/config-plugins");

function addNotifeeLibs(buildGradle) {
  const notifeeLibs = 'url(new File("../../node_modules/@notifee/react-native/android/libs"))';

  if (buildGradle.includes(notifeeLibs)) return buildGradle;

  const mavenRegex = /(maven\s*{[^{}]*})/s;
  const match = buildGradle.match(mavenRegex);

  if (!match) throw Error("Maven repositories not found");

  const block = match[0];
  const modifiedBlock =
    block.slice(0, -1) +
    `
    \t\t// Keep this dependecy bellow React Native sources
    \t\t${notifeeLibs}
    \t}
  `;

  return buildGradle.replace(block, modifiedBlock);
}

module.exports = function withNotifeeGradlePlugin(config) {
  return withProjectBuildGradle(config, (config) => {
    config.modResults.contents = addNotifeeLibs(config.modResults.contents);
    return config;
  });
};

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

No branches or pull requests

6 participants