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.

Asier
  • 461
  • 9
  • 19

1 Answers1

0

Did you link those jars with the projects in any other way than adding them to /libs ? After you added jars there, you should also add them to the project buildpath Project properties > Build Path > Configure Build Path > Libraries tab > Add JARs Are you using Eclipse or Android Studio? Also, what build tools are you using?

luciferche
  • 134
  • 9
  • After add the jars to the directory /libs, they already are automatically linked to "private android libraries" at the build path. That is more, if that was the error, the app will show compilation errors. – Asier Apr 20 '15 at 10:23
  • Ok, just checking, i should've put it in comment though... What Java version was used to compile jars? – luciferche Apr 20 '15 at 10:30
  • i have installed Java8, but the class of .jar which my application can not find was downloaded from maven central: Halbuilder-api4.0.1 – Asier Apr 20 '15 at 10:45
  • Try to set compiler to Java 1.6 or Java 1.7 and rebuild the project. Android does not support java8 yet. – luciferche Apr 20 '15 at 11:07
  • Sorry, i revised the Java properties of exported to jar projects and they were exported with Java 1.7. – Asier Apr 20 '15 at 11:21
  • Ok, good, but did you check your android project properties? Put there compiler compliance level to 1.6 for example and try to rebuild. – luciferche Apr 20 '15 at 14:29
  • First of all i forgot tell you thanks ^^. Now, i checked Java compiler level of my android project and it was on 1.6. I changed it to 1.7 (same as .jars compiler level). However, i hava the same problem. Exists some problem if the halbuilder-api version used by .jar librarys is 2.2.1 and the version of the library that i imported is 4.0.1? – Asier Apr 22 '15 at 09:45
  • Please, i cant solve this.. i already read all posts without lucky... The .jars are on /libs directory, all is compiled with 1.7 java level... I dont understand why happens this. – Asier Apr 27 '15 at 17:57
  • I added another jars which were causing errors and i have updated the logcat of the post. – Asier Apr 29 '15 at 09:37