0

The project uses external JARS with methods which are used on runtime. I have read another post of this forum and the solution is create /libs directory, and add to that the jars you need. However, i have added all of my jars to this directory (correctly created into bellow of /src directory) and when i run the application, it cant find methods from jar, referenced by another jar class. This is the log:

04-20 06:01:42.025: I/dalvikvm(1275): Could not find method com.theoryinpractise.halbuilder.api.RepresentationFactory.readRepresentation, referenced from method com.theoryinpractise.halbuilder.jaxrs.HalUnmarshaller.unmarshal
04-20 06:01:42.025: W/dalvikvm(1275): VFY: unable to resolve virtual method 12369: Lcom/theoryinpractise/halbuilder/api/RepresentationFactory;.readRepresentation (Ljava/io/Reader;)Lcom/theoryinpractise/halbuilder/api/ReadableRepresentation;
04-20 06:01:42.035: D/dalvikvm(1275): VFY: replacing opcode 0x6e at 0x0009
04-20 06:01:42.035: E/dalvikvm(1275): Could not find class 'com.theoryinpractise.halbuilder.standard.StandardRepresentationFactory', referenced from method com.theoryinpractise.halbuilder.jaxrs.HalContext.<clinit>
04-20 06:01:42.035: W/dalvikvm(1275): VFY: unable to resolve new-instance 1707 (Lcom/theoryinpractise/halbuilder/standard/StandardRepresentationFactory;) in Lcom/theoryinpractise/halbuilder/jaxrs/HalContext;
04-20 06:01:42.035: D/dalvikvm(1275): VFY: replacing opcode 0x22 at 0x0000
04-20 06:01:42.045: D/dalvikvm(1275): DexOpt: unable to opt direct call 0x3179 at 0x02 in Lcom/theoryinpractise/halbuilder/jaxrs/HalContext;.<clinit>
04-20 06:01:42.065: W/dalvikvm(1275): Exception Ljava/lang/NoClassDefFoundError; thrown while initializing Lcom/theoryinpractise/halbuilder/jaxrs/HalContext;

Update with complete log:

