title: Android Unity plugin - Class not found exception
body: <p>I want to export an android library to Unity, but that Android gives the following error:</p>
  
  <pre><code>05-14 12:58:10.601 18408-18408/? E/AndroidRuntime: FATAL EXCEPTION: main
                                                 Process: com.joostverbraeken.weargame, PID: 18408
                                                 java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.joostverbraeken.weargame/com.joostverbraeken.weargame.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "com.joostverbraeken.weargame.MainActivity" on path: DexPathList[[zip file "/data/app/com.joostverbraeken.weargame-1/base.apk"],nativeLibraryDirectories=[/data/app/com.joostverbraeken.weargame-1/lib/arm, /data/app/com.joostverbraeken.weargame-1/base.apk!/lib/armeabi-v7a, /vendor/lib, /system/lib]]
  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2332)
  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2481)
  at android.app.ActivityThread.access$900(ActivityThread.java:153)
  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1349)
  at android.os.Handler.dispatchMessage(Handler.java:102)
  at android.os.Looper.loop(Looper.java:148)
  at android.app.ActivityThread.main(ActivityThread.java:5436)
  at java.lang.reflect.Method.invoke(Native Method)
  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:735)
  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
                                                      Caused by: java.lang.ClassNotFoundException: Didn't find class "com.joostverbraeken.weargame.MainActivity" on path: DexPathList[[zip file "/data/app/com.joostverbraeken.weargame-1/base.apk"],nativeLibraryDirectories=[/data/app/com.joostverbraeken.weargame-1/lib/arm, /data/app/com.joostverbraeken.weargame-1/base.apk!/lib/armeabi-v7a, /vendor/lib, /system/lib]]
  at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
  at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
  at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
  at android.app.Instrumentation.newActivity(Instrumentation.java:1068)
  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2322)
  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2481) 
  at android.app.ActivityThread.access$900(ActivityThread.java:153) 
  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1349) 
  at android.os.Handler.dispatchMessage(Handler.java:102) 
  at android.os.Looper.loop(Looper.java:148) 
  at android.app.ActivityThread.main(ActivityThread.java:5436) 
  at java.lang.reflect.Method.invoke(Native Method) 
  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:735) 
  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625) 
                                                      Suppressed: java.lang.NoClassDefFoundError: com.joostverbraeken.weargame.MainActivity
  at dalvik.system.DexFile.defineClassNative(Native Method)
  at dalvik.system.DexFile.defineClass(DexFile.java:226)
  at dalvik.system.DexFile.loadClassBinaryName(DexFile.java:219)
  at dalvik.system.DexPathList.findClass(DexPathList.java:338)
  at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:54)
          ... 13 more
                                                      Suppressed: java.lang.ClassNotFoundException: com.joostverbraeken.weargame.MainActivity
  at java.lang.Class.classForName(Native Method)
  at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
  at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
  at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
          ... 12 more
                                                      Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available
  </code></pre>
  
  <p>My AndroidManifest (I copied the one from my library into Unity) is as follows:</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.joostverbraeken.weargame"&gt;
  
      &lt;uses-permission android:name="android.permission.WAKE_LOCK" /&gt;
      &lt;uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/&gt;
      &lt;uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/&gt;
      &lt;uses-permission android:name="android.permission.INTERNET"/&gt;
      &lt;uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/&gt;
  
      &lt;application android:icon="@mipmap/ic_launcher" android:label="@string/app_name"&gt;
          &lt;activity android:name=".MainActivity"
              android:label="@string/app_name"
              android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen"&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;/application&gt;
  
  &lt;/manifest&gt;
  </code></pre>
  
  <p>The dependencies are fairly straightforward and are declared in Gradle:</p>
  
  <pre><code>dependencies {
      compile fileTree(dir: 'libs', include: ['*.jar'], exclude: ['classes.jar'])
      provided files('libs/classes.jar')
      wearApp project(':wear')
      compile 'com.google.android.gms:play-services:8.4.0'
      compile 'com.android.support:support-v4:23.4.0'
  }
  </code></pre>
  
  <p>On a forum I read Unity needed to have the dependencies copied into Assets/Plugins/Android, although I'm using an aar instead of a jar. So I copied support-v4-23.3.0-sources.jar into Assets/Plugins/Android as well, but play-services-8.4.0.jar not because it's not included in the Android system files. play-services-8.4.0.aar is included, but if I copy that to Unity I get the following error:</p>
  
  <pre><code>Moving
  Temp/StagingArea\android-libraries\play-services-8.4.0\classes.jar to
  Temp/StagingArea\android-libraries\play-services-8.4.0\bin\classes.jar:
  The system cannot find the file specified.
  </code></pre>
  
  <p>Does anybody have an idea how to solve the ClassNotFoundException?</p>