这里是应用程序开发的新手,昨天刚刚下载了所有内容。设置Flutter医生,下载了所有必要的文件,现在开始了。
刚刚生成了默认的flutter代码,Flutter: New Application Project
使用Pixel 2 API 30 x86
作为模拟器,但是当我从lib文件夹运行main.dart
文件时,我得到了一个SSL错误。
这是我得到的整个错误块。
Launching lib\main.dart on sdk gphone x86 in debug mode...
lib\main.dart:1
Exception in thread "main" javax.net.ssl.SSLHandshakeException: Remote host terminated the handshake
at java.base/sun.security.ssl.SSLSocketImpl.handleEOF(SSLSocketImpl.java:1715)
at java.base/sun.security.ssl.SSLSocketImpl.decode(SSLSocketImpl.java:1514)
at java.base/sun.security.ssl.SSLSocketImpl.readHandshakeRecord(SSLSocketImpl.java:1416)
at java.base/sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:451)
at java.base/sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:422)
at java.base/sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:574)
at java.base/sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:183)
at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1653)
at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1577)
at java.base/sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:224)
at org.gradle.wrapper.Download.downloadInternal(Download.java:58)
at org.gradle.wrapper.Download.download(Download.java:44)
at org.gradle.wrapper.Install$1.call(Install.java:61)
at org.gradle.wrapper.Install$1.call(Install.java:48)
at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAccessManager.java:65)
at org.gradle.wrapper.Install.createDist(Install.java:48)
at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:128)
at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:61)
Caused by: java.io.EOFException: SSL peer shut down incorrectly
at java.base/sun.security.ssl.SSLSocketInputRecord.read(SSLSocketInputRecord.java:483)
at java.base/sun.security.ssl.SSLSocketInputRecord.readHeader(SSLSocketInputRecord.java:472)
at java.base/sun.security.ssl.SSLSocketInputRecord.decode(SSLSocketInputRecord.java:160)
at java.base/sun.security.ssl.SSLTransport.decode(SSLTransport.java:111)
at java.base/sun.security.ssl.SSLSocketImpl.decode(SSLSocketImpl.java:1506)
... 16 more
Exception: Gradle task assembleDebug failed with exit code 1
Exited (sigterm)
对于上下文,这是我的主。dart文件
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: 'Flutter Demo',
theme: ThemeData(
// This is the theme of your application.
//
// Try running your application with "flutter run". You'll see the
// application has a blue toolbar. Then, without quitting the app, try
// changing the primarySwatch below to Colors.green and then invoke
// "hot reload" (press "r" in the console where you ran "flutter run",
// or simply save your changes to "hot reload" in a Flutter IDE).
// Notice that the counter didn't reset back to zero; the application
// is not restarted.
primarySwatch: Colors.blue,
),
home: MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key? key, required this.title}) : super(key: key);
// This widget is the home page of your application. It is stateful, meaning
// that it has a State object (defined below) that contains fields that affect
// how it looks.
// This class is the configuration for the state. It holds the values (in this
// case the title) provided by the parent (in this case the App widget) and
// used by the build method of the State. Fields in a Widget subclass are
// always marked "final".
final String title;
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
int _counter = 0;
void _incrementCounter() {
setState(() {
// This call to setState tells the Flutter framework that something has
// changed in this State, which causes it to rerun the build method below
// so that the display can reflect the updated values. If we changed
// _counter without calling setState(), then the build method would not be
// called again, and so nothing would appear to happen.
_counter++;
});
}
@override
Widget build(BuildContext context) {
// This method is rerun every time setState is called, for instance as done
// by the _incrementCounter method above.
//
// The Flutter framework has been optimized to make rerunning build methods
// fast, so that you can just rebuild anything that needs updating rather
// than having to individually change instances of widgets.
return Scaffold(
appBar: AppBar(
// Here we take the value from the MyHomePage object that was created by
// the App.build method, and use it to set our appbar title.
title: Text(widget.title),
),
body: Center(
// Center is a layout widget. It takes a single child and positions it
// in the middle of the parent.
child: Column(
// Column is also a layout widget. It takes a list of children and
// arranges them vertically. By default, it sizes itself to fit its
// children horizontally, and tries to be as tall as its parent.
//
// Invoke "debug painting" (press "p" in the console, choose the
// "Toggle Debug Paint" action from the Flutter Inspector in Android
// Studio, or the "Toggle Debug Paint" command in Visual Studio Code)
// to see the wireframe for each widget.
//
// Column has various properties to control how it sizes itself and
// how it positions its children. Here we use mainAxisAlignment to
// center the children vertically; the main axis here is the vertical
// axis because Columns are vertical (the cross axis would be
// horizontal).
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
'You have pushed the button this many times:',
),
Text(
'$_counter',
style: Theme.of(context).textTheme.headline4,
),
],
),
),
floatingActionButton: FloatingActionButton(
onPressed: _incrementCounter,
tooltip: 'Increment',
child: Icon(Icons.add),
), // This trailing comma makes auto-formatting nicer for build methods.
);
}
}
出了什么问题
请帮助
更新:1.0
关闭并重新打开VSCODE,现在我得到一个不同的错误
Launching lib\main.dart on sdk gphone x86 in debug mode...
lib\main.dart:1
FAILURE: Build failed with an exception.
* What went wrong:
Could not open settings generic class cache for settings file 'C:\Users\user\Documents\Flutter Programs\App 1\hello_world\android\settings.gradle' (C:\Users\user\.gradle\caches\6.7\scripts\1fnwrr8g4rohfp291nvlxj5qe).
> BUG! exception in phase 'semantic analysis' in source unit '_BuildScript_' Unsupported class file major version 60
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 758ms
Exception: Gradle task assembleDebug failed with exit code 1
Exited (sigterm)
更新2.0现在该应用程序可以在web emulator中运行,可以在microsoft edge中运行,但不能在任何其他android emulator中运行。
确保你已连接到internet,第一次运行你的应用程序时,Flatter需要从internet下载一些东西,这解决了我的问题。
检查网络连接,如果使用vpn,请重试尝试停用
如果从命令面板清理java语言服务器工作区不起作用,那么您当前为gradle项目使用的jdk似乎太高而不兼容。为项目安装并使用JDK8。在Gradle项目的build.gradle
中:
sourceCompatibility = 1.8
targetCompatibility = 1.8
与交付的解决方案类似的问题,您可能希望查看:
首次发生颤振生成错误:无法打开的设置重新映射的类缓存
缺陷!“语义分析”阶段出现异常
我正试图从Flatter网站上消化以下信息。 Flutter如何在Android上运行我的代码? 引擎的C和C代码是用Android的NDK编译的。Dart代码(SDK和您的)是提前(AOT)编译到本机、ARM和x86库中的。这些库包含在一个“runner”Android项目中,整个项目都内置在一个APK中。启动时,应用程序将加载颤振库。任何呈现、输入或事件处理等都被委托给编译的flatter和应
将颤振集成到主机应用程序(docs)时,有几种方法可以实现,其中一种(最简单的)方法是通过颤振活动类在新活动中打开颤振。这样地: 传统上,对于Flutter侧的Android风格窗口,我们创建带有后退按钮的AppBar。 此AppBar后退按钮和Android系统后退按钮的行为必须相同:按下后退按钮时,前台活动必须关闭(完成)。 目前系统后退按钮确实关闭了,但如何从flutters AppBar后
当我运行命令时,由于flutter设置的Dart版本,我得到了以下错误: Flutter 0.6.0•频道beta•https://github.com/Flutter/Flutter.git 框架•修订9299C02CF7(2周前)•2018-08-16 00:35:12+0200 引擎•修订E3687F70C7 工具•飞镖2.1.0-dev.0.0.Flutter-BE6309690F 我想知
Xcode的输出:在文件中包含从 /Users/dani/development/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher-6.0.3/ios/Classes/FLTURLLauncherPlugin.m: 7: /Users/dani/development/flutter/.pub-cache/hosted/pub.dart
我最近回到了我以前的flutter项目,更新了一大堆东西,因为我得到了错误。现在我得到了下面的错误。我已经在上面至少3天了,尝试了一堆不同的东西,但我似乎仍然找不到解决办法。任何帮助都非常感谢。我还包含了下面的文件: 下面是我的: 这是我的: