我创建了新的 flutter 项目。并将我的手机作为模拟器连接到 Android Studio。
当我尝试运行该项目而不更改内部任何内容时,它在控制台中显示此错误:
**[Fatal Error] kotlin-stdlib-jdk7-1.7.10.pom:2:1: Content is not allowed in prolog.
[Fatal Error] x86_debug-1.0.0-2a3401c9bbb5a9a9aec74d4f735d18a9dd3ebf2d.pom:2:1: Content is not allowed in prolog.
[Fatal Error] flutter_embedding_debug-1.0.0-2a3401c9bbb5a9a9aec74d4f735d18a9dd3ebf2d.pom:2:1: Content is not allowed in prolog.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:checkDebugAarMetadata'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
> Could not resolve io.flutter:flutter_embedding_debug:1.0.0-2a3401c9bbb5a9a9aec74d4f735d18a9dd3ebf2d.
Required by:
project :app
> Could not resolve io.flutter:flutter_embedding_debug:1.0.0-2a3401c9bbb5a9a9aec74d4f735d18a9dd3ebf2d.
> Could not parse POM https://storage.googleapis.com/download.flutter.io/io/flutter/flutter_embedding_debug/1.0.0-2a3401c9bbb5a9a9aec74d4f735d18a9dd3ebf2d/flutter_embedding_debug-1.0.0-2a3401c9bbb5a9a9aec74d4f735d18a9dd3ebf2d.pom
> Content is not allowed in prolog.
> Could not resolve io.flutter:x86_debug:1.0.0-2a3401c9bbb5a9a9aec74d4f735d18a9dd3ebf2d.
Required by:
project :app
> Could not resolve io.flutter:x86_debug:1.0.0-2a3401c9bbb5a9a9aec74d4f735d18a9dd3ebf2d.
> Could not parse POM https://storage.googleapis.com/download.flutter.io/io/flutter/x86_debug/1.0.0-2a3401c9bbb5a9a9aec74d4f735d18a9dd3ebf2d/x86_debug-1.0.0-2a3401c9bbb5a9a9aec74d4f735d18a9dd3ebf2d.pom
> Content is not allowed in prolog.
> Could not resolve org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.10.
Required by:
project :app
> Could not resolve org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.10.
> Could not parse POM https://repo.maven.apache.org/maven2/org/jetbrains/kotlin/kotlin-stdlib-jdk7/1.7.10/kotlin-stdlib-jdk7-1.7.10.pom
> Content is not allowed in prolog.
* 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 27s
Exception: Gradle task assembleDebug failed with exit code 1**
如果您需要项目:
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
useMaterial3: true,
),
home: const MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key, required this.title});
final String title;
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
int _counter = 0;
void _incrementCounter() {
setState(() {
_counter++;
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
title: Text(widget.title),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
const Text(
'You have pushed the button this many times:',
),
Text(
'$_counter',
style: Theme.of(context).textTheme.headlineMedium,
),
],
),
),
floatingActionButton: FloatingActionButton(
onPressed: _incrementCounter,
tooltip: 'Increment',
child: const Icon(Icons.add),
), // This trailing comma makes auto-formatting nicer for build methods.
);
}
}
但是当我尝试使用 Chrome(网络)运行该项目时,它运行得很好。当涉及到模拟器时,它会显示上面写的错误。
我在谷歌上进行了研究,发现了一些类似的错误,但并不完全相同。虽然我尝试过,但没有任何改变,仍然是同样的错误。