Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Runtime Error Unfortunately app has stopped?

While trying to run my app on handset, when I am trying to go from one activity to other its throwing error Unfortunately app has stopped ! & When I checked in Logcat I'm getting following error messages...

12-07 03:12:57.958  17518-17518/com.android.mads.madses E/AndroidRuntime﹕ FATAL EXCEPTION: main
    Process: com.android.mads.madses, PID: 17518
    java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/v7/internal/widget/TintManager;
            at android.support.design.widget.TabLayout$TabView.<init>(TabLayout.java:1145)
            at android.support.design.widget.TabLayout.createTabView(TabLayout.java:635)
            at android.support.design.widget.TabLayout.addTabView(TabLayout.java:669)
            at android.support.design.widget.TabLayout.addTab(TabLayout.java:365)
            at android.support.design.widget.TabLayout.addTab(TabLayout.java:340)
            at android.support.design.widget.TabLayout.setTabsFromPagerAdapter(TabLayout.java:624)
            at android.support.design.widget.TabLayout.setupWithViewPager(TabLayout.java:595)
            at com.android.mads.madses.RegisterActivity.onCreate(RegisterActivity.java:35)
            at android.app.Activity.performCreate(Activity.java:5953)
            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1128)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2267)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2388)
            at android.app.ActivityThread.access$800(ActivityThread.java:148)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1292)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:135)
            at android.app.ActivityThread.main(ActivityThread.java:5312)
            at java.lang.reflect.Method.invoke(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:372)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:901)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:696)
     Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.v7.internal.widget.TintManager" on path: DexPathList[[zip file "/data/app/com.android.mads.madses-2/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
            at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
            at android.support.design.widget.TabLayout$TabView.<init>(TabLayout.java:1145)
            at android.support.design.widget.TabLayout.createTabView(TabLayout.java:635)
            at android.support.design.widget.TabLayout.addTabView(TabLayout.java:669)
            at android.support.design.widget.TabLayout.addTab(TabLayout.java:365)
            at android.support.design.widget.TabLayout.addTab(TabLayout.java:340)
            at android.support.design.widget.TabLayout.setTabsFromPagerAdapter(TabLayout.java:624)
            at android.support.design.widget.TabLayout.setupWithViewPager(TabLayout.java:595)
            at com.android.mads.madses.RegisterActivity.onCreate(RegisterActivity.java:35)
            at android.app.Activity.performCreate(Activity.java:5953)
            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1128)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2267)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2388)
            at android.app.ActivityThread.access$800(ActivityThread.java:148)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1292)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:135)
            at android.app.ActivityThread.main(ActivityThread.java:5312)
            at java.lang.reflect.Method.invoke(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:372)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:901)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:696)
    Suppressed: java.lang.ClassNotFoundException: android.support.v7.internal.widget.TintManager
            at java.lang.Class.classForName(Native Method)
            at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
            at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
            ... 22 more
     Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available

Can anybody please help?

Code: Main RegisterActivity (Parent Tab Activity)

package com.android.mads.madses;

import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;

import java.util.ArrayList;
import java.util.List;


public class RegisterActivity extends AppCompatActivity{
    private Toolbar toolbar;
    private TabLayout tabLayout;
    private ViewPager viewPager;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_register);

        toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);

        viewPager = (ViewPager) findViewById(R.id.viewpager);
        setupViewPager(viewPager);

        tabLayout = (TabLayout) findViewById(R.id.tabs);
        tabLayout.setupWithViewPager(viewPager);
    }

    private void setupViewPager(ViewPager viewPager) {
        ViewPagerAdapter adapter = new ViewPagerAdapter(getSupportFragmentManager());

        adapter.addFrag(new LoginInfoFragment(), "LoginInfo");
        adapter.addFrag(new PersonalInfoFragment(), "PersonalInfo");
        adapter.addFrag(new ContactInfoFragment(), "ContactInfo");
        adapter.addFrag(new VechicleInfoFragment(), "VechicleInfo");
        viewPager.setAdapter(adapter);
    }

    class ViewPagerAdapter extends FragmentPagerAdapter {
        private final List<Fragment> mFragmentList = new ArrayList<>();
        private final List<String> mFragmentTitleList = new ArrayList<>();

        public ViewPagerAdapter(FragmentManager manager) {
            super(manager);
        }

        @Override
        public Fragment getItem(int position) {
            return mFragmentList.get(position);
        }

        @Override
        public int getCount() {
            return mFragmentList.size();
        }

        public void addFrag(Fragment fragment, String title) {
            mFragmentList.add(fragment);
            mFragmentTitleList.add(title);
        }

        @Override
        public CharSequence getPageTitle(int position) {
            return mFragmentTitleList.get(position);
        }
    }


}

One of the Fragment Activity (all other fragment have same code)

package com.android.mads.madses;

import android.support.v4.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

/**
 * Created by Administrator on 07-12-2015.
 */
public class VechicleInfoFragment extends Fragment{

    public VechicleInfoFragment(){

    }

    @Override
    public void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        return inflater.inflate(R.layout.fragment_vechicleinfo , container, false);
    }
}

Login Activity (Here when i click 'Dont have an account? Signup here' app stopped)

package com.android.mads.madses;

import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.graphics.Paint;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

import com.android.mads.app.AppConfig;
import com.android.mads.app.AppController;
import com.android.mads.helper.SQLiteHandler;
import com.android.mads.helper.SessionManager;
import com.android.volley.Request;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.StringRequest;

