Runtime Error Unfortunately app has stopped?
Asked Answered
V

4

5

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")
}
Vyse answered 7/12, 2015 at 6:58 Comment(7)
can you please show your codeKibbutznik
and post your build.gradlePortal
Enabled ProGuard ahh ?Alded
Please check the code.Vyse
Don't know how but it started working properly now.Vyse
Even am struggling with the same issue since yesterday, if you solved it please tell me how.Crissman
Looks like you are missing the v7 support library, but i can see you import it on gradle.... Try clean and buildArruda
C
7

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.

Cathodoluminescence answered 7/12, 2015 at 17:2 Comment(1)
in my case i will change compileSdkVersion 24 and all dependencies compile 'com.android.support:appcompat-v7:24.0.0'Kurd
S
2

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

Sippet answered 10/5, 2016 at 6:8 Comment(0)
P
0

I encountered similar exception after updating android studio to 2.0. I'm using design library to load tabs and I got exception when I was opening the activity. So I did the following to fix issues.

I updated Android SDK tools Android SDK Platform tools Android SDK build tools Android Support library

to latest available versions and I set the following as compileSdkVersion 23 buildToolsVersion "23.0.1"

and compile 'com.android.support:appcompat-v7:23.1.0' compile 'com.android.support:design:23.1.1'

It fixed my issue.

Petrify answered 13/4, 2016 at 12:55 Comment(0)
M
-1

Here the steps you need to take to solve this problem

  1. Check your compileSdkVersion version in app level gradle file[In my case its 23]
  2. Check your dependencies in same file and make sure that the version of your appcompat and design must start from same number as compileSdkVersion
  3. Append the version of dependencies with '+' like this
Margarettamargarette answered 25/7, 2016 at 8:26 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.