mrousavy / react-native-google-nearby-messages

📲 Communicate with nearby devices using Bluetooth, BLE, WiFi and near-ultrasonic audio. Broadcast and receive small payloads (like strings) using the easy-to-use React Native API!
https://mrousavy.github.io
MIT License
209 stars 33 forks source link

plugin with id 'maven' not found #114

Open NiccoloCase opened 1 year ago

NiccoloCase commented 1 year ago

Question

When using the package with Expo the command eas build --profile development --platform android fails with a series of warnings and errors.

Expo doctor:

Running "expo doctor"
- Finding all copies of expo-modules-autolinking
- Finding all copies of @expo/config-plugins
[stderr] [20:13:25] Expected package @expo/config-plugins@^5.0.0
[stderr] [20:13:25] Found invalid:
[stderr] [20:13:25]   @expo/config-plugins@4.1.5
[stderr] [20:13:25]   (for more info, run: npm why @expo/config-plugins)
- Finding all copies of @expo/prebuild-config
- Finding all copies of @unimodules/core
- Finding all copies of @unimodules/react-native-adapter
- Finding all copies of react-native-unimodules
Command "expo doctor" failed.
bash exited with non-zero code: 1

Gradlew:

[stderr] FAILURE: Build completed with 2 failures.
[stderr] 1: Task failed with an exception.
[stderr] -----------
[stderr] * Where:
[stderr] Build file '/home/expo/workingdir/build/node_modules/react-native-google-nearby-messages/android/build.gradle' line: 24
[stderr] * What went wrong:
[stderr] A problem occurred evaluating project ':react-native-google-nearby-messages'.
[stderr] > Plugin with id 'maven' not found.
[stderr] * Try:
[stderr] > Run with --stacktrace option to get the stack trace.
[stderr] > Run with --info or --debug option to get more log output.
[stderr] > Run with --scan to get full insights.
[stderr] ==============================================================================
[stderr] 2: Task failed with an exception.
[stderr] -----------
[stderr] * What went wrong:
[stderr] A problem occurred configuring project ':react-native-google-nearby-messages'.
[stderr] > compileSdkVersion is not specified. Please add it to build.gradle
[stderr] * Try:
[stderr] > Run with --stacktrace option to get the stack trace.
[stderr] > Run with --info or --debug option to get more log output.
[stderr] > Run with --scan to get full insights.
[stderr] ==============================================================================
[stderr] * Get more help at https://help.gradle.org
[stderr] BUILD FAILED in 1m 49s
Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.
You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
See https://docs.gradle.org/7.3.3/userguide/command_line_interface.html#sec:command_line_warnings
6 actionable tasks: 6 executed
Error: Gradle build failed with unknown error. See logs for the "Run gradlew" phase for more information.

This instead is the plugin that I implemented according to the package requests:

  const { AndroidConfig, withAndroidManifest } = require("@expo/config-plugins");
  const { addMetaDataItemToMainApplication, getMainApplicationOrThrow } =
    AndroidConfig.Manifest;

  module.exports = withMyCustomConfig = (config) => {
    return withAndroidManifest(config, async (config) => {
      // Modifiers can be async, but try to keep them fast.
      config.modResults = await setCustomConfigAsync(config, config.modResults);
      return config;
    });
  };

  // Splitting this function out of the mod makes it easier to test.
  async function setCustomConfigAsync(config, androidManifest) {
    const appId = "my-app-id";
    // Get the <application /> tag and assert if it doesn't exist.
    const mainApplication = getMainApplicationOrThrow(androidManifest);

    addMetaDataItemToMainApplication(
      mainApplication,
      // value for `android:name`
      "com.google.android.nearby.messages.API_KEY",
      // value for `android:value`
      "myabikey"
    );

    return androidManifest;
  }

I honestly have no idea if this is the correct implementation, help would be very welcome. Thanks in advance.

Environment

"react": 18.1.0,
"react-native": 0.70.5,
"react-native-google-nearby-messages": 1.0.22
Romoli-Gabriele commented 1 year ago

I have the same problem too. I have the same error not with Expo but with react-native init.