砂浆/流动样品NoClassDefFoundError:com.example.mortar.MortarDemoApplication $ 1

时间:2015-01-19 22:48:17

标签: android eclipse maven dagger mortar

我很难让Mortar / Flow示例通过Eclipse&行家。

我的.apt_generated文件夹已创建,该目录中有许多生成的类,但由于某种原因未生成MortarDemoApplication$1

我已经通过大量示例和其他线程来解决此问题,但似乎找不到任何有效的解决方案。

我在Eclipse中启用了注释处理,并且我已将Factory路径配置为包括dagger,dagger-compiler和javawriter。我已经读到这不应该是必要的,因为Eclipse m2e-apt插件应该处理这个,但这似乎是我可以生成.apt_generated源的唯一方法。

在某个地方是否有一套确定的指令可能我不在?

更新1

从命令行(没有Eclipse)使用Maven构建和运行会出现一系列问题。

首先,当尝试从迫击炮目录运行mvn install时,最新的Maven 3.2.5会抛出以下错误:

  Exception in thread "main" java.lang.NoClassDefFoundError: org/eclipse/aether/spi/connector/Transfer$State
    at org.eclipse.aether.connector.wagon.WagonRepositoryConnector$GetTask.run(WagonRepositoryConnector.java:608)
    at org.eclipse.aether.util.concurrency.RunnableErrorForwarder$1.run(RunnableErrorForwarder.java:67)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
  Caused by: java.lang.ClassNotFoundException: org.eclipse.aether.spi.connector.Transfer$State
    at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:50)
    at org.codehaus.plexus.classworlds.realm.ClassRealm.unsynchronizedLoadClass(ClassRealm.java:271)
    at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:247)
    at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:239)
    ... 5 more

切换回Maven 3.1.1后mvn deploy可以正常工作,但是当通过mvn android:run运行它时,通过logcat运行它会使cm-helloworld应用程序崩溃:

D/AndroidRuntime( 2820): 
D/AndroidRuntime( 2820): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<<
D/AndroidRuntime( 2820): CheckJNI is ON
E/memtrack( 2820): Couldn't load memtrack module (No such file or directory)
E/android.os.Debug( 2820): failed to load memtrack module: -2
D/AndroidRuntime( 2820): Calling main entry com.android.commands.am.Am
D/AndroidRuntime( 2820): Shutting down VM
I/ActivityManager( 1315): Start proc com.example.hellomortar for activity com.example.hellomortar/.HelloActivity: pid=2831 uid=10057 gids={50057, 9997} abi=x86_64
E/art     ( 2831): Failed sending reply to debugger: Broken pipe
I/art     ( 2831): Debugger is no longer active
D/AndroidRuntime( 2831): Shutting down VM
E/AndroidRuntime( 2831): FATAL EXCEPTION: main
E/AndroidRuntime( 2831): Process: com.example.hellomortar, PID: 2831
E/AndroidRuntime( 2831): java.lang.NoClassDefFoundError: Failed resolution of: Lmortar/Mortar;
E/AndroidRuntime( 2831):    at com.example.hellomortar.HelloApplication.onCreate(HelloApplication.java:29)
E/AndroidRuntime( 2831):    at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1011)
E/AndroidRuntime( 2831):    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4518)
E/AndroidRuntime( 2831):    at android.app.ActivityThread.access$1500(ActivityThread.java:144)
E/AndroidRuntime( 2831):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1339)
E/AndroidRuntime( 2831):    at android.os.Handler.dispatchMessage(Handler.java:102)
E/AndroidRuntime( 2831):    at android.os.Looper.loop(Looper.java:135)
E/AndroidRuntime( 2831):    at android.app.ActivityThread.main(ActivityThread.java:5221)
E/AndroidRuntime( 2831):    at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime( 2831):    at java.lang.reflect.Method.invoke(Method.java:372)
E/AndroidRuntime( 2831):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
E/AndroidRuntime( 2831):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
E/AndroidRuntime( 2831): Caused by: java.lang.ClassNotFoundException: Didn't find class "mortar.Mortar" on path: DexPathList[[zip file "/data/app/com.example.hellomortar-2/base.apk"],nativeLibraryDirectories=[/vendor/lib64, /system/lib64]]
E/AndroidRuntime( 2831):    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
E/AndroidRuntime( 2831):    at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
E/AndroidRuntime( 2831):    at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
E/AndroidRuntime( 2831):    ... 12 more
E/AndroidRuntime( 2831):    Suppressed: java.lang.ClassNotFoundException: mortar.Mortar
E/AndroidRuntime( 2831):        at java.lang.Class.classForName(Native Method)
E/AndroidRuntime( 2831):        at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
E/AndroidRuntime( 2831):        at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
E/AndroidRuntime( 2831):        at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
E/AndroidRuntime( 2831):        ... 13 more
E/AndroidRuntime( 2831):    Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available
W/ActivityManager( 1315):   Force finishing activity com.example.hellomortar/.HelloActivity
D/gralloc (  948): Registering a buffer in the process that created it. This may cause memory ordering problems.
E/libEGL  (  948): called unimplemented OpenGL ES API
E/SurfaceFlinger(  948): glCheckFramebufferStatusOES error 1332776638
E/SurfaceFlinger(  948): got GL_FRAMEBUFFER_COMPLETE_OES error while taking screenshot
W/WindowManager( 1315): Screenshot failure taking screenshot for (800x1280) to layer 22010
E/ActivityManager( 1315): Invalid thumbnail dimensions: 420x420
W/ActivityManager( 1315): Activity pause timeout for ActivityRecord{515bd0e u0 com.example.hellomortar/.HelloActivity t20 f}
W/ActivityManager( 1315): Activity destroy timeout for ActivityRecord{515bd0e u0 com.example.hellomortar/.HelloActivity t20 f}
D/TaskPersister( 1315): removeObsoleteFile: deleting file=20_task.xml
W/BatteryStatsImpl( 1315): Couldn't get kernel wake lock stats
I/Process ( 2831): Sending signal. PID: 2831 SIG: 9

0 个答案:

没有答案