Skip to content

Android Configuration

Open your project android directory in Android Studio so you can sync project and update dependencies correctly. In your project android/build.gradle make sure to include the following:

buildscript {
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.4'
        classpath 'com.google.gms:google-services:4.0.1'
    }
}

allprojects {
    repositories {
        ...
        maven { url "https://maven.google.com" }
    }
}

Note: make sure that your gradle-wrapper.properties contains the latest gradle version.

Minimum version is distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip


In your project android/src/main/java/<your-project-package>/MainActivity.java,

  • Add the following imports:
...
import android.os.Bundle;
import android.support.annotation.Nullable;
import it.near.sdk.reactnative.rnnearitsdk.RNNearItModule;
...
  • Add the following method
...
public class MainActivity extends ReactActivity {
    ...

    @Override
    protected void onPostCreate(@Nullable Bundle savedInstanceState) {
        super.onPostCreate(savedInstanceState);
        RNNearItModule.onPostCreate(getApplicationContext(), getIntent());
    }

    ...
}