Android ERR帮忙

时间:2018-02-07 08:28:57

标签: java android runtimeexception

SplashActivity

公共类SplashActivity扩展了AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    startActivity(new Intent(this, MainActivity.class));
}

}

XML-splash_background文件

<item android:drawable="@color/colorPrimary" />

<item>
    <bitmap
        android:gravity="center"
        android:src="@mipmap/ic_launcher" />
</item>

<resources>

<!-- Base application theme -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
</style>

<!-- Splash -->
<style name="SplashTheme" parent="AppTheme">
    <item name="windowNoTitle">true</item>
    <item name="windowActionBar">false</item>
    <item name="android:windowBackground">@drawable/splash_background</item>
</style>

<!-- Main -->
<style name="NoTitleScreen" parent="AppTheme">
    <item name="windowNoTitle">true</item>
    <item name="colorPrimaryDark">@color/actionBarColor</item>
</style>

清单文件

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:roundIcon="@mipmap/ic_launcher_round"
    android:supportsRtl="true"
    android:theme="@style/NoTitleScreen">

    <activity
        android:name=".Activity.SplashActivity"
        android:theme="@style/SplashTheme">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

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

    <activity android:name=".Activity.MainActivity"></activity>
</application>

E/AndroidRuntime: FATAL EXCEPTION: main
              Process: com.app.jiwon.tekken7_manual, PID: 8933
              java.lang.RuntimeException: Unable to start activity ComponentInfo{com.app.jiwon.tekken7_manual/com.app.jiwon.tekken7_manual.Activity.SplashActivity}: android.content.res.Resources$NotFoundException: Drawable com.app.jiwon.tekken7_manual:drawable/splash_background with resource ID #0x7f070071
                  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2778)
                  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
                  at android.app.ActivityThread.-wrap11(Unknown Source:0)
                  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
                  at android.os.Handler.dispatchMessage(Handler.java:106)
                  at android.os.Looper.loop(Looper.java:164)
                  at android.app.ActivityThread.main(ActivityThread.java:6494)
                  at java.lang.reflect.Method.invoke(Native Method)
                  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
                  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
               Caused by: android.content.res.Resources$NotFoundException: Drawable com.app.jiwon.tekken7_manual:drawable/splash_background with resource ID #0x7f070071
               Caused by: android.content.res.Resources$NotFoundException: File res/drawable/splash_background.xml from drawable resource ID #0x7f070071
                  at android.content.res.ResourcesImpl.loadDrawableForCookie(ResourcesImpl.java:820)
                  at android.content.res.ResourcesImpl.loadDrawable(ResourcesImpl.java:630)
                  at android.content.res.Resources.getDrawableForDensity(Resources.java:877)
                  at android.content.res.Resources.getDrawable(Resources.java:819)
                  at android.content.Context.getDrawable(Context.java:605)
                  at android.support.v4.content.ContextCompat.getDrawable(ContextCompat.java:351)
                  at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:200)
                  at android.support.v7.widget.TintTypedArray.getDrawableIfKnown(TintTypedArray.java:87)
                  at android.support.v7.app.AppCompatDelegateImplBase.<init>(AppCompatDelegateImplBase.java:128)
                  at android.support.v7.app.AppCompatDelegateImplV9.<init>(AppCompatDelegateImplV9.java:149)
                  at android.support.v7.app.AppCompatDelegateImplV11.<init>(AppCompatDelegateImplV11.java:29)
                  at android.support.v7.app.AppCompatDelegateImplV14.<init>(AppCompatDelegateImplV14.java:54)
                  at android.support.v7.app.AppCompatDelegateImplV23.<init>(AppCompatDelegateImplV23.java:31)
                  at android.support.v7.app.AppCompatDelegateImplN.<init>(AppCompatDelegateImplN.java:31)
                  at android.support.v7.app.AppCompatDelegate.create(AppCompatDelegate.java:198)
                  at android.support.v7.app.AppCompatDelegate.create(AppCompatDelegate.java:183)
                  at android.support.v7.app.AppCompatActivity.getDelegate(AppCompatActivity.java:519)
                  at android.support.v7.app.AppCompatActivity.onCreate(AppCompatActivity.java:70)
                  at com.app.jiwon.tekken7_manual.Activity.SplashActivity.onCreate(SplashActivity.java:10)
                  at android.app.Activity.performCreate(Activity.java:6999)
                  at android.app.Activity.performCreate(Activity.java:6990)
                  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1214)
                  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2731)
                  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
                  at android.app.ActivityThread.-wrap11(Unknown Source:0)
                  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
                  at android.os.Handler.dispatchMessage(Handler.java:106)
                  at android.os.Looper.loop(Looper.java:164)
                  at android.app.ActivityThread.main(ActivityThread.java:6494)
                  at java.lang.reflect.Method.invoke(Native Method)
                  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
                  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
               Caused by: org.xmlpull.v1.XmlPullParserException: Binary XML file line #0: <bitmap> requires a valid 'src' attribute
                  at android.graphics.drawable.BitmapDrawable.updateStateFromTypedArray(BitmapDrawable.java:823)
 at android.graphics.drawable.BitmapDrawable.inflate(BitmapDrawable.java:754)
                  at android.graphics.drawable.DrawableInflater.inflateFromXmlForDensity(DrawableInflater.java:142)
                  at android.graphics.drawable.Drawable.createFromXmlInnerForDensity(Drawable.java:1295)
                  at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:1284)
                  at android.graphics.drawable.LayerDrawable.inflateLayers(LayerDrawable.java:279)
                  at android.graphics.drawable.LayerDrawable.inflate(LayerDrawable.java:194)
                  at android.graphics.drawable.DrawableInflater.inflateFromXmlForDensity(DrawableInflater.java:142)
                  at android.graphics.drawable.Drawable.createFromXmlInnerForDensity(Drawable.java:1295)
                  at android.graphics.drawable.Drawable.createFromXmlForDensity(Drawable.java:1254)
                  at android.content.res.ResourcesImpl.loadDrawableForCookie(ResourcesImpl.java:807)
                    ... 31 more

我想创建一个启动活动。 我将此splash_background文件应用于清单的背景,并在更改主题后,我得到此错误请帮助 我引用了这个页面 http://dudmy.net/android/2017/04/09/improved-loading-screen/

1 个答案:

答案 0 :(得分:0)

我把你的splash_background文件放在res里面的xml文件夹里。您的图片文件应位于可绘制文件夹中。enter image description here