title: My app crashing/closing after hitting "continue with facebook"
body: <p>I am trying to integrate facebook with my app in android studio. I am an amateur at the kotlin language that I am using to achieve my goal.</p>
  
  <p>I followed the tutorial on the facebook developers page. The problem is that once I hit the login button, it loads for 2 to 3 seconds and then crashes/closes.</p>
  
  <p>The code snippet in the <code>LoginActivity.kt file</code></p>
  
  <pre><code>val fblogin_button= findViewById&lt;LoginButton&gt;(R.id.login_button)
      fblogin_button.setOnClickListener {
          callbackManager = CallbackManager.Factory.create()
          LoginManager.getInstance().logInWithReadPermissions(this,Arrays.asList("email"))
          LoginManager.getInstance().registerCallback(callbackManager,
          object : FacebookCallback&lt;LoginResult&gt;{
              override fun onSuccess(result: LoginResult) {
                  Log.d("LoginActivity","Facebook token" + result.accessToken.token)
                  startActivity(Intent(baseContext,GradeActivity::class.java))
              }
  
              override fun onCancel() {
                  Log.d("LoginActivity","Facebook oncancel")
              }
  
              override fun onError(error: FacebookException?) {
                  Log.d("LoginActivity","Facebook onError")
              }
  
          })
      }
  </code></pre>
  
  <p>I also have another method outside the <code>onCreate</code> method. That is given below.</p>
  
  <pre><code>override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
      super.onActivityResult(requestCode, resultCode, data)
      callbackManager?.onActivityResult(requestCode,resultCode,data)
  }
  </code></pre>
  
  <p>The <code>Manifest</code> file contents are shown below.</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:tools="http://schemas.android.com/tools"
  package="com.example.vishwa.imaginators"&gt;
  &lt;uses-permission android:name="android.permission.INTERNET" /&gt;
  &lt;!--&lt;uses-permission android:name="android.permission.CAMERA" /&gt;--&gt;
  &lt;!--&lt;uses-feature android:name="android.hardware.camera" /&gt;--&gt;
  &lt;!--&lt;uses-feature android:name="android.hardware.camera" android:required="false" /&gt;--&gt;
  &lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /&gt;
  &lt;uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /&gt;
  &lt;uses-permission android:name="android.permission.RECORD_AUDIO" /&gt;
  
  &lt;application
      android:allowBackup="true"
      android:icon="@mipmap/ic_launcher"
      android:label="@string/app_name"
      android:roundIcon="@mipmap/ic_launcher_round"
      android:supportsRtl="true"
      android:theme="@style/AppTheme"&gt;
      &lt;activity android:name=".SplashscreenActivity"
          android:theme="@style/AppTheme"
          android:noHistory="true"&gt;
          &lt;intent-filter&gt;
              &lt;action android:name="android.intent.action.MAIN" /&gt;
  
              &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
          &lt;/intent-filter&gt;
      &lt;/activity&gt;
      &lt;activity android:name=".LoginActivity"
          android:theme="@style/AppTheme"
          android:noHistory="true"&gt;
      &lt;/activity&gt;
      &lt;activity android:name=".GradeActivity"
          android:theme="@style/AppTheme"
          android:noHistory="true"&gt;
  
      &lt;/activity&gt;
      &lt;activity android:name=".MainActivity"&gt;
  
      &lt;/activity&gt;
      &lt;meta-data android:name="com.facebook.sdk.ApplicationId"
          android:value="@string/facebook_app_id"/&gt;
  
      &lt;activity android:name="com.facebook.FacebookActivity"
          android:configChanges=
              "keyboard|keyboardHidden|screenLayout|screenSize|orientation"
          android:label="@string/app_name" /&gt;
      &lt;activity
          android:name="com.facebook.CustomTabActivity"
          android:exported="true"&gt;
          &lt;intent-filter&gt;
              &lt;action android:name="android.intent.action.VIEW" /&gt;
              &lt;category android:name="android.intent.category.DEFAULT" /&gt;
              &lt;category android:name="android.intent.category.BROWSABLE" /&gt;
              &lt;data android:scheme="@string/fb_login_protocol_scheme" /&gt;
          &lt;/intent-filter&gt;
      &lt;/activity&gt;
  
  
  &lt;/application&gt;
  </code></pre>
  
  <p></p>
  
  <p>As you can see the <code>onSuccess</code> method, if it login is successful then the <code>GradeActivity</code> is supposed to open but instead it closes.</p>
  
  <p>The logs are shown below.</p>
  
  <pre><code>07-23 19:22:37.154 22589-22589/? I/art: Late-enabling -Xcheck:jni
  07-23 19:22:37.219 22589-22589/? D/TidaProvider: TidaProvider()
  07-23 19:22:37.257 22589-22589/com.example.vishwa.imaginators 
  W/ActivityThread: Application com.example.vishwa.imaginators is waiting for the debugger on port 8100...
  07-23 19:22:37.282 22589-22589/com.example.vishwa.imaginators I/System.out: 
  Sending WAIT chunk
  07-23 19:22:37.375 22589-22595/com.example.vishwa.imaginators I/art: Debugger is active
  07-23 19:22:37.483 22589-22589/com.example.vishwa.imaginators I/System.out: Debugger has connected
  waiting for debugger to settle...
  07-23 19:22:37.684 22589-22589/com.example.vishwa.imaginators I/System.out: waiting for debugger to settle...
  07-23 19:22:37.884 22589-22589/com.example.vishwa.imaginators I/System.out: waiting for debugger to settle...
  07-23 19:22:38.084 22589-22589/com.example.vishwa.imaginators I/System.out: waiting for debugger to settle...
  07-23 19:22:38.284 22589-22589/com.example.vishwa.imaginators I/System.out: waiting for debugger to settle...
  07-23 19:22:38.484 22589-22589/com.example.vishwa.imaginators I/System.out: waiting for debugger to settle...
  07-23 19:22:38.685 22589-22589/com.example.vishwa.imaginators I/System.out: waiting for debugger to settle...
  07-23 19:22:38.885 22589-22589/com.example.vishwa.imaginators I/System.out: debugger has settled (1427)
  07-23 19:22:38.943 22589-22589/com.example.vishwa.imaginators W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --instruction-set=arm64 --instruction-set-features=smp,a53 --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --non-interactive --runtime-arg -Xms64m --runtime-arg -Xmx512m -j2 --instruction-set-variant=generic --instruction-set-features=default --dex-file=/data/app/com.example.vishwa.imaginators-2/split_lib_dependencies_apk.apk --oat-file=/data/dalvik-cache/arm64/data@app@com.example.vishwa.imaginators-2@split_lib_dependencies_apk.apk@classes.dex) because non-0 exit status
  07-23 19:22:39.444 22589-22589/com.example.vishwa.imaginators W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --instruction-set=arm64 --instruction-set-features=smp,a53 --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --non-interactive --runtime-arg -Xms64m --runtime-arg -Xmx512m -j2 --instruction-set-variant=generic --instruction-set-features=default --dex-file=/data/app/com.example.vishwa.imaginators-2/split_lib_slice_0_apk.apk --oat-file=/data/dalvik-cache/arm64/data@app@com.example.vishwa.imaginators-2@split_lib_slice_0_apk.apk@classes.dex) because non-0 exit status
  07-23 19:22:39.501 22589-22589/com.example.vishwa.imaginators W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --instruction-set=arm64 --instruction-set-features=smp,a53 --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --non-interactive --runtime-arg -Xms64m --runtime-arg -Xmx512m -j2 --instruction-set-variant=generic --instruction-set-features=default --dex-file=/data/app/com.example.vishwa.imaginators-2/split_lib_slice_1_apk.apk --oat-file=/data/dalvik-cache/arm64/data@app@com.example.vishwa.imaginators-2@split_lib_slice_1_apk.apk@classes.dex) because non-0 exit status
  07-23 19:22:39.560 22589-22589/com.example.vishwa.imaginators W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --instruction-set=arm64 --instruction-set-features=smp,a53 --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --non-interactive --runtime-arg -Xms64m --runtime-arg -Xmx512m -j2 --instruction-set-variant=generic --instruction-set-features=default --dex-file=/data/app/com.example.vishwa.imaginators-2/split_lib_slice_2_apk.apk --oat-file=/data/dalvik-cache/arm64/data@app@com.example.vishwa.imaginators-2@split_lib_slice_2_apk.apk@classes.dex) because non-0 exit status
  07-23 19:22:39.630 22589-22589/com.example.vishwa.imaginators W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --instruction-set=arm64 --instruction-set-features=smp,a53 --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --non-interactive --runtime-arg -Xms64m --runtime-arg -Xmx512m -j2 --instruction-set-variant=generic --instruction-set-features=default --dex-file=/data/app/com.example.vishwa.imaginators-2/split_lib_slice_3_apk.apk --oat-file=/data/dalvik-cache/arm64/data@app@com.example.vishwa.imaginators-2@split_lib_slice_3_apk.apk@classes.dex) because non-0 exit status
  07-23 19:22:39.711 22589-22589/com.example.vishwa.imaginators W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --instruction-set=arm64 --instruction-set-features=smp,a53 --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --non-interactive --runtime-arg -Xms64m --runtime-arg -Xmx512m -j2 --instruction-set-variant=generic --instruction-set-features=default --dex-file=/data/app/com.example.vishwa.imaginators-2/split_lib_slice_4_apk.apk --oat-file=/data/dalvik-cache/arm64/data@app@com.example.vishwa.imaginators-2@split_lib_slice_4_apk.apk@classes.dex) because non-0 exit status
  07-23 19:22:39.774 22589-22589/com.example.vishwa.imaginators W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --instruction-set=arm64 --instruction-set-features=smp,a53 --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --non-interactive --runtime-arg -Xms64m --runtime-arg -Xmx512m -j2 --instruction-set-variant=generic --instruction-set-features=default --dex-file=/data/app/com.example.vishwa.imaginators-2/split_lib_slice_5_apk.apk --oat-file=/data/dalvik-cache/arm64/data@app@com.example.vishwa.imaginators-2@split_lib_slice_5_apk.apk@classes.dex) because non-0 exit status
  07-23 19:22:39.844 22589-22589/com.example.vishwa.imaginators W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --instruction-set=arm64 --instruction-set-features=smp,a53 --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --non-interactive --runtime-arg -Xms64m --runtime-arg -Xmx512m -j2 --instruction-set-variant=generic --instruction-set-features=default --dex-file=/data/app/com.example.vishwa.imaginators-2/split_lib_slice_6_apk.apk --oat-file=/data/dalvik-cache/arm64/data@app@com.example.vishwa.imaginators-2@split_lib_slice_6_apk.apk@classes.dex) because non-0 exit status
  07-23 19:22:39.904 22589-22589/com.example.vishwa.imaginators W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --instruction-set=arm64 --instruction-set-features=smp,a53 --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --non-interactive --runtime-arg -Xms64m --runtime-arg -Xmx512m -j2 --instruction-set-variant=generic --instruction-set-features=default --dex-file=/data/app/com.example.vishwa.imaginators-2/split_lib_slice_7_apk.apk --oat-file=/data/dalvik-cache/arm64/data@app@com.example.vishwa.imaginators-2@split_lib_slice_7_apk.apk@classes.dex) because non-0 exit status
  07-23 19:22:39.965 22589-22589/com.example.vishwa.imaginators W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --instruction-set=arm64 --instruction-set-features=smp,a53 --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --non-interactive --runtime-arg -Xms64m --runtime-arg -Xmx512m -j2 --instruction-set-variant=generic --instruction-set-features=default --dex-file=/data/app/com.example.vishwa.imaginators-2/split_lib_slice_8_apk.apk --oat-file=/data/dalvik-cache/arm64/data@app@com.example.vishwa.imaginators-2@split_lib_slice_8_apk.apk@classes.dex) because non-0 exit status
  07-23 19:22:40.033 22589-22589/com.example.vishwa.imaginators W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --instruction-set=arm64 --instruction-set-features=smp,a53 --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --non-interactive --runtime-arg -Xms64m --runtime-arg -Xmx512m -j2 --instruction-set-variant=generic --instruction-set-features=default --dex-file=/data/app/com.example.vishwa.imaginators-2/split_lib_slice_9_apk.apk --oat-file=/data/dalvik-cache/arm64/data@app@com.example.vishwa.imaginators-2@split_lib_slice_9_apk.apk@classes.dex) because non-0 exit status
  07-23 19:22:40.043 22589-22589/com.example.vishwa.imaginators W/System: ClassLoader referenced unknown path: /data/app/com.example.vishwa.imaginators-2/lib/arm64
  07-23 19:22:40.145 22589-22817/com.example.vishwa.imaginators D/com.facebook.FacebookSdk: getGraphApiVersion: v3.0
  07-23 19:22:40.149 22589-22817/com.example.vishwa.imaginators I/DpmTcmClient: RegisterTcmMonitor from: com.android.okhttp.TcmIdleTimerMonitor
  07-23 19:22:40.154 22589-22589/com.example.vishwa.imaginators I/InstantRun: starting instant run server: is main process
  07-23 19:22:40.247 22589-22589/com.example.vishwa.imaginators W/art: Before Android 4.1, method android.graphics.PorterDuffColorFilter android.support.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable
  07-23 19:22:40.290 22589-22589/com.example.vishwa.imaginators D/AccessibilityManager: current package=com.example.vishwa.imaginators, accessibility manager mIsFinalEnabled=false, mOptimizeEnabled=false, mIsUiAutomationEnabled=false, mIsInterestedPackage=false
  07-23 19:22:40.312 22589-22589/com.example.vishwa.imaginators V/BoostFramework: BoostFramework() : mPerf = com.qualcomm.qti.Performance@7199c39
  BoostFramework() : mPerf = com.qualcomm.qti.Performance@97127e
  07-23 19:22:40.462 22589-22589/com.example.vishwa.imaginators W/com.facebook.appevents.AppEventsLogger: activateApp events are being logged automatically. There's no need to call activateApp explicitly, this is safe to remove.
  07-23 19:22:40.529 22589-22841/com.example.vishwa.imaginators D/OpenGLRenderer: Use EGL_SWAP_BEHAVIOR_PRESERVED: true
  07-23 19:22:40.648 22589-22841/com.example.vishwa.imaginators I/Adreno: QUALCOMM build                   : a7823f5, I59a6815413
  Build Date                       : 09/23/16
  OpenGL ES Shader Compiler Version: XE031.07.00.00
  Local Branch                     : mybranch22028469
  Remote Branch                    : quic/LA.BR.1.3.3_rb2.26
  Remote Branch                    : NONE
  Reconstruct Branch               : NOTHING
  07-23 19:22:40.684 22589-22824/com.example.vishwa.imaginators D/com.facebook.FacebookSdk: getGraphApiVersion: v3.0
  07-23 19:22:40.688 22589-22824/com.example.vishwa.imaginators W/AnalyticsUserIDStore: initStore should have been called before calling setUserID
  07-23 19:22:40.727 22589-22589/com.example.vishwa.imaginators W/art: Before Android 4.1, method int android.support.v7.widget.ListViewCompat.lookForSelectablePosition(int, boolean) would have incorrectly overridden the package-private method in android.widget.ListView
  07-23 19:22:40.733 22589-22841/com.example.vishwa.imaginators I/OpenGLRenderer: Initialized EGL, version 1.4
  07-23 19:22:40.783 22589-22841/com.example.vishwa.imaginators E/HAL: hw_get_module_by_class: module name gralloc
  hw_get_module_by_class: module name gralloc
  07-23 19:22:41.010 22589-22850/com.example.vishwa.imaginators D/com.facebook.FacebookSdk: getGraphApiVersion: v3.0
  07-23 19:22:41.351 22589-22824/com.example.vishwa.imaginators D/com.facebook.FacebookSdk: getGraphApiVersion: v3.0
  07-23 19:22:41.465 22589-22839/com.example.vishwa.imaginators I/Timeline: Timeline: Activity_launch_request time:459431007
  07-23 19:22:41.507 22589-22589/com.example.vishwa.imaginators V/BoostFramework: BoostFramework() : mPerf = com.qualcomm.qti.Performance@bb9ef8e
  07-23 19:22:41.508 22589-22589/com.example.vishwa.imaginators V/BoostFramework: BoostFramework() : mPerf = com.qualcomm.qti.Performance@afc73af
  07-23 19:22:43.725 22589-22589/com.example.vishwa.imaginators I/Timeline: Timeline: Activity_launch_request time:459433267
  07-23 19:22:43.781 22589-22589/com.example.vishwa.imaginators I/Timeline: Timeline: Activity_launch_request time:459433323
  07-23 19:22:44.848 22589-22589/com.example.vishwa.imaginators D/com.facebook.FacebookSdk: getGraphApiVersion: v3.0
  07-23 19:22:45.179 22589-22589/com.example.vishwa.imaginators D/com.facebook.FacebookSdk: getGraphApiVersion: v3.0
  </code></pre>
  
  <p>Now the app doesn't run in normal mode, it runs in debug mode even if I don't run in debug mode.</p>
  
  <p>Any help is appreciated.</p>