java.lang.NoClassDefFoundError: android.support.v7.app.AppCompatDelegateImplV14 in Android Studio
Asked Answered
C

2

6

Here's the log.

java.lang.NoClassDefFoundError: android.support.v7.app.AppCompatDelegateImplV14
        at android.support.v7.app.AppCompatDelegate.create(AppCompatDelegate.java:93)
        at android.support.v7.app.AppCompatDelegate.create(AppCompatDelegate.java:77)
        at android.support.v7.app.AppCompatActivity.getDelegate(AppCompatActivity.java:429)
        at android.support.v7.app.AppCompatActivity.onCreate(AppCompatActivity.java:57)
        at com.marshall.gruppo.ui.MainScreenActivity.onCreate(MainScreenActivity.java:41)
        at android.app.Activity.performCreate(Activity.java:5451)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1093)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2377)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2471)
        at android.app.ActivityThread.access$900(ActivityThread.java:175)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1308)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:146)
        at android.app.ActivityThread.main(ActivityThread.java:5602)
        at java.lang.reflect.Method.invokeNative(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:515)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
        at dalvik.system.NativeStart.main(Native Method)

I also read an article suggesting the solution (java.lang.NoClassDefFoundError: android.support.v7.app.AppCompatDelegateImplV14). It suggests me to add the following in the build.gradle file.

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

Actually that was already in the file, and it seems like it's not the original issue here. Here is my build.gradle file.

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.2.0'
compile project(':volley')
compile project(':android-support-v4')
}

In case you need to have a look at my code, here's my code that is causing the NoClassDefFoundError.

public class MainScreenActivity extends AppCompatActivity {
private DrawerLayout mDrawerLayout;
private ListView mDrawerList;
private ActionBarDrawerToggle mDrawerToggle;

private CharSequence mDrawerTitle;

private CharSequence mTitle;

private String[] navMenuTitles;
private TypedArray navMenuIcons;

private ArrayList<NavDrawerItem> navDrawerItems;
private NavDrawerListAdapter adapter;

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

    mTitle = mDrawerTitle = getTitle();

    navMenuTitles = getResources().getStringArray(R.array.drawermenu_items);

    navMenuIcons = getResources()
            .obtainTypedArray(R.array.drawermenu_icons);

    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    mDrawerList = (ListView) findViewById(R.id.list_slidermenu);

    navDrawerItems = new ArrayList<NavDrawerItem>();

    navDrawerItems.add(new NavDrawerItem(navMenuTitles[0], navMenuIcons.getResourceId(0, -1)));
    navDrawerItems.add(new NavDrawerItem(navMenuTitles[1], navMenuIcons.getResourceId(1, -1)));
    navDrawerItems.add(new NavDrawerItem(navMenuTitles[2], navMenuIcons.getResourceId(2, -1)));
    navDrawerItems.add(new NavDrawerItem(navMenuTitles[3], navMenuIcons.getResourceId(3, -1), true, "22"));
    navDrawerItems.add(new NavDrawerItem(navMenuTitles[4], navMenuIcons.getResourceId(4, -1)));
    navDrawerItems.add(new NavDrawerItem(navMenuTitles[5], navMenuIcons.getResourceId(5, -1), true, "50+"));


    navMenuIcons.recycle();

    mDrawerList.setOnItemClickListener(new SlideMenuClickListener());

    adapter = new NavDrawerListAdapter(getApplicationContext(),
            navDrawerItems);
    mDrawerList.setAdapter(adapter);

    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setHomeButtonEnabled(true);

    mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.string.app_name, R.string.app_name) {
        public void onDrawerClosed(View view) {
            getSupportActionBar().setTitle(mTitle);
            invalidateOptionsMenu();
        }

        public void onDrawerOpened(View drawerView) {
            getSupportActionBar().setTitle(mDrawerTitle);
            invalidateOptionsMenu();
        }
    };
    mDrawerLayout.setDrawerListener(mDrawerToggle);

    if (savedInstanceState == null) {
        displayView(0);
    }
}

Here's the additional error log. There might be a hint for the solution.

07-06 17:50:03.056  27850-27850/com.marshall.gruppo E/dalvikvm﹕ Could not find class 'android.support.v7.app.AppCompatDelegateImplV14', referenced from method android.support.v7.app.AppCompatDelegate.create
07-06 17:50:03.056  27850-27850/com.marshall.gruppo E/dalvikvm﹕ Could not find class 'android.support.v7.app.AppCompatDelegateImplV11', referenced from method android.support.v7.app.AppCompatDelegate.create
07-06 17:50:03.056  27850-27850/com.marshall.gruppo E/dalvikvm﹕ Could not find class 'android.support.v7.app.AppCompatDelegateImplV7', referenced from method android.support.v7.app.AppCompatDelegate.create

and here's the xml file for the activity.

<?xml version="1.0" encoding="UTF-8"?>
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">

<FrameLayout
    android:id="@+id/frame_container"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />

<ListView
    android:id="@+id/list_slidermenu"
    android:layout_width="240dp"
    android:layout_height="match_parent"
    android:layout_gravity="start"
    android:choiceMode="singleChoice"
    android:divider="@color/list_divider"
    android:dividerHeight="1dp"
    android:listSelector="@drawable/list_selector"
    android:background="@color/list_background"/>

Cella answered 6/7, 2015 at 15:32 Comment(10)
restart android studio and/or clean, recompile projectAorta
@KrupalShah I don't think it works. I did what you said, and it keeps saying the same messages.. Any other solutions?Cella
why do you use jar file dependency for support v4? compile the latest support v4 in build.gradle.Aorta
@KrupalShah you mean I should remove the support-v4 file from the project structure because it is causing the conflict?Cella
@KrupalShah Oh I also added error logs on the question, so can you please read them as well?Cella
yes...instead of the jar file, write dependency in gadle file like compile 'com.android.support:appcompat-v4:22.2.0'Aorta
and where is your xml?Aorta
@KrupalShah I just uploaded. Have a lookCella
It looks ok...I think you should replace all jar file dependencies with dependencies to be declared in Gradle. This can be a solution to your problem. remove volley and all jar dependencies and replace them with gradle dependency.Aorta
Had the same crash, this helped me : #27698787Cussed
M
2

there might be a conflict with your dependencies

try removing

compile project(':android-support-v4')
Miquelon answered 6/7, 2015 at 15:48 Comment(5)
what is in your libs folder?Miquelon
there are volley.jar and android-support-v4.jar files.Cella
I added more error logs, can you check them out as well?Cella
try removing the jar files as well as it still includes the android-support-v4.jar ... gradle has a repository where it downloads the jars delcared like compile 'com.android.support:appcompat-v7:22.2.0'Miquelon
Try enabling MultiDex instead. It saved my dayCommunism
F
1

I had the same error and FULLY enabling multidex worked for me. here is what I did in gradle and manifest files

android {
compileSdkVersion 21
buildToolsVersion "21.1.0"

defaultConfig {
    ...
    minSdkVersion 14
    targetSdkVersion 21
    ...

    // Enabling multidex support.
    multiDexEnabled true
}
...
}

dependencies {
compile 'com.android.support:multidex:1.0.0'
}

also in my manifest file, I have add the MultiDexApplication class from the multidex support library to the application element like this

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
   package="com.example.android.multidex.myapplication">
   <application
       ...
       android:name="android.support.multidex.MultiDexApplication">
       ...
   </application>
</manifest>
Fatherhood answered 30/7, 2015 at 12:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.