当前位置: 首页 > news >正文

[Flutter]导入singular_flutter_sdk后运行到Android报错

问题:

接入归因之前,flutter项目一起正常。接入归因之后,iOS正常Android有问题。

dependencies:  # Singular归因singular_flutter_sdk: ^1.3.3

针对 Flutter 的 Singular SDK 集成指南

https://support.singular.net/hc/zh-cn/articles/4408894547227-%E9%92%88%E5%AF%B9-Flutter-%E7%9A%84-Singular-SDK-%E9%9B%86%E6%88%90%E6%8C%87%E5%8D%97

当前环境配置

android/app/build.gradle

plugins {id "com.android.application"id "kotlin-android"id "dev.flutter.flutter-gradle-plugin"// 应用Google服务Gradle插件id 'com.google.gms.google-services'
}def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {localPropertiesFile.withReader('UTF-8') { reader ->localProperties.load(reader)}
}def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {flutterVersionCode = '1'
}def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {flutterVersionName = '1.0'
}android {namespace "com.teleprom.www"// compileSdkVersion是用来编译你的应用的API级别。它指定了编译时使用的Android API版本。你的代码将会使用这个版本的Android API进行编译。它应该是你打算使用的最新稳定版API版本。compileSdk flutter.compileSdkVersion// ndkVersion是指定项目要使用的Android NDK(Native Development Kit)的版本。NDK允许你使用C和C++代码来编译本地代码,通常用于性能敏感的部分。当你使用需要NDK的插件或直接编写本地代码时,这个版本就变得重要。//ndkVersion flutter.ndkVersionndkVersion "25.1.8937393"  compileOptions {sourceCompatibility JavaVersion.VERSION_1_8targetCompatibility JavaVersion.VERSION_1_8}kotlinOptions {jvmTarget = '1.8'}sourceSets {main.java.srcDirs += 'src/main/kotlin'}defaultConfig {applicationId "com.teleprom.www"// minSdkVersion指定了能够运行你的应用的最低Android API级别。如果一个设备的API级别低于这个值,该设备将无法在Google Play商店安装或运行你的应用。这个值应该尽可能低,以覆盖更广泛的用户,但同时要高到足以支持应用所需功能的API级别。//minSdkVersion flutter.minSdkVersionminSdkVersion 22  targetSdkVersion flutter.targetSdkVersionversionCode flutterVersionCode.toInteger()versionName flutterVersionName}buildTypes {release {// TODO: Add your own signing config for the release build.// Signing with the debug keys for now, so `flutter run --release` works.signingConfig signingConfigs.debug}}
}flutter {source '../..'
}dependencies {// 添加Firebase Analytics依赖implementation platform('com.google.firebase:firebase-bom:32.7.4') // 使用适合你项目的最新BOM版本implementation 'com.google.firebase:firebase-analytics'// 依赖关系列表中添加 Singular 库implementation fileTree(dir: 'libs', include: ['*.jar'])implementation 'com.android.support:appcompat-v7:28.0.0'// 注意: 如果在构建时出现DuplicateClasses(重复类 )错误,则可能已经安装了 Google play-services,可以注释掉该依赖关系。implementation 'com.android.installreferrer:installreferrer:2.2'implementation 'com.google.android.gms:play-services-appset:16.0.2'
}

android/build.gradle