import org.json.JSONException;
import org.json.JSONObject;

import java.util.HashMap;
import java.util.Map;

public class LoginActivity extends Activity {

    private EditText ed_email, ed_password;
    private Button btn_login, btn_newUser;
    private ProgressDialog pDialog;

    private SessionManager session;
    private SQLiteHandler db;

    private static final String TAG = LoginActivity.class.getSimpleName();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_login);

        ed_email = (EditText) findViewById(R.id.edtxt_login_email);
        ed_password = (EditText) findViewById(R.id.edtxt_login_password);
        btn_login = (Button) findViewById(R.id.btn_login);
        btn_newUser = (Button) findViewById(R.id.btn_login_newUser);
        pDialog = new ProgressDialog(this);

        session = new SessionManager(getApplicationContext());
        db = new SQLiteHandler(getApplicationContext());

        if (session.isLoggedIn()) {
            Intent i = new Intent(LoginActivity.this, HomeActivity.class);
            startActivity(i);
            finish();
        }

        btn_login.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String email = ed_email.getText().toString();
                String password = ed_password.getText().toString();

                if (email.isEmpty() || password.isEmpty()) {
                    Toast.makeText(LoginActivity.this, "Please Enter Details", Toast.LENGTH_LONG);
                } else {
                    checkLogin(email, password);
                }
            }
        });

        btn_newUser.setPaintFlags(btn_newUser.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
        btn_newUser.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent i = new Intent(LoginActivity.this, RegisterActivity.class);
                startActivity(i);
                finish();
            }
        });

    }

    public void checkLogin(final String email, final String password) {
        String tag_req = "login_request";
        pDialog.setMessage("Logging In...");
        showDialog();

        final StringRequest strR = new StringRequest(
                Request.Method.POST, AppConfig.LOGIN_URL,
                new Response.Listener<String>() {
                    @Override
                    public void onResponse(String response) {
                        hideDialog();

                        try {
                            JSONObject jsb = new JSONObject(response);
                            boolean error = jsb.getBoolean("error");
                            if (!error) {
                                String uid = jsb.getString("uid");

                                JSONObject user = jsb.getJSONObject("user");
                                String fname = user.getString("fname");
                                String lname = user.getString("lname");
                                String email = user.getString("email");
                                String dob = user.getString("dob");
                                String address = user.getString("address");
                                String bloodgroup = user.getString("bloodgroup");
                                String contact1 = user.getString("contact1");
                                String contact2 = user.getString("contact2");
                                String vechiclename = user.getString("vechiclename");
                                String fueltype = user.getString("fueltype");
                                String mileage = user.getString("mileage");
                                String created_at = user.getString("created_at");
                                db.addUser(uid, fname, lname, email, dob,
                                        address, bloodgroup, contact1, contact2,
                                        vechiclename, fueltype, mileage, created_at);

                                session.setLogin(true);

                                Intent i = new Intent(LoginActivity.this, HomeActivity.class);
                                startActivity(i);
                                finish();
                            } else {
                                String error_msg = jsb.getString("error_msg");
                                Toast.makeText(LoginActivity.this, error_msg, Toast.LENGTH_LONG).show();
                            }
                        } catch (JSONException e) {
                            e.printStackTrace();
                        }
                    }
                },
                new Response.ErrorListener() {
                    @Override
                    public void onErrorResponse(VolleyError error) {
                        Log.d("TAG ", error.getMessage());
                    }
                }
        ) {
            public Map<String, String> getParams() {
                Map<String, String> p = new HashMap<String, String>();
                p.put("tag", "login");
                p.put("email", email);
                p.put("password", password);

                return p;
            }
        };

        AppController.getmInstance().addToRequestQueue(strR, tag_req);

    }

    public void showDialog() {
        if (!pDialog.isShowing()) {
            pDialog.show();
        }
    }

    public void hideDialog() {
        if (pDialog.isShowing()) {
            pDialog.dismiss();
        }
    }
}

build.gradle

    apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.1"

    defaultConfig {
        applicationId "com.android.mads.madses"
        minSdkVersion 15
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:23.1.1'
    compile 'com.android.support:design:23.1.1'
    compile project (":volley")
}
like image 433
Kiran Malvi Avatar asked Dec 07 '15 06:12

Kiran Malvi


People also ask

What does it mean when an app says unfortunately stopped?

This means that when you get the “App has Stopped” message and think you've closed the app, you've actually only minimized it and the problem remains. To Force Stop an app and get it to properly restart, the best way to do it is this: Long-tap the app's icon on your home screen, then tap “App info.”

Why does my Android Studio app keeps stopping?

Apart from memory management, there are also several reasons to falls keep stopping Android Studio. Such as working on wrong coding or having some exceptions in the programs. Besides, this app can crash if you're working with full cache memory, old updates, and insufficient RAM.


2 Answers

i downgraded appcompat-v7 from:

compile 'com.android.support:appcompat-v7:23.1.1'

to:

compile 'com.android.support:appcompat-v7:23.1.0'

and it worked.

like image 133
Yaron Yosef Avatar answered Oct 29 '22 21:10

Yaron Yosef


changing dependencies will surely solve the problem , just added

compile 'com.android.support:appcompat-v7:23.2.0'
compile 'com.android.support:design:23.2.0'

and updated build tools version to 23.0.2

like image 32
KAMAL VERMA Avatar answered Oct 29 '22 22:10

KAMAL VERMA