我得到以下一些Android设备的例外情况,这些例外情况不可复制,有人可以解释一下相同的原因。 TargetSDKVerson为24 , compileSDKVersion为24 , minSDKVersion为15 且构建工具版本为23.0.3
Exception:
Fatal Exception: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.abc.activities/com.abc.activities.activities.SplashActivity}: java.lang.ClassCastException: android.support.v7.widget.ContentFrameLayout cannot be cast to android.support.v7.widget.ContentFrameLayout
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3319)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3415)
at android.app.ActivityThread.access$1100(ActivityThread.java:229)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1821)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:7325)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
Caused by java.lang.ClassCastException: android.support.v7.widget.ContentFrameLayout cannot be cast to android.support.v7.widget.ContentFrameLayout
at android.support.v7.app.AppCompatDelegateImplV9.createSubDecor(Unknown Source)
at android.support.v7.app.AppCompatDelegateImplV9.ensureSubDecor(Unknown Source)
at android.support.v7.app.AppCompatDelegateImplV9.setContentView(Unknown Source)
at android.support.v7.app.AppCompatActivity.setContentView(Unknown Source)
at com.hdfcclife.activities.activities.SplashActivity.onCreate(Unknown Source)
at android.app.Activity.performCreate(Activity.java:6904)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1136)
at com.lody.virtual.client.hook.c.b.callActivityOnCreate(Unknown Source)
at com.lody.virtual.client.hook.c.a.callActivityOnCreate(Unknown Source)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3266)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3415)
at android.app.ActivityThread.access$1100(ActivityThread.java:229)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1821)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:7325)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
Activity Layout:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:ignore="all">
<ProgressBar
android:id="@+id/progress_bar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="@dimen/margin_large"
style="?android:attr/progressBarStyle"
android:indeterminate="true"
android:indeterminateTintMode="src_atop"
android:indeterminateTint="@color/colorPrimary"/>
</RelativeLayout>
ext {
// dependencies versions
supportLibraryVersion = '24.2.1'
playServicesVersion = '9.6.1'
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile('com.github.afollestad.material-dialogs:core:0.8.5.3@aar') {
transitive = true
}
compile project(':wibmoSDK')
compile('com.crashlytics.sdk.android:crashlytics:2.5.5@aar') {
transitive = true;
}
debugCompile 'com.squareup.leakcanary:leakcanary-android:1.5'
releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5'
testCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5'
//Testing-only
androidTestCompile 'com.android.support.test:rules:0.3'
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.1'
androidTestCompile "com.android.support:support-annotations:$rootProject.supportLibraryVersion"
androidTestCompile('com.android.support.test.espresso:espresso-contrib:2.1') {
exclude group: 'com.android.support', module: 'appcompat'
exclude group: 'com.android.support', module: 'support-v4'
exclude module: 'support-annotations'
exclude module: 'recyclerview-v7'
}
// add this for intent mocking support
androidTestCompile 'com.android.support.test.espresso:espresso-intents:2.2'
// add this for webview testing support
androidTestCompile 'com.android.support.test.espresso:espresso-web:2.2'
androidTestCompile('com.android.support.test:runner:0.3') {
// Necessary if your app targets Marshmallow (since the test runner
// hasn't moved to Marshmallow yet)
exclude group: 'com.android.support', module: 'support-annotations'
}
compile files('libs/LiveChatWindow.jar')
compile files('libs/adobeMobileLibrary-4.13.0.jar')
compile 'com.android.support:multidex:1.0.1'
compile 'com.itextpdf:itextg:5.5.9'
compile 'de.greenrobot:eventbus:2.4.0'
compile 'com.squareup.retrofit:retrofit:2.0.0-beta2'
compile 'com.squareup.retrofit:converter-gson:2.0.0-beta2'
compile 'org.greenrobot:greendao-encryption:2.2.2'
compile 'net.zetetic:android-database-sqlcipher:3.5.4@aar'
compile "com.google.android.gms:play-services-location:$rootProject.playServicesVersion"
compile "com.google.android.gms:play-services-auth:$rootProject.playServicesVersion"
compile "com.google.android.gms:play-services-maps:$rootProject.playServicesVersion"
compile 'com.anupcowkur:reservoir:2.1'
compile 'com.getbase:floatingactionbutton:1.10.1'
compile "com.android.support:appcompat-v7:$rootProject.supportLibraryVersion"
compile "com.android.support:design:$rootProject.supportLibraryVersion"
compile "com.android.support:support-v13:$rootProject.supportLibraryVersion"
compile "com.android.support:cardview-v7:$rootProject.supportLibraryVersion"
compile "com.android.support:percent:$rootProject.supportLibraryVersion"
compile "com.android.support:recyclerview-v7:$rootProject.supportLibraryVersion"
compile "com.android.support:support-v4:$rootProject.supportLibraryVersion"
compile "com.android.support:customtabs:$rootProject.supportLibraryVersion"
compile 'com.jakewharton:butterknife:7.0.1'
compile 'com.facebook.android:facebook-android-sdk:4.6.0'
compile 'com.mikhaellopez:circularimageview:3.0.2'
compile 'com.shamanland:fonticon:0.1.9'
compile 'com.github.PhilJay:MPAndroidChart:v2.2.3'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.appsflyer:af-android-sdk:4.6.0@aar' //Apps Flyer
compile 'javax.inject:javax.inject:1'
compile 'org.adw.library:discrete-seekbar:1.0.1'
compile project(':PayU-release')
}
Adding Activity onCreate Code:
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash);
progressBar = (ProgressBar)findViewById(R.id.progress_bar);
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT )
getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
database(); // For Database
if (!EventBus.getDefault().isRegistered(this))
EventBus.getDefault().register(this);
Utilities.initCache(this);
if (savedInstanceState == null) {
callApi();
} else {
moveToNext();
}
}
Android Manifest:
<activity
android:name="com.hdfcclife.activities.activities.SplashActivity"
android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
android:screenOrientation="portrait"
android:theme="@style/SplashTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter >
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="hdfclife"/>
</intent-filter>
</activity>
Styles.xml:
<style name="SplashTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowBackground">@drawable/splash</item>
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/green_icon_color</item>
</style>