Android应用程序不适用于Kitkat版本,但适用于Lollipop和Marshmallow

时间:2016-05-18 18:51:58

标签: android android-studio

我使用android studio创建了简单的hello world应用程序。它在Lollipop和Marshmallow上运行但在Kitkat没有。我将targetSDKversion更改为19后尝试运行应用程序。但是,它也没有运行。消息就像是一样 "遗憾的是应用停止了#34; 。 这是我的build.gradle文件:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"

    defaultConfig {
        applicationId "com.example.vivek.myhelloworldapp"
        minSdkVersion 14
        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:24.0.0-alpha1'
}

这是我在kitkat设备上进行USB调试时遇到的错误

05-14 20:12:58.100    1911-1911/com.example.vivek.contactmanager I/art﹕ Not late-enabling -Xcheck:jni (already on)
05-14 20:12:58.152    1911-1911/com.example.vivek.contactmanager W/System﹕ ClassLoader referenced unknown path: /data/app/com.example.vivek.contactmanager-2/lib/x86
05-14 20:12:58.302    1911-1911/com.example.vivek.contactmanager D/AndroidRuntime﹕ Shutting down VM
    --------- beginning of crash
05-14 20:12:58.311    1911-1911/com.example.vivek.contactmanager E/AndroidRuntime﹕ FATAL EXCEPTION: main
    Process: com.example.vivek.contactmanager, PID: 1911
    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.vivek.contactmanager/com.example.vivek.contactmanager.MainActivity}: java.lang.RuntimeException: Could not create tab content because could not find view with id 2131427420
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
            at android.app.ActivityThread.-wrap11(ActivityThread.java)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:148)
            at android.app.ActivityThread.main(ActivityThread.java:5417)
            at java.lang.reflect.Method.invoke(Native Method)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
     Caused by: java.lang.RuntimeException: Could not create tab content because could not find view with id 2131427420
            at android.widget.TabHost$ViewIdContentStrategy.<init>(TabHost.java:663)
            at android.widget.TabHost$ViewIdContentStrategy.<init>(TabHost.java)
            at android.widget.TabHost$TabSpec.setContent(TabHost.java:503)
            at com.example.vivek.contactmanager.MainActivity.onCreate(MainActivity.java:47)
            at android.app.Activity.performCreate(Activity.java:6237)
            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
            at android.app.ActivityThread.-wrap11(ActivityThread.java)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:148)
            at android.app.ActivityThread.main(ActivityThread.java:5417)
            at java.lang.reflect.Method.invoke(Native Method)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
05-14 20:13:30.586    1911-1911/com.example.vivek.contactmanager I/Process﹕ Sending signal. PID: 1911 SIG: 9

我希望有人能帮助我摆脱这个问题。

0 个答案:

没有答案