title: Cannot set current Facebook AccessToken in React Native on Android
body: <p>I am trying to set a Facebook AccessToken in React Native on an Android device via the function <code>AccessToken.setCurrentAccessToken(...);</code></p>
  
  <p>And I am getting the following error: </p>
  
  <pre><code>E/unknown:ReactNative: Exception in native call
      java.lang.RuntimeException: Could not invoke FBAccessToken.setCurrentAccessToken
          at com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:383)
          &lt;snip&gt;
       Caused by: java.lang.reflect.InvocationTargetException
          at java.lang.reflect.Method.invoke(Native Method)
          at com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:372)
          &lt;snip&gt; 
       Caused by: java.lang.NoSuchMethodError: No direct method &lt;init&gt;(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/util/Collection;Ljava/util/Collection;Lcom/facebook/AccessTokenSource;Ljava/util/Date;Ljava/util/Date;)V in class Lcom/facebook/AccessToken; or its super classes (declaration of 'com.facebook.AccessToken' appears in /data/app/&lt;app-name-here&gt;/base.apk)
          at com.facebook.reactnative.androidsdk.Utility.buildAccessToken(Utility.java:90)
          at com.facebook.reactnative.androidsdk.FBAccessTokenModule.setCurrentAccessToken(FBAccessTokenModule.java:69)
          at java.lang.reflect.Method.invoke(Native Method) 
          at com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:372) 
          &lt;snip&gt;
  </code></pre>
  
  <p>I am not sure why it cannot find the Constructor, as the types match the definition in the docs: <a href="https://developers.facebook.com/docs/reference/android/current/class/AccessToken" rel="nofollow noreferrer">https://developers.facebook.com/docs/reference/android/current/class/AccessToken</a>
  , and the build compiles, so the types match the definition that's expected...</p>
  
  <p>The React Native code I'm running to generate this error is: </p>
  
  <pre><code>AccessToken.getCurrentAccessToken().then((ffff) =&gt; {
      AccessToken.setCurrentAccessToken(ffff);
  })
  </code></pre>
  
  <p>I have these entries in my <code>app/build.gradle</code>: </p>
  
  <pre><code>implementation 'com.facebook.android:facebook-android-sdk:[4,5)'
  implementation project(':react-native-fbsdk')
  </code></pre>
  
  <p>and these in <code>MainApplication.java</code>: </p>
  
  <pre><code>     new FBSDKPackage(mCallbackManager),
  </code></pre>
  
  <p>and </p>
  
  <pre><code>    private static CallbackManager mCallbackManager = 
          CallbackManager.Factory.create();
  </code></pre>
  
  <p>This in <code>settings.gradle</code>: </p>
  
  <pre><code>include ':react-native-fbsdk'
  project(':react-native-fbsdk').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-fbsdk/android')
  </code></pre>
  
  <p>I feel as though my build environment uses one JAR, and my runtime has a different one, as there appears to be a 'newer' AccessToken class defined here: <a href="https://developers.facebook.com/docs/reference/androidsdk/current/facebook/com/facebook/accesstoken.html/" rel="nofollow noreferrer">https://developers.facebook.com/docs/reference/androidsdk/current/facebook/com/facebook/accesstoken.html/</a> , but I cannot identify which is actually used at runtime to investigate further. Any suggestions as to where/how to investigate this will be gratefully received.</p>
  
  <p>This code has worked in the past...</p>
  
  <p>[Edit....]</p>
  
  <p>Project's <code>build.gradle</code>:</p>
  
  <pre><code>buildscript {
      repositories {
          jcenter()
          maven {
              url 'https://maven.fabric.io/public'
          }
          mavenCentral()
          google()
          maven {
              url "https://maven.google.com"
          }
      }
      dependencies {
          classpath 'com.android.tools.build:gradle:3.2.1'
          // NOTE: Do not place your application dependencies here; they belong
          // in the individual module build.gradle files
          classpath 'com.google.gms:google-services:4.0.1'
  
          // The Fabric Gradle plugin uses an open ended version to react
          // quickly to Android tooling updates
          classpath 'io.fabric.tools:gradle:1.+'
  
          // svg to png
          classpath('fr.avianey.androidsvgdrawable:gradle-plugin:3.0.0') {
              // should be excluded to avoid conflict
              exclude group: 'xerces'
          }
      }
  }
  
  allprojects {
      repositories {
          mavenLocal()
          google()
          jcenter()
          maven {
              // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
              url "$rootDir/../node_modules/react-native/android"
          }
          maven { url 'https://maven.fabric.io/public' }
          // jitpack repo is necessary to fetch ucrop dependency
          maven { url "https://jitpack.io" }
      }
  }
  
  subprojects {
      afterEvaluate {project -&gt;
          if (project.hasProperty("android")) {
              android {
                  compileSdkVersion 27
                  buildToolsVersion '27.0.3'
              }
          }
      }
  }
  </code></pre>
  
  <p>[Edit 2...]</p>
  
  <p>Also, JS code / React Native code works fine on iOS, so its an Android specific issue...</p>