-1

I am creating an android application consists of progress bar downloaded from here but i am getting an error called java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.milanprogress/com.example.milanprogress.MainActivity}: android.view.InflateException: Binary XML file line #8: Error inflating class is.arontibo.library.ElasticDownloadView can any one tell me how to overcome this This is my activity:

package com.example.milanprogress;

import android.app.Activity;
import android.os.Bundle;
import android.os.Handler;
import android.view.Menu;
import android.view.MenuItem;

import is.arontibo.library.ElasticDownloadView;
import is.arontibo.library.ProgressDownloadView;

public class MainActivity extends Activity {

    ElasticDownloadView elastic;

    @Override

    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        elastic = (ElasticDownloadView)findViewById(R.id.elastic_download_view);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();
         if (id == R.id.action_run_success_animation) {

                new Handler().post(new Runnable() {
                    @Override
                    public void run() {
                        elastic.startIntro();
                    }
                });

                new Handler().postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        elastic.success();
                    }
                }, 2*ProgressDownloadView.ANIMATION_DURATION_BASE);

                return true;
            } else if (id == R.id.action_run_fail_animation) {

                new Handler().post(new Runnable() {
                    @Override
                    public void run() {
                       elastic.startIntro();
                    }
                });

                new Handler().postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        elastic.setProgress(45);
                    }
                }, 2*ProgressDownloadView.ANIMATION_DURATION_BASE);

                new Handler().postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        elastic.fail();
                    }
                }, 3*ProgressDownloadView.ANIMATION_DURATION_BASE);

                return true;
            }

        return super.onOptionsItemSelected(item);
    }
}

This is my xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:elastic="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.example.milanprogress.MainActivity" >

    <is.arontibo.library.ElasticDownloadView
        android:id="@+id/elastic_download_view"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"/>

</RelativeLayout>

This is my Logcat:

01-02 08:04:43.980: E/AndroidRuntime(30127): FATAL EXCEPTION: main
01-02 08:04:43.980: E/AndroidRuntime(30127): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.milanprogress/com.example.milanprogress.MainActivity}: android.view.InflateException: Binary XML file line #8: Error inflating class is.arontibo.library.ElasticDownloadView
01-02 08:04:43.980: E/AndroidRuntime(30127):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2211)
01-02 08:04:43.980: E/AndroidRuntime(30127):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
01-02 08:04:43.980: E/AndroidRuntime(30127):    at android.app.ActivityThread.access$600(ActivityThread.java:141)
01-02 08:04:43.980: E/AndroidRuntime(30127):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
01-02 08:04:43.980: E/AndroidRuntime(30127):    at android.os.Handler.dispatchMessage(Handler.java:99)
01-02 08:04:43.980: E/AndroidRuntime(30127):    at android.os.Looper.loop(Looper.java:137)
01-02 08:04:43.980: E/AndroidRuntime(30127):    at android.app.ActivityThread.main(ActivityThread.java:5103)
01-02 08:04:43.980: E/AndroidRuntime(30127):    at java.lang.reflect.Method.invokeNative(Native Method)
01-02 08:04:43.980: E/AndroidRuntime(30127):    at java.lang.reflect.Method.invoke(Method.java:525)
01-02 08:04:43.980: E/AndroidRuntime(30127):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
01-02 08:04:43.980: E/AndroidRuntime(30127):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
01-02 08:04:43.980: E/AndroidRuntime(30127):    at dalvik.system.NativeStart.main(Native Method)
01-02 08:04:43.980: E/AndroidRuntime(30127): Caused by: android.view.InflateException: Binary XML file line #8: Error inflating class is.arontibo.library.ElasticDownloadView
01-02 08:04:43.980: E/AndroidRuntime(30127):    at android.view.LayoutInflater.createView(LayoutInflater.java:620)
01-02 08:04:43.980: E/AndroidRuntime(30127):    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696)
01-02 08:04:43.980: E/AndroidRuntime(30127):    at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
01-02 08:04:43.980: E/AndroidRuntime(30127):    at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
01-02 08:04:43.980: E/AndroidRuntime(30127):    at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
01-02 08:04:43.980: E/AndroidRuntime(30127):    at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
01-02 08:04:43.980: E/AndroidRuntime(30127):    at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:267)
01-02 08:04:43.980: E/AndroidRuntime(30127):    at android.app.Activity.setContentView(Activity.java:1895)
01-02 08:04:43.980: E/AndroidRuntime(30127):    at com.example.milanprogress.MainActivity.onCreate(MainActivity.java:20)
01-02 08:04:43.980: E/AndroidRuntime(30127):    at android.app.Activity.performCreate(Activity.java:5133)
01-02 08:04:43.980: E/AndroidRuntime(30127):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
01-02 08:04:43.980: E/AndroidRuntime(30127):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2175)
01-02 08:04:43.980: E/AndroidRuntime(30127):    ... 11 more
01-02 08:04:43.980: E/AndroidRuntime(30127): Caused by: java.lang.reflect.InvocationTargetException
01-02 08:04:43.980: E/AndroidRuntime(30127):    at java.lang.reflect.Constructor.constructNative(Native Method)
01-02 08:04:43.980: E/AndroidRuntime(30127):    at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
01-02 08:04:43.980: E/AndroidRuntime(30127):    at android.view.LayoutInflater.createView(LayoutInflater.java:594)
01-02 08:04:43.980: E/AndroidRuntime(30127):    ... 22 more
01-02 08:04:43.980: E/AndroidRuntime(30127): Caused by: java.lang.NoClassDefFoundError: is.arontibo.library.R$styleable
01-02 08:04:43.980: E/AndroidRuntime(30127):    at is.arontibo.library.ElasticDownloadView.<init>(ElasticDownloadView.java:30)
01-02 08:04:43.980: E/AndroidRuntime(30127):    ... 25 more
BujjiDeepu
  • 111
  • 1
  • 14

