尝试运行时在我的第一个Flutter应用中出现错误

时间:2019-05-30 15:36:23

标签: android gradle flutter

我只是试图用Flutter运行我的第一个hello world应用程序。但是在选择模拟器并运行时单击它会显示错误。

这是我的代码:

import "package:flutter/material.dart";

void main()
{
  runApp(

      Center(child:Text("Hello world!", textDirection: TextDirection.ltr) ,)
  );
}

和我得到的错误:

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:transformNativeLibsWithMergeJniLibsForDebug'.
> org/apache/commons/codec/binary/Base64

* 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 13s
Finished with error: Gradle task assembleDebug failed with exit code 1

怎么了?我该如何解决?

2 个答案:

答案 0 :(得分:0)

根据此github issue,您只需将其添加到build.gradle文件中即可:

 packagingOptions {
     pickFirst 'lib/x86/libc++_shared.so'
     pickFirst 'lib/arm64-v8a/libc++_shared.so'
     pickFirst 'lib/x86_64/libc++_shared.so'
     pickFirst 'lib/armeabi-v7a/libc++_shared.so'
 }

答案 1 :(得分:0)

我遵循并测试了您的代码,发现没有问题应用程序运行正常,完全没有错误 Here is the output 代码:

import "package:flutter/material.dart";

void main() {
  runApp(Center(
    child: Text("Hello world!", textDirection: TextDirection.ltr),
  ));
}

您可以尝试对sdk / app进行故障诊断

  

尝试运行命令flutter clean

     

颤抖的医生

希望此方法有效,添加您的日志,以便我们在运行此命令后可以调查问题