简体   繁体   中英

Android app crashing while loading image

I am trying to load around 168kb (after optimization in tinypng.com) image as splash screen. Its crashing with below VERBOSE (no errors)-

W/art: Before Android 4.1, method android.graphics.PorterDuffColorFilter android.support.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable

This is how I have implemented splash screen-

Activity :

public void onCreate(Bundle icicle) {
        super.onCreate(icicle);
        //setContentView(R.layout.activity_splash1);--> Note this is commented

        /* New Handler to start the Menu-Activity
         * and close this Splash-Screen after some seconds.*/
        new Handler().postDelayed(new Runnable(){
            @Override
            public void run() {
                /* Create an Intent that will start the Menu-Activity. */
                Intent mainIntent = new Intent(SplashActivity1.this,MainActivity.class);
                SplashActivity1.this.startActivity(mainIntent);
                SplashActivity1.this.finish();
            }
        }, SPLASH_DISPLAY_LENGTH);
    }

Manifest Entry :

<activity
            android:name=".ui.activities.SplashActivity1"
            android:screenOrientation="portrait"
            android:theme= "@style/AppTheme.NoActionBar.SplashActivity1">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity> 

Styles:

    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
            <!-- Customize your theme here. -->
            <item name="colorPrimary">@color/colorPrimary</item>
            <item name="colorPrimaryDark">@color/colorTheme</item>
            <item name="colorAccent">@color/colorBlack</item>
        </style>

<style name="AppTheme.NoActionBar">
                <item name="windowActionBar">false</item>
                <item name="windowNoTitle">true</item>
            </style>

        <style name="AppTheme.NoActionBar.SplashActivity1" parent="AppTheme.NoActionBar">
                <item name="android:windowBackground">@drawable/splash1</item>
            </style>

Drawable :

<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
    android:src="@drawable/bootpage">

</bitmap>
  • Running on: Android Emulator API 6

    Thanks in Advance

There are two problems here .
1 - if you want your activity to be created without a layout (you have commented setContentView()) then you must use Theme.NoDispaly .
in your manifest :

<activity  android:name = "MyActivity" 
          android:label = "@string/app_name" 
          android:theme = "@android:style/Theme.NoDisplay" >

2 - why you would call an activity without a ui ?
for splash pages the standard way is to to declare all your ccomponents and your drawables in xml like anyother activity.
i think there is no need not to use a layout in splash.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM