flutter跑通腾讯云直播Demo

运行示例

前提条件

要求java jdk 11版本 并且配置到了环境变量 重要

要求flutter 版本 2.8.0 并且配置到了环境变量 重要

要求dart-sdk版本2.15 并且配置到了环境变量 重要

您已 注册腾讯云 账号,并完成 实名认证

申请 SDKAPPID 和 SECRETKEY

  1. 登录实时音视频控制台,选择【开发辅助】>【快速跑通Demo】。
  2. 单击【立即开始】,输入您的应用名称,例如TestTRTC,单击【创建应用】。

环境要求:

运行出问题

  • Launching lib\main.dart on V2164A in debug mode... Running Gradle task 'assembleDebug'... Warning: The plugin path_provider_android requires Android SDK version 33. For more information about build configuration, see https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration. Warning: The plugin shared_preferences_android requires Android SDK version 33. For more information about build configuration, see https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration. Warning: The plugin url_launcher_android requires Android SDK version 33. For more information about build configuration, see https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration. One or more plugins require a higher Android SDK version. Fix this issue by adding the following to C:\Users\Administrator\Desktop\ceshi\android\app\build.gradle: android { compileSdkVersion 33 ... } Warning: Mapping new ns http://schemas.android.com/repository/android/common/02 to old ns http://schemas.android.com/repository/android/common/01 Warning: Mapping new ns http://schemas.android.com/repository/android/generic/02 to old ns http://schemas.android.com/repository/android/generic/01 Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/02 to old ns http://schemas.android.com/sdk/android/repo/addon2/01 Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/03 to old ns http://schemas.android.com/sdk/android/repo/addon2/01 Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/02 to old ns http://schemas.android.com/sdk/android/repo/repository2/01 Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/03 to old ns http://schemas.android.com/sdk/android/repo/repository2/01 Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/03 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01 Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/02 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01 FAILURE: Build failed with an exception. * What went wrong: Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'. > Failed to find Build Tools revision 29.0.2 * 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 12s Exception: Gradle task assembleDebug failed with exit code 1 
    
    
    
  • 怎么回事

  • 这个错误通常是由于Flutter项目中的某些插件需要更高版本的Android SDK,而你的项目当前使用的Android SDK版本不符合要求所致。具体来说,错误信息中提到了需要 Android SDK 版本 33,而你当前的项目使用的版本较低。

    要解决这个问题,你需要更新你的 Android 项目的编译 SDK 版本到 33。你可以按照错误信息中提供的建议,在你的项目的 android/app/build.gradle 文件中添加以下内容:

     
  • android {
      compileSdkVersion 33
      ...
    }
    

    然后重新运行你的Flutter项目,应该就能够成功构建了。

  • 问题



    Warning: This version only understands SDK XML versions up to 2 but an SDK XML file of version 3 was encountered. This can happen if you use versions of Android Studio and the command-line tools that were released at different times. Warning: �����Ԫ�� (uri:"", local:"base-extension")������Ԫ��Ϊ<{}codename>,<{}layoutlib>,<{}api-level> FAILURE: Build failed with an exception. * What went wrong: Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'. > Failed to find Build Tools revision 30.0.2 * 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 2m 41s Exception: Gradle task assembleDebug failed with exit code 1




    怎么回事

  • 这个错误提示表明你的项目中使用了一个不兼容的 Android SDK 版本。具体来说,错误信息中提到了需要 Build Tools 版本 30.0.2,但是你的环境中没有找到这个版本的构建工具。

    要解决这个问题,你可以按照以下步骤操作:

    1. 打开 Android Studio,然后点击顶部菜单中的 “Tools” -> "SDK Manager"。
    2. 在 “SDK Platforms” 标签下,确保你已经安装了 Android 11.0(API level 30)的 SDK。
    3. 在 “SDK Tools” 标签下,确保你已经安装了 “Android SDK Build-Tools” 版本 30.0.2。
    4. 如果没有找到相应的版本,点击相应的复选框进行安装。
    5. 安装完成后,重新构建你的项目,应该就可以成功了。

    如果你无法在 Android Studio 中找到所需的版本,你也可以手动下载并安装相应的 SDK 和构建工具。安装完成后,确保在你的项目中正确配置了使用这个版本的 SDK 和构建工具。

    一旦你的环境中安装了所需的 SDK 和构建工具,重新运行你的 Flutter 项目,应该就能够成功构建了。

  • FAILURE: Build failed with an exception.

    * What went wrong:
    Could not determine the dependencies of task ':permission_handler:compileDebugAidl'.
    > Failed to find Platform SDK with path: platforms;android-29

    * 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 5s
    Exception: Gradle task assembleDebug failed with exit code 1

    什么原因

  • 这个错误提示表明在编译 permission_handler 这个库时,Gradle 找不到指定路径下的 Android 平台 SDK,路径为 platforms;android-29

    要解决这个问题,你可以尝试以下步骤:

    1. 确保你的项目中包含了 Android 平台 SDK 版本为 29 的文件。你可以通过打开 Android Studio,然后点击顶部菜单中的 “Tools” -> "SDK Manager",在 “SDK Platforms” 标签下确认是否安装了 Android 10.0(API level 29)的 SDK。

    2. 如果没有安装,你可以在 SDK Manager 中选择相应的 SDK 版本进行安装。

    3. 如果你已经安装了对应的 SDK,但仍然出现这个错误,可能是 Gradle 配置有误。你可以检查你的 android/build.gradle 文件,确保 compileSdkVersiontargetSdkVersion 版本设置正确,指向了正确的 SDK 版本。

    4. 最后,如果以上步骤都没有解决问题,你可以尝试清理 Gradle 缓存并重新构建项目。可以通过在终端中运行以下命令来清理 Gradle 缓存:

       
    1. flutter clean
      

      然后重新运行你的 Flutter 项目。

    通过这些步骤,应该能够解决你遇到的问题。

  • FAILURE: Build failed with an exception.
    
    * What went wrong:
    Could not determine the dependencies of task ':tencent_trtc_cloud:compileDebugAidl'.
    > Failed to find Platform SDK with path: platforms;android-28
    
    * 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 5s
  • 这个错误提示表明在编译 tencent_trtc_cloud 这个库时,Gradle 找不到指定路径下的 Android 平台 SDK,路径为 platforms;android-28

    要解决这个问题,你可以尝试以下步骤:

    1. 确保你的项目中包含了 Android 平台 SDK 版本为 28 的文件。你可以通过打开 Android Studio,然后点击顶部菜单中的 “Tools” -> "SDK Manager",在 “SDK Platforms” 标签下确认是否安装了 Android 9.0(API level 28)的 SDK。

    2. 如果没有安装,你可以在 SDK Manager 中选择相应的 SDK 版本进行安装。

    3. 如果你已经安装了对应的 SDK,但仍然出现这个错误,可能是 Gradle 配置有误。你可以检查你的 android/build.gradle 文件,确保 compileSdkVersiontargetSdkVersion 版本设置正确,指向了正确的 SDK 版本。

    4. 最后,如果以上步骤都没有解决问题,你可以尝试清理 Gradle 缓存并重新构建项目。可以通过在终端中运行以下命令来清理 Gradle 缓存:

       
    1. flutter clean
      

      然后重新运行你的 Flutter 项目。

    通过这些步骤,应该能够解决你遇到的问题。

  • /D:/flutter_windows_2.8.0-stable/.pub-cache/hosted/pub.flutter-io.cn/tencent_trtc_cloud-2.7.7/lib/trtc_cloud_listener.dart:661:25: Error: The getter 'Uint8List' isn't defined for the class 'TRTCAudioFrameListenerPlatformMethod'.
     - 'TRTCAudioFrameListenerPlatformMethod' is from 'package:tencent_trtc_cloud/trtc_cloud_listener.dart' ('/D:/flutter_windows_2.8.0-stable/.pub-cache/hosted/pub.flutter-io.cn/tencent_trtc_cloud-2.7.7/lib/trtc_cloud_listener.dart').
    Try correcting the name to the name of an existing getter, or defining a getter or field named 'Uint8List'.
          audioFrame.data = Uint8List.fromList(List<int>.from(params['data']));
                            ^^^^^^^^^
    /D:/flutter_windows_2.8.0-stable/.pub-cache/hosted/pub.flutter-io.cn/tencent_trtc_cloud-2.7.7/lib/trtc_cloud_listener.dart:677:30: Error: The getter 'Uint8List' isn't defined for the class 'TRTCAudioFrameListenerPlatformMethod'.
     - 'TRTCAudioFrameListenerPlatformMethod' is from 'package:tencent_trtc_cloud/trtc_cloud_listener.dart' ('/D:/flutter_windows_2.8.0-stable/.pub-cache/hosted/pub.flutter-io.cn/tencent_trtc_cloud-2.7.7/lib/trtc_cloud_listener.dart').
    Try correcting the name to the name of an existing getter, or defining a getter or field named 'Uint8List'.
          audioFrame.extraData = Uint8List.fromList(List<int>.from(params['extraData']));
                                 ^^^^^^^^^
    
    
    FAILURE: Build failed with an exception.
    
    * Where:
    Script 'D:\flutter_windows_2.8.0-stable\packages\flutter_tools\gradle\flutter.gradle' line: 1070
    
    * What went wrong:
    Execution failed for task ':app:compileFlutterBuildDebug'.
    > Process 'command 'D:\flutter_windows_2.8.0-stable\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 24s
    Exception: Gradle task assembleDebug failed with exit code 1
    
    
    怎么回事
    
  • 这个错误提示表明在编译过程中出现了无法识别的类或方法。具体来说,代码中引用了不存在的 Uint8List 类型。

    要解决这个问题,你可以尝试以下步骤:

    1. 检查依赖版本: 确保你使用的 tencent_trtc_cloud 库的版本与你的代码兼容。有时候更新库版本或者降低库版本可以解决这类问题。

    2. 检查引用路径: 确保 Uint8List 类型被正确地引入。在 Dart 中,Uint8List 类型通常是从 dart:typed_data 中引入的。你可以检查一下是否在文件开头引入了该类:

       
    1. import 'dart:typed_data';
      
    2. 检查参数类型: 确保传递给 Uint8List.fromList 方法的参数类型是 List<int>。你可以添加一些调试语句,确认参数类型和值是否正确。

    3. 清理缓存并重新构建: 有时候清理 Flutter 和 Gradle 的缓存可以解决一些编译问题。你可以尝试运行 flutter clean 命令清理 Flutter 缓存,然后重新构建项目。

    4. 查看文档和示例: 如果以上方法都没有解决问题,你可以查看相关库的文档和示例,看是否有类似的用法示例或者已知的解决方法。

    通过以上步骤,你应该能够解决这个编译错误。如果问题仍然存在,可以提供更多的代码片段或者详细的错误信息,这样我可以给出更具体的帮助。

  • ע: D:\flutter_windows_2.8.0-stable\.pub-cache\hosted\pub.flutter-io.cn\path_provider_android-2.0.12\android\src\main\java\io\flutter\plugins\pathprovider\PathProviderPlugin.javaʹ����δ�����򲻰�ȫ�IJ�����
    ע: �й���ϸ��Ϣ, ��ʹ�� -Xlint:unchecked ���±��롣
    ע: ijЩ�����ļ�ʹ�û򸲸����ѹ�ʱ�� API��
    ע: �й���ϸ��Ϣ, ��ʹ�� -Xlint:deprecation ���±��롣
    ע: ijЩ�����ļ�ʹ����δ�����򲻰�ȫ�IJ�����
    ע: �й���ϸ��Ϣ, ��ʹ�� -Xlint:unchecked ���±��롣
    
    乱码
  • 这些警告信息看起来是由于编译过程中使用了非 ASCII 字符,导致终端输出了乱码。虽然这些警告信息看起来比较杂乱,但通常不会影响到你的应用程序的运行。

    根据警告信息中提到的路径 D:\flutter_windows_2.8.0-stable\.pub-cache\hosted\pub.flutter-io.cn\path_provider_android-2.0.12\android\src\main\java\io\flutter\plugins\pathprovider\PathProviderPlugin.java,似乎是在处理路径提供者插件(path_provider)的 Android 部分时出现了一些问题。但从这个信息来看,并没有提供具体的错误信息或者异常。

    要解决这个问题,你可以尝试以下几点:

    1. 清理缓存并重新构建: 运行 flutter clean 清理 Flutter 缓存,然后重新构建你的应用程序。

    2. 检查依赖版本: 确保你使用的 path_provider 插件的版本是最新的,并且与你的 Flutter 版本兼容。

    3. 查看详细日志: 如果上述步骤无法解决问题,你可以尝试添加 -v 参数重新运行构建命令,以获取更详细的日志信息,帮助你定位问题所在。

    4. 更新插件: 如果问题依然存在,可以尝试更新相关的插件或者依赖库到最新版本,看是否有已知的问题修复。

    通过以上步骤,你应该能够解决这个警告信息所引发的问题。如果问题依然存在,欢迎提供更多的详细信息,我会尽力帮助你解决。