04-29 05:04:27.969: I/dalvikvm(1221): Could not find method com.theoryinpractise.halbuilder.api.RepresentationFactory.readRepresentation, referenced from method com.theoryinpractise.halbuilder.jaxrs.HalUnmarshaller.unmarshal
04-29 05:04:27.969: W/dalvikvm(1221): VFY: unable to resolve virtual method 19072: Lcom/theoryinpractise/halbuilder/api/RepresentationFactory;.readRepresentation (Ljava/io/Reader;)Lcom/theoryinpractise/halbuilder/api/ReadableRepresentation;
04-29 05:04:27.969: D/dalvikvm(1221): VFY: replacing opcode 0x6e at 0x0009
04-29 05:04:27.979: D/dalvikvm(1221): DexOpt: couldn't find static field Lcom/theoryinpractise/halbuilder/api/RepresentationFactory;.SINGLE_ELEM_ARRAYS
04-29 05:04:27.979: W/dalvikvm(1221): VFY: unable to resolve static field 6502 (SINGLE_ELEM_ARRAYS) in Lcom/theoryinpractise/halbuilder/api/RepresentationFactory;
04-29 05:04:27.979: D/dalvikvm(1221): VFY: replacing opcode 0x62 at 0x0011
04-29 05:04:28.009: W/dalvikvm(1221): Exception Ljava/lang/NoSuchFieldError; thrown while initializing Lcom/theoryinpractise/halbuilder/jaxrs/HalContext;
04-29 05:04:28.009: W/System.err(1221): java.util.concurrent.ExecutionException: java.lang.NoSuchFieldError: com.theoryinpractise.halbuilder.api.RepresentationFactory.SINGLE_ELEM_ARRAYS
04-29 05:04:28.009: W/System.err(1221):     at java.util.concurrent.FutureTask.report(FutureTask.java:93)
04-29 05:04:28.019: W/System.err(1221):     at java.util.concurrent.FutureTask.get(FutureTask.java:163)
04-29 05:04:28.019: W/System.err(1221):     at android.os.AsyncTask.get(AsyncTask.java:483)
04-29 05:04:28.019: W/System.err(1221):     at com.hc.modelo.ObtieneRecursos.obtieneTokenMe(ObtieneRecursos.java:49)
04-29 05:04:28.019: W/System.err(1221):     at com.hc.Holacampus.InitActivity.compruebaUsuario(InitActivity.java:121)
04-29 05:04:28.019: W/System.err(1221):     at com.hc.Holacampus.InitActivity$2.onClick(InitActivity.java:66)
04-29 05:04:28.029: W/System.err(1221):     at android.view.View.performClick(View.java:4438)
04-29 05:04:28.029: W/System.err(1221):     at android.view.View$PerformClick.run(View.java:18422)
04-29 05:04:28.029: W/System.err(1221):     at android.os.Handler.handleCallback(Handler.java:733)
04-29 05:04:28.029: W/System.err(1221):     at android.os.Handler.dispatchMessage(Handler.java:95)
04-29 05:04:28.029: W/System.err(1221):     at android.os.Looper.loop(Looper.java:136)
04-29 05:04:28.029: W/System.err(1221):     at android.app.ActivityThread.main(ActivityThread.java:5017)
04-29 05:04:28.029: W/System.err(1221):     at java.lang.reflect.Method.invokeNative(Native Method)
04-29 05:04:28.029: W/System.err(1221):     at java.lang.reflect.Method.invoke(Method.java:515)
04-29 05:04:28.029: W/System.err(1221):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
04-29 05:04:28.029: W/System.err(1221):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
04-29 05:04:28.029: W/System.err(1221):     at dalvik.system.NativeStart.main(Native Method)
04-29 05:04:28.029: W/System.err(1221): Caused by: java.lang.NoSuchFieldError: com.theoryinpractise.halbuilder.api.RepresentationFactory.SINGLE_ELEM_ARRAYS
04-29 05:04:28.029: W/System.err(1221):     at com.theoryinpractise.halbuilder.jaxrs.HalContext.<clinit>(HalContext.java:60)
04-29 05:04:28.039: W/System.err(1221):     at com.theoryinpractise.halbuilder.jaxrs.HalUnmarshaller.unmarshal(HalUnmarshaller.java:53)
04-29 05:04:28.039: W/System.err(1221):     at com.hc.modelo.ObtencionTokenUsuario.doInBackground(ObtencionTokenUsuario.java:47)
04-29 05:04:28.039: W/System.err(1221):     at com.hc.modelo.ObtencionTokenUsuario.doInBackground(ObtencionTokenUsuario.java:1)
04-29 05:04:28.039: W/System.err(1221):     at android.os.AsyncTask$2.call(AsyncTask.java:288)
04-29 05:04:28.039: W/System.err(1221):     at java.util.concurrent.FutureTask.run(FutureTask.java:237)
04-29 05:04:28.039: W/System.err(1221):     at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
04-29 05:04:28.039: W/System.err(1221):     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
04-29 05:04:28.039: W/System.err(1221):     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
04-29 05:04:28.039: W/System.err(1221):     at java.lang.Thread.run(Thread.java:841)
04-29 05:04:28.039: W/dalvikvm(1221): threadid=11: thread exiting with uncaught exception (group=0xb2ad2ba8)
04-29 05:04:28.099: E/AndroidRuntime(1221): FATAL EXCEPTION: AsyncTask #1
04-29 05:04:28.099: E/AndroidRuntime(1221): Process: com.hc.Holacampus, PID: 1221
04-29 05:04:28.099: E/AndroidRuntime(1221): java.lang.RuntimeException: An error occured while executing doInBackground()
04-29 05:04:28.099: E/AndroidRuntime(1221):     at android.os.AsyncTask$3.done(AsyncTask.java:300)
04-29 05:04:28.099: E/AndroidRuntime(1221):     at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355)
04-29 05:04:28.099: E/AndroidRuntime(1221):     at java.util.concurrent.FutureTask.setException(FutureTask.java:222)
04-29 05:04:28.099: E/AndroidRuntime(1221):     at java.util.concurrent.FutureTask.run(FutureTask.java:242)
04-29 05:04:28.099: E/AndroidRuntime(1221):     at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
04-29 05:04:28.099: E/AndroidRuntime(1221):     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
04-29 05:04:28.099: E/AndroidRuntime(1221):     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
04-29 05:04:28.099: E/AndroidRuntime(1221):     at java.lang.Thread.run(Thread.java:841)
04-29 05:04:28.099: E/AndroidRuntime(1221): Caused by: java.lang.NoSuchFieldError: com.theoryinpractise.halbuilder.api.RepresentationFactory.SINGLE_ELEM_ARRAYS
04-29 05:04:28.099: E/AndroidRuntime(1221):     at com.theoryinpractise.halbuilder.jaxrs.HalContext.<clinit>(HalContext.java:60)
04-29 05:04:28.099: E/AndroidRuntime(1221):     at com.theoryinpractise.halbuilder.jaxrs.HalUnmarshaller.unmarshal(HalUnmarshaller.java:53)
04-29 05:04:28.099: E/AndroidRuntime(1221):     at com.hc.modelo.ObtencionTokenUsuario.doInBackground(ObtencionTokenUsuario.java:47)
04-29 05:04:28.099: E/AndroidRuntime(1221):     at com.hc.modelo.ObtencionTokenUsuario.doInBackground(ObtencionTokenUsuario.java:1)
04-29 05:04:28.099: E/AndroidRuntime(1221):     at android.os.AsyncTask$2.call(AsyncTask.java:288)
04-29 05:04:28.099: E/AndroidRuntime(1221):     at java.util.concurrent.FutureTask.run(FutureTask.java:237)
04-29 05:04:28.099: E/AndroidRuntime(1221):     ... 4 more
04-29 05:04:28.139: W/DefaultRequestDirector(1221): Authentication error: Unable to respond to any of these challenges: {}
04-29 05:04:28.159: I/System.out(1221): Error
04-29 05:04:28.159: D/AndroidRuntime(1221): Shutting down VM
04-29 05:04:28.159: W/dalvikvm(1221): threadid=1: thread exiting with uncaught exception (group=0xb2ad2ba8)
04-29 05:04:28.169: I/Process(1221): Sending signal. PID: 1221 SIG: 9

Which is the problem with the SuchfieldError?

All helps are wellcome.

4

1 回答 1

0

除了将它们添加到 /libs 之外,您是否以任何其他方式将这些 jar 与项目链接?在那里添加 jar 后,您还应该将它们添加到项目 buildpath 项目属性 > 构建路径 > 配置构建路径 > 库选项卡 > 添加 JAR 您使用的是 Eclipse 还是 Android Studio?另外,您使用的是什么构建工具?

于 2015-04-20T10:12:19.760 回答