我为API21(棒棒糖)开发了一个应用程序,我希望这个应用程序在API19(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.+'
}
有人知道怎么解决这个问题吗?
最佳答案
如果您运行的是最新的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}"
}