4 Answers4

0

In your xml, try to close with a tag like this :

 <is.arontibo.library.ElasticDownloadView
        android:id="@+id/elastic_download_view"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"></is.arontibo.library.ElasticDownloadView>

The problem seems to happen in ElasticDownloadView. Check line 30 of source code. The library seems to use a resource called R.styleable.ColorOptionsView_backgroundColor, that you have probably not defined.

EDIT

Well if you imported the whole project in Eclipse and set it as "library" (check http://developer.android.com/tools/projects/projects-eclipse.html) you should be good. If you have still errors, try to modify the code inside the library. On line 30 change :

mBackgroundColor = a.getColor(R.styleable.ColorOptionsView_backgroundColor,
                R.color.orange_salmon);

to

 mBackgroundColor = Color.WHITE;

Once it's done, run and post your LogCat again if you still have issues.

Gordak
  • 2,060
  • 22
  • 32
  • I edited my post, the problem seems to come from the library. Have you imported the whole project ? Are you using Eclipse ? – Gordak Jun 30 '15 at 12:35
  • Yes dude i am using eclipse i imported whole project into my work space @Gordak – BujjiDeepu Jun 30 '15 at 12:48
  • If you have imported the project correctly, the style should be defined. If the library contains an error, then try to modify the line 30 (basically replace it with Color.WHITE) – Gordak Jun 30 '15 at 12:51
  • In Android Studio, this kind of error can be detected at compilation time, where in Eclipse it is detected only at runtime. Switch to Android Studio ;) – Gordak Jun 30 '15 at 12:53
  • Thanks for the Suggestion dude but i need to develop my project on Eclipse Dude can you help me with that – BujjiDeepu Jun 30 '15 at 12:58
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/81973/discussion-between-gordak-and-bujjideepu). – Gordak Jun 30 '15 at 13:04
0

You might have not included that lib properly in your build path. Try re adding that lib with a clean and make sure you have added all the styleables , layouts , colors XML files which are included with that library. This seems like you have not added this library properly.

rd7773
  • 409
  • 3
  • 13
0

Your stack says the error is

java.lang.NoClassDefFoundError

Here is the solution of same problem just used library is diffrent

http://stackoverflow.com/questions/26494346/error-inflating-class-and-android-support-v7-widget-cardview
Adi Tiwari
  • 761
  • 1
  • 5
  • 17
0

Take a look at the last lines of your logs:

Caused by: java.lang.NoClassDefFoundError: is.arontibo.library.R$styleable

Styleable properties are missing!!

Please make sure to have this defined in the library if you imported it:

<declare-styleable name="ColorOptionsView">
    <attr name="backgroundColor" format="color" />
</declare-styleable>

in the attrs.xml file.

Tíbó
  • 1,188
  • 13
  • 28