01-04 18:37:56.113: E/dalvikvm(12153): Could not find class 'com.google.gson.Gson', referenced from method com.applix.nsa.AddActivity.onClick
01-04 18:37:56.113: W/dalvikvm(12153): VFY: unable to resolve new-instance 730 (Lcom/google/gson/Gson;) in Lcom/applix/nsa/AddActivity;
01-04 18:41:06.209: E/AndroidRuntime(12153): FATAL EXCEPTION: main
01-04 18:41:06.209: E/AndroidRuntime(12153): java.lang.NoClassDefFoundError: com.google.gson.Gson
01-04 18:41:06.209: E/AndroidRuntime(12153): at com.applix.nsa.AddActivity.onClick(AddActivity.java:55)
I normally do not copy "external" jars to my eclipse projects. Instead, I tell Eclipse to include them in the project build path as external jars. For some of the really common external jars, such as Tomcat's servlet and JSP API jars, I go one step further and have them defined as symbolic references.
That's opposed to "external" as in third-party jars specific to the project, which I would generally copy into the project and use the library "Add jar" button on the project build dialog.
Note that defining a jar in the Eclipse build path may not be enough. If you build externally using Maven or Ant, those tools have their own inclusion mechanisms that have to be configured.
Finally, the classpath used when running an app in Eclipse may not be identical to the build classpath. In particular, if the profile for a test run was made before the library was added to the build profile, you should check the debug/run profile you are using to make sure that it picks up the jar, and if it didn't, update that profile. You can edit the debug/run profile by pulling the Run/Run Configurations... (or Debug Configurations) dialog, then searching it for the run profile of that project.
Customer surveys are for companies who didn't pay proper attention to begin with.
Actually, since this is an Android app, the rules are very different.
You may have a fundamental problem, since Android doesn't really run Java, it runs Dalvik, and Dalvik classes are not binary compatible with actual Java classes (or vice versa, for that matter). So if you dump a Java Jar into an Android app, it won't work.
You would have to re-create the classes in your Java Jar as Dalvik (Android) classes and include them in the installed module (apk), then run them under the Android emulator.
Ron McLeod wrote:I use gson-2.2.3 in one Android app and it works fine.
I just tried with gson-2.2.4 and it does in fact work fine. And you are correct that all I had to do was drop in the lib directory. No mucking around with classpath or manifest.
Ron McLeod wrote:Android does compile to byte code and then runs a tool called dx to translate/cross-compile Java byte code into instructions which run on the Dalvik VM.
I did know that. I didn't realize it cross-compile code in jars too.
Ron McLeod wrote:The support library that you reference is used to provide applications which are targeted for earlier API versions (like Gingerbread for example) to use the newer APIs (like support for fragments).
Good to know.
Ron McLeod wrote:You are wrong with both your statements.
I stand corrected. I'm giving you two cows for standing your ground when two moderators told you this is impossible. Thank you for that. I'm happy to have learned something new.