java - Android ClassNotFoundException on source file in a different package -
i've managed noclassdeffounderror
caused classnotfoundexception
trying access class in separate package.
i have written code reproduce problem pressing button calls function below stack traces.
what doesn't make sense though have source file in project, doesn't find class.
stack trace:
07-13 15:58:40.317: e/x(2517): x- java.lang.noclassdeffounderror: failed resolution of: lobd/obdgatewayservice; 07-13 15:58:40.317: e/xx(2517): xx- 07-13 15:58:40.317: e/xx(2517): java.lang.noclassdeffounderror: failed resolution of: lobd/obdgatewayservice; 07-13 15:58:40.317: e/xx(2517): @ piccolo.android.panda18.obdtaximeter.dobindservice(obdtaximeter.java:856) 07-13 15:58:40.317: e/xx(2517): @ piccolo.android.panda18.obdtaximeter.startlivedata(obdtaximeter.java:823) 07-13 15:58:40.317: e/xx(2517): @ piccolo.android.panda18.obdtaximeter.access$8(obdtaximeter.java:818) 07-13 15:58:40.317: e/xx(2517): @ piccolo.android.panda18.obdtaximeter$3.onclick(obdtaximeter.java:313) 07-13 15:58:40.317: e/xx(2517): @ android.view.view.performclick(view.java:5217) 07-13 15:58:40.317: e/xx(2517): @ android.view.view$performclick.run(view.java:20983) 07-13 15:58:40.317: e/xx(2517): @ android.os.handler.handlecallback(handler.java:739) 07-13 15:58:40.317: e/xx(2517): @ android.os.handler.dispatchmessage(handler.java:95) 07-13 15:58:40.317: e/xx(2517): @ android.os.looper.loop(looper.java:145) 07-13 15:58:40.317: e/xx(2517): @ android.app.activitythread.main(activitythread.java:6117) 07-13 15:58:40.317: e/xx(2517): @ java.lang.reflect.method.invoke(native method) 07-13 15:58:40.317: e/xx(2517): @ java.lang.reflect.method.invoke(method.java:372) 07-13 15:58:40.317: e/xx(2517): @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:1399) 07-13 15:58:40.317: e/xx(2517): @ com.android.internal.os.zygoteinit.main(zygoteinit.java:1194) 07-13 15:58:40.317: e/xx(2517): caused by: java.lang.classnotfoundexception: didn't find class "obd.obdgatewayservice" on path: dexpathlist[[zip file "/system/framework/com.google.android.maps.jar", zip file "/data/app/piccolo.android.panda18-2/base.apk"],nativelibrarydirectories=[/data/app/piccolo.android.panda18-2/lib/arm, /vendor/lib, /system/lib]] 07-13 15:58:40.317: e/xx(2517): @ dalvik.system.basedexclassloader.findclass(basedexclassloader.java:56) 07-13 15:58:40.317: e/xx(2517): @ java.lang.classloader.loadclass(classloader.java:511) 07-13 15:58:40.317: e/xx(2517): @ java.lang.classloader.loadclass(classloader.java:469) 07-13 15:58:40.317: e/xx(2517): ... 14 more 07-13 15:58:40.317: e/xx(2517): suppressed: java.lang.noclassdeffounderror: obd.obdgatewayservice 07-13 15:58:40.317: e/xx(2517): @ dalvik.system.dexfile.defineclassnative(native method) 07-13 15:58:40.317: e/xx(2517): @ dalvik.system.dexfile.defineclass(dexfile.java:226) 07-13 15:58:40.317: e/xx(2517): @ dalvik.system.dexfile.loadclassbinaryname(dexfile.java:219) 07-13 15:58:40.317: e/xx(2517): @ dalvik.system.dexpathlist.findclass(dexpathlist.java:321) 07-13 15:58:40.317: e/xx(2517): @ dalvik.system.basedexclassloader.findclass(basedexclassloader.java:54) 07-13 15:58:40.317: e/xx(2517): ... 16 more 07-13 15:58:40.317: e/xx(2517): suppressed: java.lang.classnotfoundexception: obd.obdgatewayservice 07-13 15:58:40.317: e/xx(2517): @ java.lang.class.classforname(native method) 07-13 15:58:40.317: e/xx(2517): @ java.lang.bootclassloader.findclass(classloader.java:781) 07-13 15:58:40.317: e/xx(2517): @ java.lang.bootclassloader.loadclass(classloader.java:841) 07-13 15:58:40.317: e/xx(2517): @ java.lang.classloader.loadclass(classloader.java:504) 07-13 15:58:40.317: e/xx(2517): ... 15 more 07-13 15:58:40.317: e/xx(2517): caused by: java.lang.noclassdeffounderror: class not found using boot class loader; no stack available
note above stacktrace produced first time press button. subsequent button presses result in shorter, different version of (see below).
07-13 15:31:59.767: e/x(32078): x- java.lang.noclassdeffounderror: obd.obdgatewayservice 07-13 15:31:59.767: e/xx(32078): xx- 07-13 15:31:59.767: e/xx(32078): java.lang.noclassdeffounderror: obd.obdgatewayservice 07-13 15:31:59.767: e/xx(32078): @ piccolo.android.panda18.obdtaximeter.dobindservice(obdtaximeter.java:856) 07-13 15:31:59.767: e/xx(32078): @ piccolo.android.panda18.obdtaximeter.startlivedata(obdtaximeter.java:823) 07-13 15:31:59.767: e/xx(32078): @ piccolo.android.panda18.obdtaximeter.access$8(obdtaximeter.java:818) 07-13 15:31:59.767: e/xx(32078): @ piccolo.android.panda18.obdtaximeter$3.onclick(obdtaximeter.java:313) 07-13 15:31:59.767: e/xx(32078): @ android.view.view.performclick(view.java:5217) 07-13 15:31:59.767: e/xx(32078): @ android.view.view$performclick.run(view.java:20983) 07-13 15:31:59.767: e/xx(32078): @ android.os.handler.handlecallback(handler.java:739) 07-13 15:31:59.767: e/xx(32078): @ android.os.handler.dispatchmessage(handler.java:95) 07-13 15:31:59.767: e/xx(32078): @ android.os.looper.loop(looper.java:145) 07-13 15:31:59.767: e/xx(32078): @ android.app.activitythread.main(activitythread.java:6117) 07-13 15:31:59.767: e/xx(32078): @ java.lang.reflect.method.invoke(native method) 07-13 15:31:59.767: e/xx(32078): @ java.lang.reflect.method.invoke(method.java:372) 07-13 15:31:59.767: e/xx(32078): @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:1399) 07-13 15:31:59.767: e/xx(32078): @ com.android.internal.os.zygoteinit.main(zygoteinit.java:1194)
section of code that's causing error:
// obdtaximeter class, , called whenever press specific button. have try/catch i'm calling log error above private void dobindservice() { if (!isservicebound) { log.d(tag, "binding obd service.."); if (prerequisites) { intent serviceintent = new intent(this, obdgatewayservice.class); // specifically, line bindservice(serviceintent, serviceconn, context.bind_auto_create); } else { intent serviceintent = new intent(this, mockobdgatewayservice.class); bindservice(serviceintent, serviceconn, context.bind_auto_create); } } }
screenshot of solution explorer:
the yellow highlighted portion shows file indeed in same project, in different package, red line represents code that's trying use missing class called.
i've considered may problem manifest declaration, can't find wrong - may wrong, i'm including condensed version containing relevant bits below.
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="piccolo.android.panda18" android:versioncode="1" android:versionname="1.0"> <activity android:name="obdtaximeter" /> <activity android:name="obd.configactivity" /> <service android:enabled="true" android:name="obd.mockobdgatewayservice" /> <service android:enabled="true" android:name="obd.obdgatewayservice" /> </application> </manifest>
i've tried cleaning , rebuilding (too many times count). made sure build path correct (in terms of appcompat libraries, export order , whatnot), in case, i'm including screenshot of "order , export" screen eclipse below.
i've checked classes.dex file, , find obdgatewayservice
class listings inside it.
listing of class in classes.dex:
class #239 - class descriptor : 'lobd/obdgatewayservice$1;' access flags : 0x0000 () superclass : 'ljava/lang/object;' interfaces - #0 : 'ljava/lang/runnable;' static fields - instance fields - #0 : (in lobd/obdgatewayservice$1;) name : 'this$0' type : 'lobd/obdgatewayservice;' access : 0x1010 (final synthetic) #1 : (in lobd/obdgatewayservice$1;) name : 'val$job2' type : 'lobd/obdcommandjob;' access : 0x1012 (private final synthetic) direct methods - #0 : (in lobd/obdgatewayservice$1;) name : '<init>' type : '(lobd/obdgatewayservice;lobd/obdcommandjob;)v' access : 0x10000 (constructor) code - registers : 3 ins : 3 outs : 1 insns size : 8 16-bit code units catches : (none) positions : 0x0000 line=1 0x0004 line=240 locals : 0x0000 - 0x0008 reg=0 lobd/obdgatewayservice$1; virtual methods - #0 : (in lobd/obdgatewayservice$1;) name : 'run' type : '()v' access : 0x0001 (public) code - registers : 3 ins : 1 outs : 2 insns size : 12 16-bit code units catches : (none) positions : 0x0000 line=243 0x000b line=244 locals : 0x0000 - 0x000c reg=2 lobd/obdgatewayservice$1; source_file_idx : 4574 (obdgatewayservice.java)
why happening?
start intent this:
intent intent = new intent(); intent.setclassname("obd", "obd.obdgatewayservice"); startservice(intent);
Comments
Post a Comment