title: Android ClassNotFoundException
body: <p>I am having a problem with one of my apps and I was wondering if anyone could give me any insight into what maybe causing it.</p>
  
  <p>I am getting a <strong>ClassNotFoundException</strong>, the important line below is</p>
  
  <pre><code>E/AndroidRuntime(21982): Caused by: java.lang.ClassNotFoundException: couk.doridori.goigo.customUI.GoBoardView in loader dalvik.system.PathClassLoader@446fc3d0
  </code></pre>
  
  <p>Now this app has been out for over a year and 2 days ago I had two seperate users contact me regarding this issue, one on a HTC wildfire (2.1) and one a Samsung Galaxy S (?). Now I cannot recreate this problem on my devices (2.2 and 1.6) or an emulator (2.1) and cannot really work out why this class cannot be found by the classloader. I have spent a while googling to no avail, and hopes someone has some pointers! It only seems to be when an activity is loaded which when the contentView is set, it tries to inflate a custom View called <strong>GoBoardView</strong> which extends the View class, this is just doing some simple canvas drawing and is not using any third party libs or any other classes that would have a packagename clash or anything.</p>
  
  <p>Please help! Just in case its a build issue I am updating all my SDK and ADT through eclipse as it was building against 1.6 and using the old ADT, but I have no idea if this will help just thought worth a try. Any advice would be great thanks! (see below for EDIT)</p>
  
  <pre><code>E/AndroidRuntime(21982): java.lang.RuntimeException: Unable to start activity ComponentInfo{couk.doridori.goigoFull/couk.doridori.goigoFull.Board}: android.view.InflateException: Binary XML file line #14: Error inflating class couk.doridori.goigo.customUI.GoBoardView
  E/AndroidRuntime(21982): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2596)
  E/AndroidRuntime(21982): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2621)
  E/AndroidRuntime(21982): at android.app.ActivityThread.access$2200(ActivityThread.java:126)
  E/AndroidRuntime(21982): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1932)
  E/AndroidRuntime(21982): at android.os.Handler.dispatchMessage(Handler.java:99)
  E/AndroidRuntime(21982): at android.os.Looper.loop(Looper.java:123)
  E/AndroidRuntime(21982): at android.app.ActivityThread.main(ActivityThread.java:4603)
  E/AndroidRuntime(21982): at java.lang.reflect.Method.invokeNative(Native Method)
  E/AndroidRuntime(21982): at java.lang.reflect.Method.invoke(Method.java:521)
  E/AndroidRuntime(21982): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
  E/AndroidRuntime(21982): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
  E/AndroidRuntime(21982): at dalvik.system.NativeStart.main(Native Method)
  E/AndroidRuntime(21982): Caused by: android.view.InflateException: Binary XML file line #14: Error inflating class couk.doridori.goigo.customUI.GoBoardView
  E/AndroidRuntime(21982): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:576)
  E/AndroidRuntime(21982): at android.view.LayoutInflater.rInflate(LayoutInflater.java:618)
  E/AndroidRuntime(21982): at android.view.LayoutInflater.rInflate(LayoutInflater.java:621)
  E/AndroidRuntime(21982): at android.view.LayoutInflater.rInflate(LayoutInflater.java:621)
  E/AndroidRuntime(21982): at android.view.LayoutInflater.inflate(LayoutInflater.java:407)
  E/AndroidRuntime(21982): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
  E/AndroidRuntime(21982): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
  E/AndroidRuntime(21982): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:207)
  E/AndroidRuntime(21982): at android.app.Activity.setContentView(Activity.java:1629)
  E/AndroidRuntime(21982): at couk.doridori.goigoFull.Board.onCreate(Board.java:31)
  E/AndroidRuntime(21982): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
  E/AndroidRuntime(21982): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2544)
  E/AndroidRuntime(21982): ... 11 more
  E/AndroidRuntime(21982): Caused by: java.lang.ClassNotFoundException: couk.doridori.goigo.customUI.GoBoardView in loader dalvik.system.PathClassLoader@446fc3d0
  E/AndroidRuntime(21982): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
  E/AndroidRuntime(21982): at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
  E/AndroidRuntime(21982): at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
  E/AndroidRuntime(21982): at android.view.LayoutInflater.createView(LayoutInflater.java:466)
  E/AndroidRuntime(21982): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:565)
  E/AndroidRuntime(21982): ... 22 more
  </code></pre>
  
  <p><strong>EDIT</strong></p>
  
  <p>Ok, researching some of the links that users to have commented in reply to this question, it seems that the use of the wrong context for loading activities can cause this problem. I find this interesting becuase <strong>one</strong> of the <strong>two</strong> log reports i have been send has this exception preceeded by </p>
  
  <pre><code>W/ActivityManager( 1222): startActivity called from non-Activity context; forcing Intent.FLAG_ACTIVITY_NEW_TASK for: Intent { flg=0x20000 cmp=couk.doridori.goigoFull/.Games }
  </code></pre>
  
  <p>which is quite self explanatory - problem is i have no idea where this activity could be being started from where it uses a non activity context, so im a bit stumped, thinking it maye be some multitasking like quirk and its being brought back into the foreground of something . This can then apparently cause problems with the classLoader. If this was happening on a users phone i cant see why i cannot reproduce this (and most other users cannot either).</p>
  
  <p>The other thing i found through the links which is interesting, is some people have encountered problems due to a "incorrect apk installation', which can be resolved by a reinstall, which i have asked the users who have had the problem to try (which does not make a difference). Also it seems once the problem is encountered (which is on first use) it will be persistent.</p>