安装到手机如果白屏的话,请关闭app后台让后将 ,让后重新启动app就可以看到所有模块按钮了

 

  • 27
    点赞
  • 18
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论
Flutter是一种跨平台的移动应用开发框架,能够实现在iOS、Android和Web三个平台上进行开发和适配。以下是一个简单的Flutter三端适配的Demo实现。 首先,在flutter项目的根目录下创建一个名为`lib`的文件夹,用于存放我们的Flutter代码。然后,在`lib`文件夹下创建三个文件夹,分别为`android`、`ios`和`web`,用于存放对应平台的代码。 在`android`文件夹中,可以编写Android平台相关的代码。例如,可以在`MainActivity.kt`中做一些Android特定的设置,比如隐藏导航栏、设置应用图标等。 在`ios`文件夹中,可以编写iOS平台相关的代码。例如,可以在`AppDelegate.swift`中设置应用程序的启动配置、设置推送通知等。 在`web`文件夹中,可以编写Web平台相关的代码。例如,可以在`index.html`文件中修改网页标题、添加favicon等。 接下来,在`lib`文件夹下创建一个名为`main.dart`的文件,用于编写Flutter应用的业务逻辑。在`main.dart`中,可以编写整个应用程序的界面和交互逻辑。 在`main.dart`中,需要使用`Platform`类来判断当前运行的平台,并根据平台做出不同的适配。例如,可以使用`Platform.isAndroid`来判断当前是否是Android平台,然后分别调用Android平台的特定代码。同样的,也可以使用`Platform.isIOS`和`Platform.isWeb`来判断当前平台,并进行相应的适配。 总结起来,一个Flutter三端适配的Demo就是在一个Flutter项目中,通过编写平台特定的代码,针对不同的平台进行适配。通过使用`Platform`类来判断当前运行的平台,并根据平台的不同做出相应的操作和适配。这样就能够实现在iOS、Android和Web三个平台上进行开发和适配。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

王家视频教程图书馆

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值