闪屏上出现致命错误,它突然停止了应用程序

时间:2019-01-23 07:14:04

标签: android dart flutter splash-screen

我跟随stackoverflow answermedium tutorial制作了Android版本的启动画面,但是当我启动该应用程序时,它会短暂显示启动画面并停止该应用程序。

我的启动画面徽标图片直接显示

enter image description here

launch_background.xml

<?xml version="1.0" encoding="utf-8"?>
<!-- Modify this file to customize your launch splash screen -->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:drawable="@android:color/white" />

    <item>
        <bitmap
            android:gravity="center"
            android:src="@mipmap/splash_logo" />
    </item>
</layer-list>

styles.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="LaunchTheme" parent="@android:style/Theme.Black.NoTitleBar">
        <!-- Show a splash screen on the activity. Automatically removed when
             Flutter draws its first frame -->
        <item name="android:windowBackground">@drawable/launch_background</item>
        <item name="android:windowFullscreen">true</item>
    </style>
</resources>

MainActivity.java

package com.example.privacyofanimal;

import android.os.Bundle;
import io.flutter.app.FlutterActivity;
import io.flutter.plugins.GeneratedPluginRegistrant;
import android.view.ViewTreeObserver;
import android.view.WindowManager;

public class MainActivity extends FlutterActivity {
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getWindow().setStatusBarColor(0x00000000);
    GeneratedPluginRegistrant.registerWith(this);
    ViewTreeObserver vto = getFlutterView().getViewTreeObserver();
    vto.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
      @Override
      public void onGlobalLayout() {
        getFlutterView().getViewTreeObserver().removeOnGlobalLayoutListener(this);
        getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
      }
    });
  }
}

main.dart

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

void main() {
  SystemChrome.setEnabledSystemUIOverlays([]);
  runApp(PrivacyOfAnimal());
}

class PrivacyOfAnimal extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: '동물의 사생활',
      home: Test(),
      debugShowCheckedModeBanner: false,
    );
  }
}

class Test extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Container(),
    );
  }
}

我的手机是三星Galaxy S8 +,我想解决这个问题。有什么问题吗?

错误日志

  

2019-01-23 16:44:03.443 18922-18922 / com.handong.privacyofanimal   E / AndroidRuntime:致命异常:main       流程:com.handong.privacyofanimal,PID:18922       java.lang.RuntimeException:无法实例化活动ComponentInfo {com.handong.privacyofanimal / com.handong.privacyofanimal.MainActivity}:   java.lang.ClassNotFoundException:找不到类   路径上的“ com.handong.privacyofanimal.MainActivity”:DexPathList [[zip   文件   “ /data/app/com.handong.privacyofanimal-rCGlJOS-fSwTgzOMfceE0g==/base.apk"],nativeLibraryDirectories=[/data/app/com.handong.privacyofanimal-rCGlJOS-fSwTgzOMfceE0g==/lib/arm64,   /data/app/com.handong.privacyofanimal-rCGlJOS-fSwTgzOMfceE0g==/base.apk!/lib/arm64-v8a,   / system / lib64,/ system / vendor / lib64]]           在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2839)           在android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3030)           在android.app.ActivityThread.-wrap11(未知来源:0)           在android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1696)           在android.os.Handler.dispatchMessage(Handler.java:105)           在android.os.Looper.loop(Looper.java:164)           在android.app.ActivityThread.main(ActivityThread.java:6938)           在java.lang.reflect.Method.invoke(本机方法)           在com.android.internal.os.Zygote $ MethodAndArgsCaller.run(Zygote.java:327)           在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)        原因:java.lang.ClassNotFoundException:在路径:DexPathList上找不到类“ com.handong.privacyofanimal.MainActivity”。   文件   “ /data/app/com.handong.privacyofanimal-rCGlJOS-fSwTgzOMfceE0g==/base.apk"],nativeLibraryDirectories=[/data/app/com.handong.privacyofanimal-rCGlJOS-fSwTgzOMfceE0g==/lib/arm64,   /data/app/com.handong.privacyofanimal-rCGlJOS-fSwTgzOMfceE0g==/base.apk!/lib/arm64-v8a,   / system / lib64,/ system / vendor / lib64]]           在dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:93)           在java.lang.ClassLoader.loadClass(ClassLoader.java:379)           在java.lang.ClassLoader.loadClass(ClassLoader.java:312)           在android.app.Instrumentation.newActivity(Instrumentation.java:1180)           在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2829)

0 个答案:

没有答案