首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >无法将animation.json文件加载到flutter项目

无法将animation.json文件加载到flutter项目
EN

Stack Overflow用户
提问于 2020-12-15 02:17:21
回答 1查看 710关注 0票数 1

我使用bodymovin从Aftereffect导出了animation.json文件,但无法将其加载到我的flutter项目中。

我遵循这个中等的article,我无法渲染动画,也是在将文件路径放在pubspec.yaml文件的资源中之后。

我试着将我的代码简化为:

代码语言:javascript
运行
复制
import 'package:flutter/material.dart';
import 'package:lottie/lottie.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: ListView(
          children: [
            // Load a Lottie file from your assets
            Lottie.asset('assets/optimal.json'),

            // Load a Lottie file from a remote url
            Lottie.network(
                'https://raw.githubusercontent.com/xvrh/lottie-flutter/master/example/assets/Mobilo/A.json'),

            // Load an animation and its images from a zip file
            // Lottie.asset('assets/lottiefiles/angel.zip'),
          ],
        ),
      ),
    );
  }
}

下面是错误消息:

代码语言:javascript
运行
复制
> FAILURE: Build failed with an exception.
> 
> * Where: Script 'C:\src\flutter\packages\flutter_tools\gradle\flutter.gradle' line:
> 904
> 
> * What went wrong: Execution failed for task ':app:compileFlutterBuildDebug'.
> > Process 'command 'C:\src\flutter\bin\flutter.bat'' finished with non-zero exit value 1
> 
> * 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 44s Exception: Gradle task assembleDebug failed with
> exit code 1
EN

回答 1

Stack Overflow用户

发布于 2020-12-15 02:40:40

您可以尝试删除pubspec.lock并使用flutter pub get安装软件包。

票数 -1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/65294357

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档