我为Api 21(Lollipop)开发了一个应用程序,我想要这个应用程序在Api 19(Kitkat +)设备上运行。
可悲的是我收到了这个错误:
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)
这发生在onCreate()方法的第一行:
super.onCreate(savedInstanceState);
这些是我的进口商品:
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.+'
}
有人知道如何解决这个问题吗?
答案 0 :(得分:1)
如果您拥有最新的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}"
}