java - Android application throws Guice exception -
i'm new in android applcation , wrong. i've tried compile application javampd modue throws exception: "com.google.inject.internal.util.$computationexception: com.google.inject.internal.util.$computationexception: java.lang.exceptionininitializererror" @ biulder creation:
try { mpd.builder mpdbuilder = new mpd.builder(); } catch (exception error) { string text = error.getmessage(); toast.maketext(this, "exception: " + text, toast.length_long).show(); }
i've traced exception guice , figured out exception throwing inside javampd module
injector = guice.createinjector(new mpdmodule());
here full stack trace:
w/nalizablereferencequeue: not load finalizer in own class loader. loading finalizer in current class loader instead. result, not able garbage collect class loader. support reclaiming class loader, either resolve underlying issue, or move google collections system class path. java.io.filenotfoundexception: com/google/inject/internal/util/$finalizer.class @ com.google.inject.internal.util.$finalizablereferencequeue$decoupledloader.getbaseurl(finalizablereferencequeue.java:269) @ com.google.inject.internal.util.$finalizablereferencequeue$decoupledloader.loadfinalizer(finalizablereferencequeue.java:253) @ com.google.inject.internal.util.$finalizablereferencequeue.loadfinalizer(finalizablereferencequeue.java:175) @ com.google.inject.internal.util.$finalizablereferencequeue.<clinit>(finalizablereferencequeue.java:100) @ com.google.inject.internal.util.$mapmaker$queueholder.<clinit>(mapmaker.java:787) @ com.google.inject.internal.util.$mapmaker$weakentry.<init>(mapmaker.java:946) @ com.google.inject.internal.util.$mapmaker$strength$1.newentry(mapmaker.java:312) @ com.google.inject.internal.util.$mapmaker$strategyimpl.newentry(mapmaker.java:498) @ com.google.inject.internal.util.$mapmaker$strategyimpl.newentry(mapmaker.java:419) @ com.google.inject.internal.util.$customconcurrenthashmap$computingimpl.get(customconcurrenthashmap.java:2029) @ com.google.inject.internal.annotations$annotationchecker.hasannotations(annotations.java:116) @ com.google.inject.internal.annotations.isscopeannotation(annotations.java:124) @ com.google.inject.internal.scopebindingprocessor.visit(scopebindingprocessor.java:40) @ com.google.inject.internal.scopebindingprocessor.visit(scopebindingprocessor.java:30) @ com.google.inject.spi.scopebinding.acceptvisitor(scopebinding.java:59) @ com.google.inject.internal.abstractprocessor.process(abstractprocessor.java:55) @ com.google.inject.internal.injectorshell$builder.build(injectorshell.java:165) @ com.google.inject.internal.internalinjectorcreator.build(internalinjectorcreator.java:103) @ com.google.inject.guice.createinjector(guice.java:95) @ com.google.inject.guice.createinjector(guice.java:72) @ com.google.inject.guice.createinjector(guice.java:62) @ org.bff.javampd.mpd$builder.<init>(mpd.java:186) @ com.yarygin.alex.mpd_test.mainactivity.oncreate(mainactivity.java:16) @ android.app.activity.performcreate(activity.java:5971) @ android.app.instrumentation.callactivityoncreate(instrumentation.java:1111) @ android.app.activitythread.performlaunchactivity(activitythread.java:2413) @ android.app.activitythread.handlelaunchactivity(activitythread.java:2522) @ android.app.activitythread.access$800(activitythread.java:167) @ android.app.activitythread$h.handlemessage(activitythread.java:1417) @ android.os.handler.dispatchmessage(handler.java:111) @ android.os.looper.loop(looper.java:194) @ android.app.activitythread.main(activitythread.java:5534) @ java.lang.reflect.method.invoke(native method) @ java.lang.reflect.method.invoke(method.java:372) @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:955) @ com.android.internal.os.zygoteinit.main(zygoteinit.java:750)
my gradle file:
apply plugin: 'com.android.application' android { compilesdkversion 22 buildtoolsversion "22.0.1" defaultconfig { applicationid "com.yarygin.alex.mpd_test" minsdkversion 15 targetsdkversion 22 versioncode 1 versionname "1.0" testinstrumentationrunner "android.support.test.runner.androidjunitrunner" } buildtypes { release { minifyenabled false proguardfiles getdefaultproguardfile('proguard-android.txt'), 'proguard-rules.pro' } } compileoptions { sourcecompatibility javaversion.version_1_7 targetcompatibility javaversion.version_1_7 } } dependencies { compile filetree(include: ['*.jar'], dir: 'libs') androidtestcompile('com.android.support.test.espresso:espresso-core:2.2.2', { exclude group: 'com.android.support', module: 'support-annotations' }) compile 'com.android.support:appcompat-v7:22.2.1' testcompile 'junit:junit:4.12' compile 'net.thejavashop:javampd:5.0.3' }
and activity file:
package com.yarygin.alex.mpd_test; import android.support.v7.app.appcompatactivity; import android.os.bundle; import android.widget.toast; import org.bff.javampd.mpd; public class mainactivity extends appcompatactivity { @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); try { mpd.builder mpdbuilder = new mpd.builder(); } catch (exception error) { string text = error.getmessage(); toast.maketext(this, "exception: " + text, toast.length_long).show(); } } }
i can not find reason in 2 weeks. please help!
although android apps written in java, cannot take java libraries , use them in android app without configuration issues.
if library, java mpd, depends internally on guice, difficult use as-is inside android project. because guice has number of configuration issues working android. besides, there other issues consider. demonstrate, quote faq of 1 of other di frameworks android:
- guice slow, @ least didn't match more expected performance of android apps.
- guice 4 uses guava contains tens of thousands of methods contribute multidex issues , heavy apks
- guice uses reflection , reflection slow on android. because there no jit of reflection code opposed pc jvms.
you try using roboguice, uses fork of guice , annotations processor around guice's use of reflection , other integration issues android. if provides enough of guice classes make mdp library work surprised. otherwise, have find library use.
Comments
Post a Comment