Android problem - sample


#1

Dear Sir, Madam,

I have used Shinobi Charts for iOS successfully, and am trying to include these Charts in Android as well. A good start I thought would be to see the sample.

When I try to run the sample app I get the following error messages:

06-04 09:57:53.471: E/AndroidRuntime(1090): FATAL EXCEPTION: main

06-04 09:57:53.471: E/AndroidRuntime(1090): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.shinobicontrols.sample.hellolinechart/com.shinobicontrols.sample.hellolinechart.HelloLineChartActivity}: android.view.InflateException: Binary XML file line #26: Error inflating class com.shinobicontrols.chart.Chart

06-04 09:57:53.471: E/AndroidRuntime(1090): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)

06-04 09:57:53.471: E/AndroidRuntime(1090): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)

06-04 09:57:53.471: E/AndroidRuntime(1090): at android.app.ActivityThread.access$600(ActivityThread.java:141)

06-04 09:57:53.471: E/AndroidRuntime(1090): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)

06-04 09:57:53.471: E/AndroidRuntime(1090): at android.os.Handler.dispatchMessage(Handler.java:99)

06-04 09:57:53.471: E/AndroidRuntime(1090): at android.os.Looper.loop(Looper.java:137)

06-04 09:57:53.471: E/AndroidRuntime(1090): at android.app.ActivityThread.main(ActivityThread.java:5041)

06-04 09:57:53.471: E/AndroidRuntime(1090): at java.lang.reflect.Method.invokeNative(Native Method)

06-04 09:57:53.471: E/AndroidRuntime(1090): at java.lang.reflect.Method.invoke(Method.java:511)

06-04 09:57:53.471: E/AndroidRuntime(1090): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)

06-04 09:57:53.471: E/AndroidRuntime(1090): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)

06-04 09:57:53.471: E/AndroidRuntime(1090): at dalvik.system.NativeStart.main(Native Method)

06-04 09:57:53.471: E/AndroidRuntime(1090): Caused by: android.view.InflateException: Binary XML file line #26: Error inflating class com.shinobicontrols.chart.Chart

06-04 09:57:53.471: E/AndroidRuntime(1090): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:698)

06-04 09:57:53.471: E/AndroidRuntime(1090): at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)

06-04 09:57:53.471: E/AndroidRuntime(1090): at android.view.LayoutInflater.inflate(LayoutInflater.java:489)

06-04 09:57:53.471: E/AndroidRuntime(1090): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)

06-04 09:57:53.471: E/AndroidRuntime(1090): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)

06-04 09:57:53.471: E/AndroidRuntime(1090): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:270)

06-04 09:57:53.471: E/AndroidRuntime(1090): at android.app.Activity.setContentView(Activity.java:1881)

06-04 09:57:53.471: E/AndroidRuntime(1090): at com.shinobicontrols.sample.hellolinechart.HelloLineChartActivity.onCreate(HelloLineChartActivity.java:58)

06-04 09:57:53.471: E/AndroidRuntime(1090): at android.app.Activity.performCreate(Activity.java:5104)

06-04 09:57:53.471: E/AndroidRuntime(1090): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)

06-04 09:57:53.471: E/AndroidRuntime(1090): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)

06-04 09:57:53.471: E/AndroidRuntime(1090): … 11 more

06-04 09:57:53.471: E/AndroidRuntime(1090): Caused by: java.lang.ClassNotFoundException: Didn’t find class “com.shinobicontrols.chart.Chart” on path: /data/app/com.shinobicontrols.sample.hellolinechart-1.apk

06-04 09:57:53.471: E/AndroidRuntime(1090): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:65)

06-04 09:57:53.471: E/AndroidRuntime(1090): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)

06-04 09:57:53.471: E/AndroidRuntime(1090): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)

06-04 09:57:53.471: E/AndroidRuntime(1090): at android.view.LayoutInflater.createView(LayoutInflater.java:552)

06-04 09:57:53.471: E/AndroidRuntime(1090): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:687)

06-04 09:57:53.471: E/AndroidRuntime(1090): … 21 more

Basically the error is:

Error inflating class com.shinobicontrols.chart.Chart

Probably because it can’t find the right class somehow. I am using the latest Android SDK and Eclipse versions.

Do you have any suggestions how to resolve this? So I can start developing for Android?

Best regards,

Harm


#2

Oke, found the solution myself:

Right click the sample project and select properties

Select Java build path on the left

And Order and Export at the top on the right

Move the library .jar to above the source of the sample and make sure the box in front of it is checked!

Rerun and this problem should be resolved.


#3

I’ve been trying to work through this issue myself. Here is what I have found:

hellolinechart has the following items in the Java Build Path - Android 4.2.2, Android Dependencies, Android Private Libraries, hellolinechart/src, hellolinechart/gen.
Android 4.2.2 contains android.jar; Android Dependencies contains shinobichartslibrary.jar; Android Private Libraries contains shinobicontrols.jar, android-support-v4.jar;

ShinobiChartsLibrary has the following items in the Java Build Path - Android 3.0, Android Dependencies, Android Private Libraries, ShinobiChartsLibrary/src, ShinobiChartsLibrary/gen.
Android 3.0 contains android.jar; Android Dependencies contains annotations.jar; Android Private Libraries contains shinobicontrols.jar;

I have not yet found an arrangement of build path items with corresponding check marks that allows this sample project to run.


#4

Are you using Eclipse? If so, which version? And have you tried the solution I posted?


#5

I’m using Eclipse, specifically the Android ADT package. Build: v22.0.0-675183

I tried the solution you proposed except that there was no library.jar. That’s why I detailed exactly what *was* in the Java Build Path.


#6

What I meant was not library.jar but the shinobicontrols.jar (as in the library you want to use).

If that one is not in the list, go to the Libraries tab in the same window and click “add external library” and look for the shinbocontrols.jar file (which should be in the download you got from shinobicontrols) and click add, than follow the remaining part of the solution.


#7

The solution was to configure the Java Build Paths as follows, in order:

hellolinechart -
Android 4.2.2 (unchecked)
Android Private Libraries (checked)
Android Dependencies (checked)
/src (default check)
/gen (default check)

Android 3.0 (unchecked)
Android Private Libraries (checked)
Android Dependencies (checked)
/src (default check)
/gen (default check)

That ordering with those checks/unchecks allowed the project to run.