title: Unity C# and Layar SDK Java - AndroidJavaException
body: <p>I'm Trying to Integrate Layar SDK to Unity.
  But I've got some issue.</p>
  
  <p>Here is the <strong>AndroidManifest.xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="com.layar.player"
  android:versionCode="1"
  android:versionName="8.5.2" &gt;
  
  &lt;uses-sdk
      android:minSdkVersion="15"
      android:targetSdkVersion="23" /&gt;
  
  &lt;uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" /&gt;
  &lt;uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /&gt;
  &lt;uses-permission android:name="android.permission.INTERNET" /&gt;
  &lt;uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /&gt;
  &lt;uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /&gt;
  &lt;uses-permission android:name="android.permission.ACCESS_COARSE_UPDATES" /&gt;
  &lt;uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /&gt;
  &lt;uses-permission android:name="android.permission.CAMERA" /&gt;
  &lt;uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /&gt;
  &lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /&gt;
  
  &lt;uses-feature android:name="android.hardware.camera" /&gt;
  
  &lt;application&gt;
      &lt;activity
          android:name="com.layar.sdk.LayarSDKActivity"
          android:launchMode="singleTask"
          android:screenOrientation="nosensor"
          android:theme="@android:style/Theme.Light.NoTitleBar" /&gt;
      &lt;activity
          android:name="com.layar.player.geo.FilterSettingsActivity"
          android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
          android:theme="@style/FilterTheme" /&gt;
      &lt;activity
          android:name="com.layar.LayerDetailsActivity"
          android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
          android:theme="@style/LayarTitleTheme" /&gt;
      &lt;activity
          android:name="com.layar.WebActivity"
          android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
          android:theme="@style/LayarTitleTheme" /&gt;
      &lt;activity
          android:name="com.layar.ShareSocialActivity"
          android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
          android:theme="@style/Layar.Theme.Default" /&gt;
      &lt;activity
          android:name="com.layar.VideoActivity"
          android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
          android:theme="@style/FullScreenTheme" /&gt;
      &lt;activity
          android:name="com.layar.AudioActivity"
          android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
          android:theme="@style/SmartDialogTheme" /&gt;
      &lt;activity
          android:name="com.layar.ScreenshotActivity"
          android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
          android:screenOrientation="nosensor"
          android:theme="@android:style/Theme.Light.NoTitleBar" /&gt;
      &lt;activity
          android:name="com.layar.ShareOnFacebookActivity"
          android:theme="@android:style/Theme.Light.NoTitleBar"
          android:windowSoftInputMode="stateAlwaysVisible|adjustResize" /&gt;
  
      &lt;receiver
          android:name="com.layar.localytics.CloseSesionBroadcastReciever"
          android:exported="false" &gt;
          &lt;intent-filter&gt;
              &lt;action android:name="com.layar.close_session" /&gt;
          &lt;/intent-filter&gt;
      &lt;/receiver&gt;
  &lt;/application&gt;
  </code></pre>
  
  <p></p>
  
  <p>and This is My c#</p>
  
  <pre><code>using UnityEngine;
  
  public class IntegrationLayar : MonoBehaviour {
  
  private AndroidJavaObject LayarSDK = null;
  private AndroidJavaObject activity = null;
  private AndroidJavaObject context = null;
  
  private string oauthKey = "code";
  private string oauthSecret = "code2";
  
  
  void Start ()
  {
          if (LayarSDK == null)
          {
              using (AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer"))
              {
                  activity = unityPlayer.GetStatic&lt;AndroidJavaObject&gt;("currentActivity");
                  context = activity.Call&lt;AndroidJavaObject&gt;("getApplicationContext");
  
                  //activity.Call("runOnUiThread", new AndroidJavaRunnable(runOnUiThread));
                  Debug.Log("unity3D JAVA - Working");
              }
  
              using (AndroidJavaClass pluginClass = new AndroidJavaClass("com.layar.player"))
              {
                  if (pluginClass != null)
                  {
                      Debug.Log("Layar Java - Working");
                      pluginClass.CallStatic("initialize", context, oauthKey, oauthSecret);
                      pluginClass.CallStatic("startLayarActivity", context);
                  }
              }
      }
  }
  }
  </code></pre>
  
  <p><strong>Error</strong> : </p>
  
  <blockquote>
    <p>AndroidJavaException: java.lang.ClassNotFoundException: com.layar.player</p>
  </blockquote>
  
  <p>As I understand it, it didn't found a Class named like this in the Java.
  So The problem is what ? I'm calling the wrong activity?</p>
  
  <p>Here is the link to Layar API <a href="https://www.layar.com/documentation/layar-sdk/integrate-android-studio/" rel="nofollow noreferrer">link</a></p>
  
  <p>As I see in the Layar API the class is "LayarVisionSDK".</p>
  
  <pre><code>AndroidJavaClass pluginClass = new AndroidJavaClass("com.layar.player.LayarVisionSDK")
  </code></pre>
  
  <p>So Maybe this should work?</p>
  
  <p>I certainly doing it wrong but if any of you have a direction to follow, I'll be glad to learn :)</p>
  
  <p><strong>UPDATE 1 :</strong> </p>
  
  <p>This is from the APK</p>
  
  <pre><code>Class LayarVisionSDK
  
  java.lang.Object
  com.layar.sdk.LayarVisionSDK
  </code></pre>
  
  <p>So instead of using </p>
  
  <pre><code>AndroidJavaClass pluginClass = new AndroidJavaClass("com.layar.player.LayarVisionSDK")
  </code></pre>
  
  <p>I'm using</p>
  
  <pre><code>AndroidJavaObject LayarVisionSDK = new AndroidJavaObject("com.layar.sdk.LayarVisionSDK");
  </code></pre>
  
  <p>But still not sucessfull. I'm asking myself if the problem may be not where it seem to be.</p>
  
  <p><strong>UPDATE 2 :</strong></p>
  
  <p>OK ! I found why I get this error, the API doc was not updated so i checked in the java package and found where was the "initialize" method.</p>
  
  <p>So here is the new c# code.</p>
  
  <pre><code>using (AndroidJavaClass pluginClass = new AndroidJavaClass("com.layar.sdk.LayarSDK"))
                  {
                      if (pluginClass != null)
                      {
                          Debug.Log("SDK LAYAR FOUND !!! ");
                          pluginClass.CallStatic("initialize", context, oauthKey, oauthSecret);
                          Debug.Log("INITIALIZED");
                          //pluginClass.Call("startLayarActivity", context);
                      }
                  }
  </code></pre>
  
  <p><strong>But I got a new error :</strong> </p>
  
  <pre><code>AndroidJavaException: java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/v4/content/ContextCompat;
  </code></pre>
  
  <p>Am I missing a android library?</p>