Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Android Runtime Exception Error

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 22
    Answer it

    hello,

    i have faced problem in it.

     

    This is my logcat:

    04-13 18:04:54.694 2407-2407/? I/art: Not late-enabling -Xcheck:jni (already on)
    04-13 18:04:54.694 2407-2407/? W/art: Unexpected CPU variant for X86 using defaults: x86
    04-13 18:04:54.932 2407-2407/com.ex.nishkarsh.nishkarsh W/System: ClassLoader referenced unknown path: /data/app/com.ex.nishkarsh.nishkarsh-1/lib/x86
    04-13 18:04:54.940 2407-2407/com.ex.nishkarsh.nishkarsh I/InstantRun: Starting Instant Run Server for com.ex.nishkarsh.nishkarsh
    04-13 18:04:55.748 2407-2407/com.ex.nishkarsh.nishkarsh W/art: Before Android 4.1, method android.graphics.PorterDuffColorFilter android.support.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable
    04-13 18:04:56.085 2407-2414/com.ex.nishkarsh.nishkarsh W/art: Suspending all threads took: 162.679ms
    04-13 18:04:56.534 2407-2414/com.ex.nishkarsh.nishkarsh W/art: Suspending all threads took: 110.985ms
    04-13 18:04:56.949 2407-2414/com.ex.nishkarsh.nishkarsh W/art: Suspending all threads took: 25.574ms
    04-13 18:04:57.354 2407-2418/com.ex.nishkarsh.nishkarsh I/art: Background sticky concurrent mark sweep GC freed 3795(605KB) AllocSpace objects, 0(0B) LOS objects, 8% free, 3MB/4MB, paused 116.413ms total 398.981ms
    04-13 18:04:57.406 2407-2476/com.ex.nishkarsh.nishkarsh I/OpenGLRenderer: Initialized EGL, version 1.4
    04-13 18:04:57.406 2407-2476/com.ex.nishkarsh.nishkarsh D/OpenGLRenderer: Swap behavior 1
    04-13 18:04:57.407 2407-2476/com.ex.nishkarsh.nishkarsh W/OpenGLRenderer: Failed to choose config with EGL_SWAP_BEHAVIOR_PRESERVED, retrying without...
    04-13 18:04:57.407 2407-2476/com.ex.nishkarsh.nishkarsh D/OpenGLRenderer: Swap behavior 0
    04-13 18:04:57.466 2407-2414/com.ex.nishkarsh.nishkarsh W/art: Suspending all threads took: 41.047ms
    04-13 18:04:57.491 2407-2407/com.ex.nishkarsh.nishkarsh W/art: Before Android 4.1, method int android.support.v7.widget.ListViewCompat.lookForSelectablePosition(int, boolean) would have incorrectly overridden the package-private method in android.widget.ListView
    04-13 18:05:00.210 2407-2407/com.ex.nishkarsh.nishkarsh D/AndroidRuntime: Shutting down VM
    04-13 18:05:00.210 2407-2407/com.ex.nishkarsh.nishkarsh E/AndroidRuntime: FATAL EXCEPTION: main
                                                                              Process: com.ex.nishkarsh.nishkarsh, PID: 2407
                                                                              java.lang.RuntimeException: Unable to start activity ComponentInfo{com.ex.nishkarsh.nishkarsh/com.ex.nishkarsh.nishkarsh.MainActivity}: java.lang.IllegalStateException: This Activity already has an action bar supplied by the window decor. Do not request Window.FEATURE_SUPPORT_ACTION_BAR and set windowActionBar to false in your theme to use a Toolbar instead.
                                                                                  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2665)
                                                                                  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)
                                                                                  at android.app.ActivityThread.-wrap12(ActivityThread.java)
                                                                                  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)
                                                                                  at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                                  at android.os.Looper.loop(Looper.java:154)
                                                                                  at android.app.ActivityThread.main(ActivityThread.java:6119)
                                                                                  at java.lang.reflect.Method.invoke(Native Method)
                                                                                  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
                                                                                  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
                                                                               Caused by: java.lang.IllegalStateException: This Activity already has an action bar supplied by the window decor. Do not request Window.FEATURE_SUPPORT_ACTION_BAR and set windowActionBar to false in your theme to use a Toolbar instead.
                                                                                  at android.support.v7.app.AppCompatDelegateImplV9.setSupportActionBar(AppCompatDelegateImplV9.java:207)
                                                                                  at android.support.v7.app.AppCompatActivity.setSupportActionBar(AppCompatActivity.java:130)
                                                                                  at com.ex.nishkarsh.nishkarsh.MainActivity.onCreate(MainActivity.java:73)
                                                                                  at android.app.Activity.performCreate(Activity.java:6679)
                                                                                  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
                                                                                  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2618)
                                                                                  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726) 
                                                                                  at android.app.ActivityThread.-wrap12(ActivityThread.java) 
                                                                                  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477) 
                                                                                  at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                                                  at android.os.Looper.loop(Looper.java:154) 
                                                                                  at android.app.ActivityThread.main(ActivityThread.java:6119) 
                                                                                  at java.lang.reflect.Method.invoke(Native Method) 
                                                                                  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886) 
                                                                                  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776) 
    04-13 18:05:00.315 2407-2418/com.ex.nishkarsh.nishkarsh I/art: Background partial concurrent mark sweep GC freed 1540(232KB) AllocSpace objects, 0(0B) LOS objects, 25% free, 4MB/6MB, paused 903us total 284.662ms

     

    and this is my main activity:

    package com.ex.nishkarsh.nishkarsh;
    
    import android.app.ProgressDialog;
    import android.os.Bundle;
    import android.support.annotation.NonNull;
    import android.util.Log;
    import android.view.View;
    import android.support.design.widget.NavigationView;
    import android.support.v4.view.GravityCompat;
    import android.support.v4.widget.DrawerLayout;
    import android.support.v7.app.ActionBarDrawerToggle;
    import android.support.v7.app.AppCompatActivity;
    import android.support.v7.widget.Toolbar;
    import android.view.Menu;
    import android.view.MenuItem;
    import android.widget.AdapterView;
    import android.widget.ArrayAdapter;
    import android.widget.Button;
    import android.content.Intent;
    import android.widget.EditText;
    import android.widget.ImageView;
    import android.widget.FrameLayout;
    import android.widget.Spinner;
    import android.widget.TextView;
    import android.widget.Toast;
    import android.widget.AdapterView.OnItemSelectedListener;
    import com.android.volley.AuthFailureError;
    import com.android.volley.Response;
    import com.android.volley.VolleyError;
    import com.android.volley.VolleyLog;
    import com.android.volley.toolbox.JsonArrayRequest;
    import com.ex.nishkarsh.nishkarsh.app.AppController;
    import org.json.JSONArray;
    import java.util.ArrayList;
    import java.util.HashMap;
    import java.util.List;
    import java.util.Map;
    
    @SuppressWarnings("ALL")
    public class MainActivity extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener,OnItemSelectedListener {
        private final String TAG = MainActivity.class.getSimpleName();
        private static final String BANNER_URL = "http://www.nishkarsh.co.in/api/bannerrecords?tokenno=bee5c79banrr2d42df1c2986382a502857879";
        private static final String KEY_USER = "UserId";
        private Button b5;
        private Button b6;
        private ProgressDialog pDialog;
        private EditText ed1;
        private TextView t1;
        private Button b7;
        private ImageView img3;
        private ImageView img1;
        private ImageView img2;
        private ImageView img4;
        private ImageView img5;
        private ImageView img6;
        private ImageView img7;
        private ImageView img8;
        private FrameLayout f2;
        private FrameLayout f3;
        private FrameLayout f4;
        private FrameLayout f5;
        private FrameLayout f6;
        private FrameLayout f7;
        private Spinner s1;
        private String UserId;
        Toolbar toolbar;
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.content_main);
            Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
            setSupportActionBar(toolbar);
    
            DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
            ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
                    this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
            drawer.setDrawerListener(toggle);
            toggle.syncState();
    
            NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
            navigationView.setNavigationItemSelectedListener(this);
            ProgressDialog pDialog = new ProgressDialog(this);
            pDialog.setMessage("Loading...");
            pDialog.setCancelable(false);
            s1 = (Spinner) findViewById(R.id.spin);
            img1 = (ImageView) findViewById(R.id.image1);
            img2 = (ImageView) findViewById(R.id.image2);
            img3 = (ImageView) findViewById(R.id.image3);
            img4 = (ImageView) findViewById(R.id.image4);
            img5 = (ImageView) findViewById(R.id.image5);
            img6 = (ImageView) findViewById(R.id.image6);
            img7 = (ImageView) findViewById(R.id.image7);
            img8 = (ImageView) findViewById(R.id.image8);
            t1 = (TextView) findViewById(R.id.textView);
            ed1 = (EditText) findViewById(R.id.editText);
            b5 = (Button) findViewById(R.id.button5);
            b6 = (Button) findViewById(R.id.button6);
            b7 = (Button) findViewById(R.id.button2);
            f7 = (FrameLayout) findViewById(R.id.layout1);
            f2 = (FrameLayout) findViewById(R.id.layout2);
            f3 = (FrameLayout) findViewById(R.id.layout3);
            f4 = (FrameLayout) findViewById(R.id.layout4);
            f5 = (FrameLayout) findViewById(R.id.layout5);
            f6 = (FrameLayout) findViewById(R.id.layout6);
    
            // Spinner click listener
            s1.setOnItemSelectedListener(this);
    
            b5.setOnClickListener(new View.OnClickListener() {
    
                @Override
                public void onClick(View v) {
                    // TODO Auto-generated method stub
                    if (v == b5) {
                        Intent intent = new Intent(MainActivity.this, MainActivity.class);
                        startActivity(intent);
                    } else {
                        Intent intent = new Intent(MainActivity.this, sendReferral.class);
    
                        startActivity(intent);
                    }
                }
            });
            b6.setOnClickListener(new View.OnClickListener() {
    
                @Override
                public void onClick(View v) {
                    // TODO Auto-generated method stub
                    if (v == b6) {
                        Intent intent = new Intent(MainActivity.this, MainActivity.class);
                        startActivity(intent);
                    } else {
                        Intent intent = new Intent(MainActivity.this, wallet.class);
    
                        startActivity(intent);
    
                    }
                }
            });
            img1.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    if (v == img1) {
                        Intent intent = new Intent(MainActivity.this, MainActivity.class);
                        startActivity(intent);
                    } else {
                        Intent intent = new Intent(MainActivity.this, brand.class);
                        makeJsonArrReq();
                        startActivity(intent);
                    }
                }
            });
            img2.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    if (v == img2) {
                        Intent intent = new Intent(MainActivity.this, MainActivity.class);
                        startActivity(intent);
                    } else {
                        Intent intent = new Intent(MainActivity.this, politicalBanner.class);
    
                        startActivity(intent);
                    }
                }
            });
    
            img3.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    if (v == img3) {
                        Intent intent = new Intent(MainActivity.this, MainActivity.class);
                        startActivity(intent);
                    } else {
                        Intent intent = new Intent(MainActivity.this, eduBanner.class);
    
                        startActivity(intent);
                    }
                }
            });
            img5.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Intent intent = new Intent(MainActivity.this, MainActivity.class);
    
                    startActivity(intent);
                }
            });
            img8.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    if (v == img8) {
                        Intent intent = new Intent(MainActivity.this, MainActivity.class);
                        startActivity(intent);
                    } else {
                        Intent intent = new Intent(MainActivity.this, wallet.class);
    
                        startActivity(intent);
                    }
                }
            });
            // Spinner Drop down elements
            List<String> categories = new ArrayList<>();
            categories.add("Automobile");
            categories.add("Agriculture");
            categories.add("Baby Care");
            categories.add("Banking & Finance");
            categories.add("Confectionery");
            categories.add("Construction");
            categories.add("Cooking Oil");
            categories.add("Cosmetics");
            categories.add("Education");
            categories.add("Electricals");
            categories.add("Food & beverages");
            categories.add("Furniture");
            categories.add("Gadgets");
            categories.add("Gaming");
            categories.add("Garments");
            categories.add("Banking & Finance");
            categories.add("Grocery");
            categories.add("Home Appliances");
            categories.add("Household Goods");
            categories.add("Media & Entertainment");
            categories.add("Mobile Applications");
            categories.add("OTC");
            categories.add("Personal Accessories");
            categories.add("Personal care");
            categories.add("Spices");
            categories.add("Stationeries");
            categories.add("Tea & Coffee");
            categories.add("Tobacco & Alcohol");
            categories.add("Toiletries");
            categories.add("Website");
            categories.add("Others");
    
    
            // Creating adapter for spinner
            ArrayAdapter<String> dataAdapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, categories);
    
            // Drop down layout style - list view with radio button
            dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    
            // attaching data adapter to spinner
            s1.setAdapter(dataAdapter);
    
        }
    
        @Override
        public void onBackPressed() {
            DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
            if (drawer.isDrawerOpen(GravityCompat.START)) {
                drawer.closeDrawer(GravityCompat.START);
            } else {
                super.onBackPressed();
            }
        }
    
        @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();
    
            //noinspection SimplifiableIfStatement
            if (id == R.id.action_settings) {
                return true;
            }
    
            return super.onOptionsItemSelected(item);
        }
    
        @SuppressWarnings("StatementWithEmptyBody")
        @Override
        public boolean onNavigationItemSelected(@NonNull MenuItem item) {
            // Handle navigation view item clicks here.
            int id = item.getItemId();
            if (id == R.id.edi1) {
    
            } else if (id == R.id.edi2) {
    
            } else if (id == R.id.edi3) {
    
            } else if (id == R.id.reg) {
    
            } else if (id == R.id.logout) {
    
            }
    
            DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
            drawer.closeDrawer(GravityCompat.START);
            return true;
    
        }
    
        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            // On selecting a spinner item
            String item = parent.getItemAtPosition(position).toString();
    
            // Showing selected spinner item
            Toast.makeText(parent.getContext(), "Selected: " + item, Toast.LENGTH_LONG).show();
        }
    
        public void onNothingSelected(AdapterView<?> arg0) {
            // TODO Auto-generated method stub
        }
    
        private void showProgressDialog() {
            if (!pDialog.isShowing())
                pDialog.show();
        }
    
        private void hideProgressDialog() {
            if (pDialog.isShowing())
                pDialog.hide();
        }
    
        private void makeJsonArrReq() {
            showProgressDialog();
            JsonArrayRequest jsonArrReq = new JsonArrayRequest(BANNER_URL, new Response.Listener<JSONArray>() {
    
                @Override
                public void onResponse(JSONArray response) {
                    Log.d(TAG, response.toString());
                    pDialog.hide();
                }
    
            }, new Response.ErrorListener() {
    
                @Override
                public void onErrorResponse(VolleyError error) {
                    VolleyLog.d(TAG, "Error: " + error.getMessage());
                    hideProgressDialog();
                }
    
            }) {
                /**
                 * Passing some request headers
                 */
                @Override
                public Map<String, String> getHeaders() throws AuthFailureError {
                    HashMap<String, String> headers = new HashMap<>();
                    headers.put("Content-Type", "application/json");
                    return headers;
                }
    
                @Override
                protected Map<String, String> getParams() {
                    Map<String, String> params = new HashMap<>();
                    params.put(KEY_USER, UserId);
    
                    return params;
                }
    
            };
    
            // Adding request to request queue
            String tag_json_arr = "jsonArrReq ";
            AppController.getInstance().addToRequestQueue(jsonArrReq,
                    tag_json_arr);
    }
    }
    

 0 Answer(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: