首页 > 其他分享 >Flutter module集成到Android原生项目报错

Flutter module集成到Android原生项目报错

时间:2023-10-10 16:14:03浏览次数:52  
标签:1.0 module gradle 报错 build Android com flutter

使用AAR方案集成遇到两个诡异错误

环境:

  • Flutter (Channel stable, 3.3.10, on macOS 13.5.2 22G91 darwin-x64, locale
    zh-Hans-CN)
  • Android Studio (version 2022.3)
  • Android toolchain - develop for Android devices (Android SDK version 34.0.0)

参考文档en
参考文档zh

  1. 生成flutter module aar
flutter build aar
  1. 按照终端提示操作集成
    ...
    同步失败
报错:Build was configured to prefer settings repositories over project repositories but repository 'maven' was added by build file 'app/build.gradle'

错误原因:
在settings.gradle里面定了repositories和maven,又在build.gradle里面定义repositorie导致冲突

解决方法:
不在build.gradle里定义repositorie,仅在settings.gradle定义

// settings.gradle
dependencyResolutionManagement {
        repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
        repositories {
            google()
            mavenCentral()
            maven {
                url 'path/to/your/flutter_module/build/host/outputs/repo'
                // This is relative to the location of the build.gradle file
                // if using a relative path.
            }
            maven {
                url 'https://storage.googleapis.com/download.flutter.io'
            }
        }
}

修正上面错误后sync成功,运行项目失败

错误:Could not find flutter-1.0-debug.jar

错误原因:
没找到之前输出打包的aar

解决方法:

dependencies {
    debugImplementation 'com.example.flutter_module:flutter:1.0:debug'
    profileImplementation 'com.example.flutter_module:flutter:1.0:profile'
    releaseImplementation 'com.example.flutter_module:flutter:1.0:release'
}
// 修正为
dependencies {
    debugImplementation 'com.example.flutter_module:flutter_debug:1.0'
    profileImplementation 'com.example.flutter_module:flutter_profile:1.0'
    releaseImplementation 'com.example.flutter_module:flutter_release:1.0'
}

修改后可以正确加载打包的aar依赖并成功运行
基本这两个错误都是flutter的文档过时了...没点安卓原生功底解决起来真的麻烦

标签:1.0,module,gradle,报错,build,Android,com,flutter
From: https://www.cnblogs.com/ligun123/p/17754933.html

相关文章

  • Android Studio可以编译但Flutter提示无法定位java runtime
    AndroidStudio可以编译但Flutter提示无法定位javaruntime下面我们重点讲一下“UnabletofindbundledJavaversion”报错问题到AndroidStudio安装目录下注意:有些AndroidStudio可能是“jbr”文件,不用管jbr文件,直接复制一份jbr文件在同一路经,再把复制的文件改名为“jre”文......
  • ansible报 MODULE FAILURE
    在使用ansibles 批量连接新升级的欧拉系统时候,报MODULEFAILURE原因:ansibles 默认的python 名字叫python,需要使用python3,;而欧拉的python链接到的是python2 解决办法: 先将python重命名, 再执行:ln -s /usr/bin/python3 /usr/bin/python将python链接到pyth......
  • Android设置spinner字体
    弹出下拉菜单可以直接设置,但是显示字体需要使用自定义适配器来生效你尝试在Spinner上应用了自定义的样式,但似乎字体大小未更改。在Spinner控件中更改字体大小可能需要使用自定义适配器来生效。尽管你在样式setting_spinner中设置了android:textSize,但这只会影响下拉列表中......
  • SQLServer报错: Got minus one from a read call
    用JDBC连接SqlServer数据库时,报这个错误。网上很多都说是数据库的连接已经满了。但我实际查询的时候,数据库连接数并没有满。 后来发现原因了,是代码存在疏忽。我把驱动类写成了Oracle的驱动类。所以这个错误实际上有一种可能是因为使用了错误的驱动类导致的。 ......
  • app直播源代码,android中几种常用的弹框
    app直播源代码,android中几种常用的弹框一、SweetAlertDialog弹框使用该控件需要添加依赖: implementation'com.github.f0ris.sweetalert:library:1.5.1'​下面是具体用法:  newSweetAlertDialog(this,SweetAlertDialog.WARNING_TYPE)        .setTitl......
  • 学习笔记427—Python Keras 报错AttributeError: 'Sequential' object has no attribu
    PythonKeras报错AttributeError:'Sequential'objecthasnoattribute'predict_classes'解决方法本文文要介绍Python中,使用Keras执行yhat_classes=model.predict_classes(X_test)代码报错:AttributeError:'Sequential'objecthasnoattribute'pr......
  • Android Activity的玩法
    TODO基本的使用IntentTODO基础的使用方法Intent传输数据//添加Intentintent=newIntent(activity,TargetActivity.class);intent.putExtra(Stringname,Objectdata);startActivity(intent)//使用intent=getIntent()intent.getExtra(Stringkey).var;Acti......
  • go gomail.v2发送邮件报错unencrypted connection
    实现Auth接口typeauthstruct{hoststringusernamestringpasswordstring}func(a*auth)Start(server*smtp.ServerInfo)(protostring,toServer[]byte,errerror){if!server.TLS{advertised:=falsefor_,mechanis......
  • AttributeError: module 'tensorflow.compat.v2' has no attribute '__internal__'
     File/home/software/anaconda3/envs/mydlenv/lib/python3.8/site-packages/keras/backend_config.py:3328#Defaultimagedataformat,oneof"channels_last","channels_first".29_IMAGE_DATA_FORMAT="channels_last"......
  • MPAndroidChart 中的HorizontalBarChart数值显示不全问题
    privateHorizontalBarCharthor_bar_chart;hor_bar_chart=(HorizontalBarChart)findViewById(R.id.hor_barchart);YAxisleftYAxis=hor_bar_chart.getAxisLeft();//设置y轴边距,解决数值过大显示不全问题leftYAxis.setSpaceTop(25f);privateHorizontalBarCharthor_bar_c......