Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Lollipop optimized app compiling on Kitkat - LayoutInflaterCompatHC NoClassDefFoundError

I developed an app for Api 21 (Lollipop), and i want this app to run on Api 19 (Kitkat+) devices.

Sadly i got this error:

E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.myurl.myapp , PID: 14398
java.lang.NoClassDefFoundError: android.support.v4.view.LayoutInflaterCompatHC
  at android.support.v4.view.LayoutInflaterCompat$LayoutInflaterCompatImplV11.setFactory(LayoutInflaterCompat.java:42)
  at android.support.v4.view.LayoutInflaterCompat.setFactory(LayoutInflaterCompat.java:79)
  at android.support.v7.app.AppCompatDelegateImplV7.installViewFactory(AppCompatDelegateImplV7.java:790)
  at android.support.v7.app.AppCompatActivity.onCreate(AppCompatActivity.java:57)
  at com.myurl.myapp.FeedActivity.onCreate(FeedActivity.java:194)

This happens at the first line of onCreate() method:

super.onCreate(savedInstanceState);

These are my imports:

dependencies {
  compile fileTree(dir: 'libs', include: ['*.jar'])
  compile 'com.android.support:support-v4:21.+'
  compile "com.android.support:appcompat-v7:21.0.+"
  compile 'com.android.support:cardview-v7:21.+'
  compile 'com.android.support:recyclerview-v7:21.+'
}

Does anybody know how to solve this problem?

like image 955
jazz Avatar asked Jul 06 '15 10:07

jazz


1 Answers

It doesn't matter which device you run if have latest buildToolsVersion.

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"

    defaultConfig {
        applicationId "your.app.id"
        minSdkVersion 16
        targetSdkVersion 21
        versionCode 1
        versionName "1.0"
    }
}

ext {
    supportLibVersion = '23.1.1'
    playServiceVersion = '8.3.0'
}

dependencies {
    compile "com.android.support:design:${supportLibVersion}"
    compile "com.android.support:cardview-v7:${supportLibVersion}"
    compile "com.android.support:appcompat-v7:${supportLibVersion}"
    compile "com.android.support:recyclerview-v7:${supportLibVersion}"
    compile "com.google.android.gms:play-services:${playServiceVersion}"
}
like image 167
Shailesh Avatar answered Nov 10 '22 21:11

Shailesh