简体   繁体   中英

splash screen is not working in android 6

I have added splash screen in my app but the app crashes when is run on Android 6. The interesting thing is that the app runs fine on Android 9. Don't know what to do. Target SDK - 28. min SDK= 19

it is showing error on oncreate method while run app on android 6

splash.java

import android.os.Bundle;
import android.os.Handler;

public class splash extends AppCompatActivity  {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState); // it showing error here.
        setContentView(R.layout.activity_splash);
        int SPLASH_TIME_OUT = 4000;
        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                Intent splashintent=new Intent(splash.this,MainActivity.class);
                startActivity(splashintent);
                finish();
            }
        }, SPLASH_TIME_OUT);

    }
}

logs

06-22 16:17:30.930 10294-10294/? E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.napps.wallpaper, PID: 10294
    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.napps.wallpaper/com.napps.wallpaper.splash}: android.content.res.Resources$NotFoundException: Resource ID #0x7f07009e
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2655)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2725)
        at android.app.ActivityThread.-wrap12(ActivityThread.java)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1572)
        at android.os.Handler.dispatchMessage(Handler.java:111)
        at android.os.Looper.loop(Looper.java:207)
        at android.app.ActivityThread.main(ActivityThread.java:5896)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:679)
     Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x7f07009e
        at android.content.res.Resources.getValue(Resources.java:1595)
        at androidx.appcompat.widget.AppCompatDrawableManager.loadDrawableFromDelegates(AppCompatDrawableManager.java:331)
        at androidx.appcompat.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:198)
        at androidx.appcompat.widget.TintTypedArray.getDrawableIfKnown(TintTypedArray.java:86)
        at androidx.appcompat.app.AppCompatDelegateImpl.<init>(AppCompatDelegateImpl.java:260)
        at androidx.appcompat.app.AppCompatDelegate.create(AppCompatDelegate.java:182)
        at androidx.appcompat.app.AppCompatActivity.getDelegate(AppCompatActivity.java:520)
        at androidx.appcompat.app.AppCompatActivity.onCreate(AppCompatActivity.java:71)
        at com.napps.wallpaper.splash.onCreate(splash.java:13)
        at android.app.Activity.performCreate(Activity.java:6298)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1113)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2608)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2725) 
        at android.app.ActivityThread.-wrap12(ActivityThread.java) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1572) 
        at android.os.Handler.dispatchMessage(Handler.java:111) 
        at android.os.Looper.loop(Looper.java:207) 
        at android.app.ActivityThread.main(ActivityThread.java:5896) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:679) 

There might be problem with your drawable Image. While copying image Please check the folder in which you are copying. Try to add the image in drawable folder not drawable-21

I would suggest to remove old image and Add Image again to proper directory.

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