该应用在调试模式下运行良好,但是在安装到我的Android手机中后,在发布模式下无法显示主体。我使用flutter build apk --split-per-abi构建并复制了输出apk文件之一,以安装在手机中。需要帮助。谢谢。
import 'dart:math' as math;
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Earth',
theme: ThemeData(
primarySwatch: Colors.blue, scaffoldBackgroundColor: Colors.white),
home: MyHomePage(title: 'Earth'),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage>
with SingleTickerProviderStateMixin {
AnimationController _controller;
@override
void initState() {
// Create animation controller.
_controller =
AnimationController(duration: const Duration(seconds: 10), vsync: this)
..addListener(() {
setState(() {
// Force build.
});
})
..addStatusListener((AnimationStatus status) {
if (status == AnimationStatus.dismissed) {
_controller.forward();
} else if (status == AnimationStatus.completed) {
_controller.reverse();
}
});
// Start animation automatically.
_controller.forward(from: 0.0);
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Center(
child: Transform.scale(
scale: 1.6,
child: Transform.rotate(
angle: math.pi * _controller.value, // rotate animation
child: Image.network(
"https://ak7.picdn.net/shutterstock/videos/3010597/thumb/1.jpg")))),
);
}
}
答案 0 :(得分:-1)
问题已解决: 将此添加到\ android \ app \ src \ main \ androidmanifest.xml
class WarningWithStacktrace extends ErrorException {}
set_error_handler(function($severity, $message, $file, $line) {
if ((error_reporting() & $severity)) {
if ($severity & (E_WARNING | E_NOTICE | E_USER_WARNING | E_USER_NOTICE)) {
$ex = new WarningWithStacktrace($message, 0, $severity, $file, $line);
echo "\n" . $ex . "\n\n";
return true;
} else {
throw new ErrorException($message, 0, $severity, $file, $line);
}
}
});