buildscript {ext.kotlin_version = ''1.9.23'repositories {google()mavenCentral()}dependencies {classpath 'com.android.tools.build:gradle:8.1.3'classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"}
}allprojects {repositories {google()mavenCentral()}
}rootProject.buildDir = '../build'
subprojects {project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {project.evaluationDependsOn(':app')
}tasks.register("clean", Delete) {delete rootProject.buildDir
}

settings.gradle

pluginManagement {def flutterSdkPath = {def properties = new Properties()file("local.properties").withInputStream { properties.load(it) }def flutterSdkPath = properties.getProperty("flutter.sdk")assert flutterSdkPath != null, "flutter.sdk not set in local.properties"return flutterSdkPath}settings.ext.flutterSdkPath = flutterSdkPath()includeBuild("${settings.ext.flutterSdkPath}/packages/flutter_tools/gradle")repositories {google()mavenCentral()gradlePluginPortal()}
}plugins {id "dev.flutter.flutter-plugin-loader" version "1.0.0"id "com.android.application" version "8.1.3" apply false id "org.jetbrains.kotlin.android" version "1.9.23" apply false// 添加Google服务插件. apply false 表示该插件不会立即应用到项目中,而是可以在子项目(模块)中单独应用。id 'com.google.gms.google-services' version '4.3.15' apply false
}include ":app"

gradle/wrapper/gradle-wrapper.properties

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl = https\://services.gradle.org/distributions/gradle-8.4-bin.zip

运行到Android报错1

报错日志:

Launching lib/main.dart on vivo X20 in debug mode...FAILURE: Build completed with 2 failures.1: Task failed with an exception.
-----------
* What went wrong:
A problem occurred configuring project ':singular_flutter_sdk'.
> Could not create an instance of type com.android.build.api.variant.impl.LibraryVariantBuilderImpl.> Namespace not specified. Specify a namespace in the module's build file. See https://d.android.com/r/tools/upgrade-assistant/set-namespace for information about setting the namespace.If you've specified the package attribute in the source AndroidManifest.xml, you can use the AGP Upgrade Assistant to migrate to the namespace value in the build file. Refer to https://d.android.com/r/tools/upgrade-assistant/agp-upgrade-assistant for general information about using the AGP Upgrade Assistant.* 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.
==============================================================================2: Task failed with an exception.
-----------
* What went wrong:
Failed to query the value of property 'buildFlowServiceProperty'.
> Could not isolate value org.jetbrains.kotlin.gradle.plugin.statistics.BuildFlowService$Parameters_Decorated@7d79dba7 of type BuildFlowService.Parameters> A problem occurred configuring project ':singular_flutter_sdk'.> Could not create an instance of type com.android.build.api.variant.impl.LibraryVariantBuilderImpl.> Namespace not specified. Specify a namespace in the module's build file. See https://d.android.com/r/tools/upgrade-assistant/set-namespace for information about setting the namespace.If you've specified the package attribute in the source AndroidManifest.xml, you can use the AGP Upgrade Assistant to migrate to the namespace value in the build file. Refer to https://d.android.com/r/tools/upgrade-assistant/agp-upgrade-assistant for general information about using the AGP Upgrade Assistant.* 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 4s
Error: Gradle task assembleDebug failed with exit code 1Exited (1).

解决:

按照搜索到的办法,并非所有包都支持版本 8.xx,将 Android Gridle 插件版本 8.1.3 降级到 7.4.2 来解决这个问题。

flutter firebase app not running on Android: Namespace not specified - Stack Overflow

android/build.gradle:

buildscript {ext.kotlin_version = ''1.8.0'repositories {google()mavenCentral()}dependencies {classpath 'com.android.tools.build:gradle:7.4.2'classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"}
}
...

settings.gradle

...
plugins {id "com.android.application" version "7.4.2" apply false id "org.jetbrains.kotlin.android" version "1.8.0" apply false...
}

gradle/wrapper/gradle-wrapper.properties

...
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.3-all.zip

 

运行到Android报错ERROR:D8: com.android.tools.r8.kotlin.H

修复完第一个问题后,运行包这个错误。

报错日志:

Launching lib/main.dart on vivo X20 in debug mode...
注: /Users/gamin/.pub-cache/hosted/pub.flutter-io.cn/singular_flutter_sdk-1.3.3/android/src/main/java/com/singular/flutter_sdk/SingularSDK.java使用了未经检查或不安全的操作。
注: 有关详细信息, 请使用 -Xlint:unchecked 重新编译。
ERROR:D8: com.android.tools.r8.kotlin.HFAILURE: Build failed with an exception.* What went wrong:
Execution failed for task ':app:mergeExtDexDebug'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.> Failed to transform play-services-measurement-api-21.5.1.aar (com.google.android.gms:play-services-measurement-api:21.5.1) to match attributes {artifactType=android-dex, asm-transformed-variant=NONE, dexing-enable-desugaring=true, dexing-enable-jacoco-instrumentation=false, dexing-is-debuggable=true, dexing-min-sdk=22, org.gradle.status=release, org.gradle.usage=java-runtime}.> Execution failed for DexingWithClasspathTransform: /Users/gamin/.gradle/caches/transforms-3/4e42575ef433f9d8bb5373944a07a9ed/transformed/jetified-play-services-measurement-api-21.5.1-runtime.jar.> Error while dexing.* 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.orgBUILD FAILED in 3m 55s┌─ Flutter Fix ──────────────────────────────────────────────────────────────┐
│ [!] The shrinker may have failed to optimize the Java bytecode.            │
│ To disable the shrinker, pass the `--no-shrink` flag to this command.      │
│ To learn more, see: https://developer.android.com/studio/build/shrink-code │
└────────────────────────────────────────────────────────────────────────────┘
Error: Gradle task assembleDebug failed with exit code 1Exited (1).

解决:

有个类似问题:https://github.com/flutter/flutter/issues/146038

将最低支持版本从22升级到24

android/app/build.gradle:

android {defaultConfig {minSdkVersion 24}
}

相关文章:

[Flutter]导入singular_flutter_sdk后运行到Android报错

问题: 接入归因之前,flutter项目一起正常。接入归因之后,iOS正常Android有问题。 dependencies: # Singular归因singular_flutter_sdk: ^1.3.3 针对 Flutter 的 Singular SDK 集成指南 https://support.singular.net/hc/zh-cn/articles/…...

ChatGPT新手指南:如何用AI写出专业学术论文

ChatGPT无限次数:点击直达 ChatGPT新手指南:如何用AI写出专业学术论文 在当今信息爆炸的时代,人工智能技术的快速发展为我们提供了许多新的可能性。ChatGPT作为一种先进的自然语言处理技术,不仅能够进行对话和文本生成,还可以辅助…...

【ZZULIOJ】1047: 对数表(Java)

目录 题目描述 输入 输出 样例输入 Copy 样例输出 Copy code 题目描述 输入两个正整数m和n&#xff0c;输出m到n之间每个整数的自然对数。 输入 输入包括两个整数m和n(m<n)&#xff0c;之间用一个空格隔开。 输出 每行输出一个整数及其对数&#xff0c;整数占4…...

thinkphp6使用阿里云SDK发送短信

使用composer安装sdk "alibabacloud/dysmsapi-20170525": "2.0.24"封装发送短信类 发送到的短信参数写在env文件里面的 #发送短信配置 [AliyunSms] AccessKeyId "" AccessKeySecret "" signName"" templateCode"&…...

file_get_contents(‘php://input‘); 这个postman要如何传参

在 Postman 中传递参数给 file_get_contents(php://input); 是通过请求的 Body 部分来实现的。使用 Postman 进行 API 接口测试时&#xff0c;可以按照以下步骤来传递参数&#xff1a; 打开 Postman 并创建一个新的请求。在请求的 URL 地址栏输入你的 API 地址。选择请求方法为…...

HDFS [MSST‘10] 论文阅读笔记

原论文:The Hadoop Distributed File System (MSST’10) HDFS关键技术要点概览 设计目标:HDFS旨在可靠地存储大型数据集,并以高带宽流式传输这些数据集到用户应用程序。它通过在大量服务器上分布存储和计算资源,使得资源可以随着需求的增长而扩展,同时保持经济高效。架构组…...

Feature Pyramid Networks for object detection

FPN 总述1.引言2.相关工作3. Feature Pyramid NetworksBottom-up pathwayTop-down pathway and lateral connections 4. 应用用于 RPN用于 Fast R-CNN 核心代码复现FPN网络结构ResNet Bottleneck完整代码 总述 下图中&#xff0c;蓝色边框表示的是特征图&#xff0c;边框越粗表…...

Linux下docker运行python

前言 本机开发环境众多&#xff0c;python版本都好多个&#xff0c;虽然可以通过conda管理多个虚拟环境&#xff0c;但还是不能像容器那样进行进程间的隔离。于是打算试下docker下运行python&#xff0c;而且生产环境很多时候也是用容器来跑应用&#xff0c;环境统一、方便扩容…...

MacOS下载和安装HomeBrew的详细教程

在MacOS上安装Homebrew的详细教程如下&#xff1a;&#xff08;参考官网&#xff1a;macOS&#xff08;或 Linux&#xff09;缺失的软件包的管理器 — Homebrew&#xff09; 步骤1&#xff1a;检查系统要求 确保你的MacOS版本至少为macOS Monterey (12) (or higher) 或更高版本…...

AI技术在金融领域/银行业的应用和风险

前言 随着科技的不断发展&#xff0c;人工智能&#xff08;AI&#xff09;技术已经在各行各业得到了广泛的应用&#xff0c;其中包括银行业。银行业作为经济的重要组成部分&#xff0c;一直在不断地探索和应用新技术&#xff0c;以提升服务效率、风险管理和客户体验。然而&…...

每日OJ题_两个数组dp⑤_力扣10. 正则表达式匹配

目录 力扣10. 正则表达式匹配 解析代码 力扣10. 正则表达式匹配 10. 正则表达式匹配 难度 困难 给你一个字符串 s 和一个字符规律 p&#xff0c;请你来实现一个支持 . 和 * 的正则表达式匹配。 . 匹配任意单个字符* 匹配零个或多个前面的那一个元素 所谓匹配&#xff0c…...

开源区块链系统/技术 总结(欢迎补充,最新)

一、联盟链 1. FISCO BCOS FISCO BCOS 2.0 技术文档 — FISCO BCOS 2.0 v2.9.0 文档https://fisco-bcos-documentation.readthedocs.io/ 2. ChainMaker&#xff08;长安链&#xff09; 文档导航 — chainmaker-docs v2.3.2 documentationhttps://docs.chainmaker.org.cn/v2…...

LeetCode 994—— 腐烂的橘子

阅读目录 1. 题目2. 解题思路3. 代码实现 1. 题目 2. 解题思路 1.记录下初始新鲜橘子的位置到 notRotting&#xff0c;我们按照行把二维数组拉成一维&#xff0c;所以&#xff0c;一个vector 就可以实现了&#xff1b;2.如果没有新鲜橘子&#xff0c;那么第 0 分钟所有橘子已经…...

向上向下采样

在数字图像处理中&#xff0c;向上采样&#xff08;upsampling&#xff09;和向下采样&#xff08;downsampling&#xff09;是两种常见的操作&#xff0c;用于改变图像的分辨率。 向上采样&#xff08;Upsampling&#xff09;&#xff1a; 向上采样是指增加图像的分辨率&…...

Leetcode面试经典150_Q169多数元素

题目&#xff1a; 给定一个大小为 n 的数组 nums &#xff0c;返回其中的多数元素。多数元素是指在数组中出现次数 大于 ⌊n/2⌋ 的元素。 你可以假设数组是非空的&#xff0c;并且给定的数组总是存在多数元素。 解题思路&#xff1a; 1. 注意“大于 ⌊n/2⌋”&#xff0c;…...

Spring Cloud微服务入门(五)

Sentinel的安装与使用 安装部署Sentinel 下载Sentinel&#xff1a; https://github.com/alibaba/Sentinel/releases Sentinel控制台 https://localhost:8080 用户和密码为sentinel 使用Sentinel 加依赖&#xff1a; 写配置&#xff1a; 输入&#xff1a; java -Dserver.po…...

负荷预测 | Matlab基于TCN-GRU-Attention单输入单输出时间序列多步预测

目录 效果一览基本介绍程序设计参考资料 效果一览 基本介绍 1.Matlab基于TCN-GRU-Attention单输入单输出时间序列多步预测&#xff1b; 2.单变量时间序列数据集&#xff0c;采用前12个时刻预测未来96个时刻的数据&#xff1b; 3.excel数据方便替换&#xff0c;运行环境matlab20…...

SpringBoot整合Spring Data JPA

✅作者简介:大家好,我是Leo,热爱Java后端开发者,一个想要与大家共同进步的男人😉😉🍎个人主页:Leo的博客💞当前专栏: 循序渐进学SpringBoot ✨特色专栏: MySQL学习 🥭本文内容: SpringBoot整合Spring Data JPA 📚个人知识库: Leo知识库,欢迎大家访问 1.…...

机器学习(五) -- 监督学习(2) -- k近邻

系列文章目录及链接 目录 前言 一、K近邻通俗理解及定义 二、原理理解及公式 1、距离度量 四、接口实现 1、鸢尾花数据集介绍 2、API 3、流程 3.1、获取数据 3.2、数据预处理 3.3、特征工程 3.4、knn模型训练 3.5、模型评估 3.6、结果预测 4、超参数搜索-网格搜…...

【.NET全栈】ZedGraph图表库的介绍和应用

文章目录 一、ZedGraph介绍ZedGraph的特点ZedGraph的缺点使用注意事项 二、ZedGraph官网三、ZedGraph的应用四、ZedGraph的高端应用五、、总结 一、ZedGraph介绍 ZedGraph 是一个用于绘制图表和图形的开源.NET图表库。它提供了丰富的功能和灵活性&#xff0c;可以用于创建各种…...

基于大语言模型的本地语义搜索工具LLocalSearch部署与应用指南

1. 项目概述&#xff1a;一个能“读懂”你电脑的本地搜索工具 如果你和我一样&#xff0c;电脑里塞满了各种文档、邮件、聊天记录和代码片段&#xff0c;那么“找东西”这件事&#xff0c;绝对能排进日常最耗时的任务前三。传统的文件搜索&#xff0c;比如Windows自带的搜索或者…...

JetBrains IDE试用期重置终极指南:简单三步实现30天无限续杯

JetBrains IDE试用期重置终极指南&#xff1a;简单三步实现30天无限续杯 【免费下载链接】ide-eval-resetter 项目地址: https://gitcode.com/gh_mirrors/id/ide-eval-resetter 你是否曾经在项目开发的关键时刻&#xff0c;突然看到JetBrains IDE弹出"评估期已结束…...

认识Python数据包套接字

如你所知&#xff0c;数据包格式套接字&#xff08;Datagram Sockets&#xff09;也叫“无连接的套接字”&#xff0c;在代码中使用 SOCK_DGRAM 表示。可以将 SOCK_DGRAM 比喻成高速移动的摩托车快递&#xff0c;它有以下特征&#xff1a;强调快速传输而非传输顺序&#xff1b;…...

大语言模型与多模态生成融合:架构、工具与实践指南

1. 项目概述&#xff1a;当大语言模型遇见多模态生成最近两年&#xff0c;AI领域最激动人心的进展&#xff0c;莫过于大语言模型&#xff08;LLMs&#xff09;和多模态生成模型的“双向奔赴”。前者以ChatGPT、GPT-4为代表&#xff0c;展现了惊人的语言理解、推理和生成能力&am…...

DeepLake:AI原生数据湖统一管理多模态数据与向量嵌入

1. 项目概述&#xff1a;当数据湖遇上AI向量化如果你正在构建一个AI应用&#xff0c;无论是RAG检索增强生成系统、多模态模型训练&#xff0c;还是复杂的语义搜索&#xff0c;数据管理环节的复杂性往往会让你头疼不已。传统的文件系统、数据库&#xff0c;甚至是对象存储&#…...

Cortex-A78C架构解析:AMU与ETM寄存器实战指南

1. Cortex-A78C核心架构与寄存器概览Cortex-A78C是Armv8-A架构的高性能实现&#xff0c;面向移动计算和边缘AI场景优化。作为A78系列的安全增强版本&#xff0c;它在保留原有3发射乱序执行流水线的基础上&#xff0c;新增了Pointer Authentication等安全扩展&#xff0c;同时强…...

在 1688、阿里国际站上,怎么分清哪些是真工厂、哪些是贸易商?一份采购辨别清单

跨境卖家和采购最常踩的坑&#xff0c;就是把贸易商当成了源头工厂。结果是&#xff1a;报价里多了一手差价、打样要等贸易商再转给后面的厂、出了质量问题没人能进车间整改。 平台上的"工厂认证"“源头工厂”"工厂直供"标签&#xff0c;看起来像是替你做了…...

【Midjourney极简艺术风格终极指南】:20年视觉设计专家亲授3大构图法则、5类禁用提示词与1套可复用Prompt模板

更多请点击&#xff1a; https://intelliparadigm.com 第一章&#xff1a;极简艺术风格的本质与Midjourney适配原理 极简艺术风格并非简单地“减少元素”&#xff0c;而是通过精准的留白、克制的色彩、几何化的形态与高度凝练的视觉语法&#xff0c;实现信息密度与情绪张力的平…...

Arm Neoverse CMN-700一致性网格网络架构与寄存器配置详解

1. Arm Neoverse CMN-700一致性网格网络架构解析 在现代多核处理器设计中&#xff0c;一致性网格网络&#xff08;Coherent Mesh Network&#xff09;已成为解决核间通信瓶颈的关键技术。Arm Neoverse CMN-700作为第二代一致性互连架构&#xff0c;相比前代CMN-600在拓扑灵活性…...

基于CircuitPython与Adafruit IO的DIY智能门铃摄像头全栈开发指南

1. 项目概述与核心思路几年前&#xff0c;我还在用传统的猫眼和门铃&#xff0c;每次快递员敲门或者有访客&#xff0c;都得急匆匆跑到门口&#xff0c;从那个小小的、视野受限的孔洞里费力张望。后来市面上出现了各种智能门铃摄像头&#xff0c;功能是挺诱人&#xff0c;但要么…...