title: Get Android Version Information
body: <p>I want to get Android version information from Unity. I know that <a href="https://docs.unity3d.com/ScriptReference/SystemInfo-operatingSystem.html" rel="noreferrer"><code>SystemInfo.operatingSystem</code></a> can be used to do this but it does not have all the information such as release number, code-name and other info.</p>
  
  <p>I decided to make a tiny plugin with Unity's <a href="https://docs.unity3d.com/ScriptReference/AndroidJavaClass.html" rel="noreferrer"><code>AndroidJavaClass</code></a> class using Android's <a href="https://developer.android.com/reference/android/os/Build.VERSION.html" rel="noreferrer"><code>Build.VERSION</code></a> class but ran into a problem I can't explain.</p>
  
  <p>When I do:</p>
  
  <pre><code>AndroidJavaClass("android.os.Build.VERSION");
  </code></pre>
  
  <p>I get class not found exception.</p>
  
  <p>It <strong>works</strong> when use:</p>
  
  <pre><code>AndroidJavaClass("android.os.Build$VERSION");
  </code></pre>
  
  <p>Notice that I replaced <em>"."</em> with <em>"$"</em> and the class can now be found. </p>
  
  <p>I have written many plugins in the past and have never ran into this problem before. For <a href="https://stackoverflow.com/a/45012767/3785314">example</a>, when I accessed the Android's <code>Uri</code> class, I used  <code>AndroidJavaClass("android.net.Uri");</code> and it worked. I didn't have to put <em>"$"</em> before "<code>Uri</code>".</p>
  
  <p>What makes accessing <code>android.net.Uri</code> different from accessing <code>android.os.Build.VERSION</code>?</p>
  
  <p>Why do you have to put <em>"$"</em> between Build and VERSION in order for <a href="https://docs.unity3d.com/ScriptReference/AndroidJavaClass.html" rel="noreferrer"><code>AndroidJavaClass</code></a> to find this class?</p>
  
  <p>By the way, here is the working plugin of <a href="https://developer.android.com/reference/android/os/Build.VERSION.html" rel="noreferrer"><code>Build.VERSION</code></a> in Unity:</p>
  
  <pre><code>public class AndroidVersion
  {
      static AndroidJavaClass versionInfo;
  
      static AndroidVersion()
      {
          versionInfo = new AndroidJavaClass("android.os.Build$VERSION");
      }
  
      public static string BASE_OS
      {
          get
          {
              return versionInfo.GetStatic&lt;string&gt;("BASE_OS");
          }
      }
  
      public static string CODENAME
      {
          get
          {
              return versionInfo.GetStatic&lt;string&gt;("CODENAME");
          }
      }
  
      public static string INCREMENTAL
      {
          get
          {
              return versionInfo.GetStatic&lt;string&gt;("INCREMENTAL");
          }
      }
  
      public static int PREVIEW_SDK_INT
      {
          get
          {
              return versionInfo.GetStatic&lt;int&gt;("PREVIEW_SDK_INT");
          }
      }
  
      public static string RELEASE
      {
          get
          {
              return versionInfo.GetStatic&lt;string&gt;("RELEASE");
          }
      }
  
      public static string SDK
      {
          get
          {
              return versionInfo.GetStatic&lt;string&gt;("SDK");
          }
      }
  
      public static int SDK_INT
      {
          get
          {
              return versionInfo.GetStatic&lt;int&gt;("SDK_INT");
          }
      }
  
      public static string SECURITY_PATCH
      {
          get
          {
              return versionInfo.GetStatic&lt;string&gt;("SECURITY_PATCH");
          }
      }
  
      public static string ALL_VERSION
      {
          get
          {
              string version = "BASE_OS: " + BASE_OS + "\n";
              version += "CODENAME: " + CODENAME + "\n";
              version += "INCREMENTAL: " + INCREMENTAL + "\n";
              version += "PREVIEW_SDK_INT: " + PREVIEW_SDK_INT + "\n";
              version += "RELEASE: " + RELEASE + "\n";
              version += "SDK: " + SDK + "\n";
              version += "SDK_INT: " + SDK_INT + "\n";
              version += "SECURITY_PATCH: " + SECURITY_PATCH;
  
              return version;
          }
      }
  }
  </code></pre>