title: Find all classes in a package in Android
body: <p>How can i find all classes inside a package on Android? I use PathClassLoader, but it always returns an empty enumeration?</p>
  
  <p>Additional info</p>
  
  <p>Tried the suggested Reflections approach. Couple of important points about reflections library. The library available through maven central is not compatible with Android and gives dex errors. I had to include source and compile dom4j, java-assist. </p>
  
  <p>The problem with reflections, and my original solution is that PathClassLoader in android returns an empty enumeration for package. </p>
  
  <p>The issue with approach is that getResource in Android is always returning empty enumeration.</p>
  
  <pre><code>final String resourceName = aClass.getName().replace(".", "/") + ".class";
  
  for (ClassLoader classLoader : loaders) {
        try {
              final URL url = classLoader.getResource(resourceName);
              if (url != null) {
                  final String normalizedUrl = url.toExternalForm().substring(0, url.toExternalForm().lastIndexOf(aClass.getPackage().getName().replace(".", "/")));
                  return new URL(normalizedUrl);
              }
          } catch (MalformedURLException e) {
              e.printStackTrace();
          }
     }
  </code></pre>