On Dalvik you'll get that error if you use a custom ClassLoader that loads classes from other ClassLoader(s) (eg. the API of a plugin). If you're using this, you have two options: either dont export the symbols or remove them at runtime[1] (you'll need to move the class definitions and zero out the remaining space).
[1]: https://source.android.com/devices/tech/dalvik/dex-format.html 2014-07-13 14:00 GMT+01:00 shiqun.shi <[email protected]>: > >> I notice this two methods, handleReceiver() and makeApplication()。 >> >> In which case,packageInfo.makeApplication(false, mInstrumentation); was >> called and mApplication == null? Which will make a receiver be >> instantiated(by cl.loadClass(component).newInstance())before >> packageInfo.makeApplication(false, mInstrumentation); and >> instrumentation.callApplicationOnCreate(app);. >> >> >> >> private void handleReceiver(ReceiverData data) { >> >> // If we are getting ready to gc after going to the background, >> well >> >> // we are back active so skip it. >> >> unscheduleGcIdler(); >> >> >> >> String component = data.intent.getComponent().getClassName(); >> >> >> >> LoadedApk packageInfo = getPackageInfoNoCheck( >> >> data.info.applicationInfo, data.compatInfo); >> >> >> >> IActivityManager mgr = ActivityManagerNative.getDefault(); >> >> >> >> BroadcastReceiver receiver; >> >> try { >> >> java.lang.ClassLoader cl = packageInfo.getClassLoader(); >> >> data.intent.setExtrasClassLoader(cl); >> >> data.setExtrasClassLoader(cl); >> >> receiver = >> (BroadcastReceiver)cl.loadClass(component).newInstance(); >> >> } catch (Exception e) { >> >> if (DEBUG_BROADCAST) Slog.i(TAG, >> >> "Finishing failed broadcast to " + >> data.intent.getComponent()); >> >> data.sendFinished(mgr); >> >> throw new RuntimeException( >> >> "Unable to instantiate receiver " + component >> >> + ": " + e.toString(), e); >> >> } >> >> >> >> try { >> >> Application app = packageInfo.makeApplication(false, >> mInstrumentation); >> >> >> >> if (localLOGV) Slog.v( >> >> TAG, "Performing receive of " + data.intent >> >> + ": app=" + app >> >> + ", appName=" + app.getPackageName() >> >> + ", pkg=" + packageInfo.getPackageName() >> >> + ", comp=" + data.intent.getComponent().toShortString() >> >> + ", dir=" + packageInfo.getAppDir()); >> >> >> >> ContextImpl context = (ContextImpl)app.getBaseContext(); >> >> sCurrentBroadcastIntent.set(data.intent); >> >> receiver.setPendingResult(data); >> >> receiver.onReceive(context.getReceiverRestrictedContext(), >> >> data.intent); >> >> } catch (Exception e) { >> >> if (DEBUG_BROADCAST) Slog.i(TAG, >> >> "Finishing failed broadcast to " + >> data.intent.getComponent()); >> >> data.sendFinished(mgr); >> >> if (!mInstrumentation.onException(receiver, e)) { >> >> throw new RuntimeException( >> >> "Unable to start receiver " + component >> >> + ": " + e.toString(), e); >> >> } >> >> } finally { >> >> sCurrentBroadcastIntent.set(null); >> >> } >> >> >> >> if (receiver.getPendingResult() != null) { >> >> data.finish(); >> >> } >> >> } >> >> >> >> >> >> public Application makeApplication(boolean forceDefaultAppClass, >> >> Instrumentation instrumentation) { >> >> if (mApplication != null) { >> >> return mApplication; >> >> } >> >> >> >> Application app = null; >> >> >> >> String appClass = mApplicationInfo.className; >> >> if (forceDefaultAppClass || (appClass == null)) { >> >> appClass = "android.app.Application"; >> >> } >> >> >> >> try { >> >> java.lang.ClassLoader cl = getClassLoader(); >> >> ContextImpl appContext = new ContextImpl(); >> >> appContext.init(this, null, mActivityThread); >> >> app = mActivityThread.mInstrumentation.newApplication( >> >> cl, appClass, appContext); >> >> appContext.setOuterContext(app); >> >> } catch (Exception e) { >> >> if (!mActivityThread.mInstrumentation.onException(app, e)) { >> >> throw new RuntimeException( >> >> "Unable to instantiate application " + appClass >> >> + ": " + e.toString(), e); >> >> } >> >> } >> >> mActivityThread.mAllApplications.add(app); >> >> mApplication = app; >> >> >> >> if (instrumentation != null) { >> >> try { >> >> instrumentation.callApplicationOnCreate(app); >> >> } catch (Exception e) { >> >> if (!instrumentation.onException(app, e)) { >> >> throw new RuntimeException( >> >> "Unable to create application " + >> app.getClass().getName() >> >> + ": " + e.toString(), e); >> >> } >> >> } >> >> } >> >> >> >> return app; >> >> } >> >> > > -- > You received this message because you are subscribed to the Google > Groups "Android Developers" group. > To post to this group, send email to [email protected] > To unsubscribe from this group, send email to > [email protected] > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en > --- > You received this message because you are subscribed to the Google Groups > "Android Developers" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en --- You received this message because you are subscribed to the Google Groups "Android Developers" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.

