react-native-nearby-api icon indicating copy to clipboard operation
react-native-nearby-api copied to clipboard

Java.lang.NoClassDefFoundError: com.google.android.gms.nearby.messages.Message

Open butchmarshall opened this issue 8 years ago • 5 comments

Tried to use the module but doesn't seem to work with my config.

Any ideas?

MainApplication.java:


import com.facebook.react.ReactApplication;
import com.badfeatures.nearby.RNNearbyApiPackage;
import fr.bamlab.rnimageresizer.ImageResizerPackage;
import com.imagepicker.ImagePickerPackage;
import io.invertase.firebase.RNFirebasePackage;
import io.invertase.firebase.messaging.RNFirebaseMessagingPackage;
import io.invertase.firebase.analytics.RNFirebaseAnalyticsPackage;
//import io.invertase.firebase.admob.RNFirebaseAdMobPackage;
import com.mapbox.rctmgl.RCTMGLPackage;
import org.devio.rn.splashscreen.SplashScreenReactPackage;
import com.idehub.Billing.InAppBillingBridgePackage;
import com.react.rnspinkit.RNSpinkitPackage;
import com.RNFetchBlob.RNFetchBlobPackage;
import com.learnium.RNDeviceInfo.RNDeviceInfo;
import com.rnfs.RNFSPackage;
import com.rnziparchive.RNZipArchivePackage;
import com.tradle.react.UdpSocketsModule;
import com.peel.react.TcpSocketsModule;
import com.bitgo.randombytes.RandomBytesPackage;
import com.lugg.ReactNativeConfig.ReactNativeConfigPackage;
import com.oblador.vectoricons.VectorIconsPackage;
import com.corbt.keepawake.KCKeepAwakePackage;
import com.facebook.react.ReactInstanceManager;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage;
import com.facebook.soloader.SoLoader;
import com.wix.interactable.Interactable;

import com.facebook.react.modules.network.ReactCookieJarContainer;
import com.facebook.stetho.Stetho;
import okhttp3.OkHttpClient;
import com.facebook.react.modules.network.OkHttpClientProvider;
import com.facebook.stetho.okhttp3.StethoInterceptor;
import java.util.concurrent.TimeUnit;

import java.util.Arrays;
import java.util.List;

public class MainApplication extends Application implements ReactApplication {

  private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
    @Override
    public boolean getUseDeveloperSupport() {
      return BuildConfig.DEBUG;
    }

    @Override
    protected List<ReactPackage> getPackages() {
      return Arrays.<ReactPackage>asList(
            new MainReactPackage(),
            new RNNearbyApiPackage(),
            new ImageResizerPackage(),
            new ImagePickerPackage(),
            new RNFirebasePackage(),
            new RNFirebaseMessagingPackage(),
            new RNFirebaseAnalyticsPackage(),
            //new RNFirebaseAdMobPackage(),
            new RCTMGLPackage(),
            new SplashScreenReactPackage(),
            new InAppBillingBridgePackage(),
            new RNSpinkitPackage(),
            new RNFetchBlobPackage(),
            new RNDeviceInfo(),
            new RNFSPackage(),
            new RNZipArchivePackage(),
            new UdpSocketsModule(),
            new TcpSocketsModule(),
            new RandomBytesPackage(),
            new ReactNativeConfigPackage(),
            new VectorIconsPackage(),
            new KCKeepAwakePackage(),
            new Interactable()
      );
    }
  };

settings.gradle:

include ':react-native-nearby-api'
project(':react-native-nearby-api').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-nearby-api/android')

android/app/build.gradle:


dependencies {
    compile fileTree(dir: "libs", include: ["*.jar"])
    compile 'com.android.support:multidex:1.0.1'
    compile project(':react-native-nearby-api')
    compile project(':react-native-image-resizer')
    compile project(':react-native-image-picker')
    compile(project(':react-native-firebase')) {
        transitive = false
    }
	compile "com.google.firebase:firebase-core:11.6.0"
	compile "com.google.firebase:firebase-messaging:11.6.0"
	compile "com.google.firebase:firebase-analytics:11.6.0"
	//compile "com.google.firebase:firebase-ads:11.6.0"

    compile project(':mapbox-react-native-mapbox-gl')
    compile project(path: ':react-native-interactable')
    compile project(':react-native-splash-screen')
    compile project(':react-native-billing')
    compile 'com.facebook.stetho:stetho:1.3.1'
    compile 'com.facebook.stetho:stetho-okhttp3:1.3.1'

    compile project(':react-native-spinkit')
    compile project(':react-native-fetch-blob')
    compile (project(':react-native-device-info')) {
        exclude group: "com.google.android.gms" 
    }
    compile project(':react-native-fs')
    compile project(':react-native-zip-archive')
    compile project(':react-native-udp')
    compile project(':react-native-tcp')
    compile project(':react-native-randombytes')
    compile project(':react-native-config')
    compile project(':react-native-vector-icons')
    compile project(':react-native-keep-awake')
    compile "com.android.support:appcompat-v7:23.0.1"
    compile "com.facebook.react:react-native:0.51.0"  // From node_modules
	
	// Firebase dependencies
	compile ("com.google.android.gms:play-services-gcm:11.6.0") {
        force = true;
    }
	compile ("com.google.android.gms:play-services-base:11.6.0") {
		force = true;
	}
}

butchmarshall avatar Jan 09 '18 04:01 butchmarshall

@butchmarshall Did you get this resolved?

migbot avatar Apr 12 '18 22:04 migbot

Hi guys, Does anyone has any idea on how to solve this?.

I have the exact same error and I believe is due to some kind of conflict with other google libraries. This started to happen in my project when I added react-native-push-notification plugin, also happened when I added urbanairship's RN plugin.

jortegano avatar Aug 20 '18 18:08 jortegano

same here :(

rares-lupascu avatar Aug 24 '18 05:08 rares-lupascu

unfortunately i think this repo is dead since there is no reply from anyone for a few months now

rares-lupascu avatar Aug 24 '18 06:08 rares-lupascu

I was able to fix this by changing my app/build.gradle to exclude the com.google.android.gms group from react-native-nearby-api and force update it to com.google.android.gms:play-services-nearby:15.0.0

hope this helps!

dependencies {
    compile project(':react-native-splash-screen')
    compile project(':react-native-sound')
    compile (project(':react-native-nearby-api')){
        exclude group: "com.google.android.gms"
    }
    compile project(':react-native-keep-awake')
    compile project(':react-native-haptic-feedback')
    compile project(':react-native-google-analytics-bridge')
    compile project(':lottie-react-native')

    compile project(':appcenter-crashes')
    compile project(':appcenter-analytics')
    compile project(':appcenter')

    compile project(':react-native-code-push')
    compile fileTree(dir: "libs", include: ["*.jar"])
    compile "com.android.support:appcompat-v7:23.0.1"

    compile "com.facebook.react:react-native:+"  // From node_modules

    compile ("com.google.android.gms:play-services-nearby:15.0.0") {
        force = true
    }
}

joshbalfour avatar Sep 19 '18 19:09 joshbalfour