Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>It means that your JAR file does not have the all class files.</p> <p><strong>NoClassDefFoundError</strong> appears only when it fails to find <strong>.class</strong> file of java class.</p> <p>as the class file is not present you cant access any function or variable from that class.</p> <p>To solve this issue,</p> <p>n eclipse when you export the jar file it includes only the classes which don't have any errors or warnings.So, to generate jar file with all the classes including warnings you need to select <strong>generate Jar with warnings</strong>.</p> <p>Then put this jar file in <strong>libs</strong> folder instead of <strong>lib</strong> folder.</p> <p>Then add this jar to your build path.</p> <p>As you want to import the resources,</p> <p>Since Android makes R class automatically with resources files under /res folder, using R class as final static is impossible.</p> <p>in your source code which will be exported in jar file, DON'T USE R variable because it will be replaced with final static memory address in compile time. Instead of using R, use method below.</p> <pre><code> public static int getResourseIdByName(String packageName, String className, String name) { Class r = null; int id = 0; try { r = Class.forName(packageName + ".R"); Class[] classes = r.getClasses(); Class desireClass = null; for (int i = 0; i &lt; classes.length; i++) { if(classes[i].getName().split("\\$")[1].equals(className)) { desireClass = classes[i]; break; } } if(desireClass != null) id = desireClass.getField(name).getInt(desireClass); } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (SecurityException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (NoSuchFieldException e) { e.printStackTrace(); } return id; } </code></pre> <p>For example, if you have a layout named "main.xml", you can get it by calling method</p> <pre><code>int id = getResourceIdByName(context.getPackageName(), "layout", "main"); </code></pre> <p>and if you have a string whose id is "text1", you can get it by calling method</p> <pre><code>int id = getResourceIdByName(context.getPackageName(), "string", "text1"); </code></pre> <p>this method gives you your resource id in runtime. It uses reflection api to get R's status in runtime.</p> <p>So now you can avoid using R variable and resources ewrrors by using this method</p> <p>copy your res to target project.</p> <p>And finally run your project.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload