kotlin-null-safety 相关问题


修复 Flutter GitHub 项目导入错误:Dart SDK 版本和空安全兼容性

从github导入flutter中的任何项目时,它显示“sdk:'> = 2.7.0的下限<3.0.0'" must be 2.12.0' or higher to enable null safety. The current Dart SDK (3.2.3)...


Kotlin 是否有可空值的映射函数

我想映射一个可为空的值,如果存在则在该值内应用一个函数,如果不存在则返回null。


Spring Boot启动错误无法调用“org.apache.commons.logging.Log.isDebugEnabled()”,因为“this.logger”为null

我正在为 kotlin 使用 spring-boot:3.2.1。但是当我使用它的时候,突然应用程序启动出错了。算我一个 类似问题1 类似问题2 但他们的问题虽然堆栈看起来是一样的。但是...


检查变量是否为空

if ($user_id == NULL || $user_name == NULL || $user_logged == NULL) { $user_id = '-1'; $用户名 = NULL; $user_logged = NULL; } 如果($user_admin == NULL){ $user_admin = NULL; } 是...


Kotlin 1.4 中 sumOf() 和 sumBy() 有什么区别?

Kotlin 1.4 中新的 sumOf() 函数与 sumBy() 或 sumByDouble() 函数有何不同?


如何将 testOptions.unitTests.all 转换为 gradle Kotlin dsl

如何在 Gradle 中将这段代码从 Groovy 转换为 Kotlin DSL? testOptions.unitTests.all { 测试记录{ 异常格式=“完整” 事件“通过”,&...


Kotlin maven 插件忽略 jvmTarget

Spring Boot:3.2.0,Kotlin:1.9.21,构建映像:maven:3.9.5-amazoncorretto-21,运行映像:amazoncorretto:17 我有一个非常简单的 Spring Boot 项目 @SpringBootApplication 类演示应用程序 有趣


将 Kotlin 版本从 1.7.10 更新到 1.9.10 时,多个测试用例失败

问题描述 Kotlin 版本从 1.7.10 更新到 1.9.10 后,多次测试均失败,主要问题是错误消息: kotlinx.coroutines.test.


在 WSL2 中使用 Gradle 对 Kotlin Spring Boot 应用程序进行 Docker 化是行不通的

我正在使用 WSL 2,想要使用 gradle (kotlin) 对 spring boot kotlin 应用程序进行 dockerize,并使其全部在 Docker 中运行,这样我就不必在本地安装任何内容。但每次我运行 docker-compose


Kotlin 继承 - 没有为参数上下文传递值

我正在尝试使用 kotlin for android 构建一个 AccountAuthenticator 类。但是当尝试实现 AbstractAccountAuthenticator 类时,我在编译时遇到以下异常: 没有价值...


Kotlin - IntelliJ 项目设置

我想使用 IntelliJ IDE 为 JVM 启动一个新的 Kotlin 项目,但我无法获得让它工作的配置。我试图按照本教程进行操作,但之后不起作用(...


Android Kotlin Flow 数据未从 StateFlow 和 SharedFlow 收集

在调查 Android 中的 Kotlin Flow 期间,我试图理解并(也许)将 LiveData 替换为 Flow。但我不明白如何在 StateFlow 和 Share 中收集和发送数据...


在 SQL Developer 上运行创建表学生时出错:CREATE TABLE Students

创建表学生( 年号(4) NOT NULL, 学期 VARCHAR2(1) NOT NULL CONSTRAINT Stu_sem_ck CHECK (学期 IN ('1', '2', '3')), 部门 VARCHAR2(3) NOT NULL, 课程编号...


Gradle 构建时的 Kotlin 警告

自从我开始将项目从 java 转换为 kotlin 以来,我一直在 Mac 上遇到构建性能问题。 我将 gradle 与 Android Studio 3.0.1 一起使用 问题是当我构建/运行/


如何在 kotlin 中比较 LocalDateTime 实例

所以我在 kotlin LocalDateTime 方面遇到了一些问题 现在的值 = 当前日期时间 val someDate = someService.someLocalDateTime 如你所见,我有两个日期,我想知道现在是否更大......


使用 Kotlin 公开的 SQL DSL 选择多个值并按 ORDER BY

我正在尝试使用 Kotlin SQL Exposed 框架进行下一个查询。 选择 interation_id、group_id、max(版本) 来自互动 按组 ID 分组; 我有一个交互表,每个


无法在 Kotlin Multiplatform 中导入 os.log

我正在尝试实现 kotlin 多平台记录器。在iOS架构的实现过程中,我无法导入os.log来使用os_log。我该怎么做或者我还可以使用什么来登录 iOS


如何反编译kotlin android apk?

我有自己用 kotlin 开发的 Android 应用程序。在我使用下面的 adb 命令从物理 Android 设备中提取我的 apk 后,我丢失了所有源代码(硬盘崩溃) - c:\> adb shell pm...


使用 Karate Runner 和 Gradle Kotlin 调试空手道

由于 Gradle 默认其构建文件使用 Kotlin,而且我从来都不是 Groovy 的粉丝,因此尝试使用开源 Karate Runner (v1.2.5) 进行调试。我已经尝试了几个版本...


Kotlin/Spring Boot 应用程序无法使用 Docker 在 Maven 中构建

我正在尝试为 Kotlin/Spring Boot 应用程序构建一个映像。但是当我运行 docker build 时出现以下错误: [错误] 无法执行目标 org.jetbrains.kotlin:kotlin-maven-plugin:1.7.20:


使用结构复制构造进行聚合初始化

有没有办法在 C++ 中模仿 Kotlin 的数据类“copy()”? 这允许在单个表达式中复制对象并修改其特定部分,请参阅 Kotlin 示例: 数据类 SomeData(...


如何在 Kotlin 中生成 MD5 哈希? [已关闭]

使用 Kotlin 中的标准库生成字符串的 MD5 哈希值? 我已经尝试过下面提到的代码 导入 java.math.BigInteger 导入 java.security.MessageDigest 有趣的md5(输入:字符串):字符串{ 维...


com.auth.java-jwt - 使用 java 主对象内的 kotlin 对象反序列化声明

我有一个声明对象,它是一个java对象(JsonUserTokenClaims就是例子),它内部是一个kotlin对象。我正在尝试像这样反序列化对象: Claims.get("用户").as(


在 Android Studio Kotlin 中读取 Excel xlsx 文件数据

我是编程新手,需要帮助。 我正在尝试在我的 Android studio Kotlin 项目中读取 Excel 文件的内容。我打算用这些数据来备份数据库,但现在,我只是......


也许很简单,但下一步是什么?

学习语言基础知识(Kotlin)之后 成为Android开发者后应该学习什么? 我非常了解 Kotlin 基础知识,但是当我观看有关制作应用程序的视频时,我......


使用 kotlin/compose 与 java/xml 指南相比

我猜我应该说我对 kotlin 的 compose 很陌生,我只用过 java/xml 的项目,我在这里很困惑。 使用java,我们为每个屏幕提供具有自己的逻辑/设计的片段。这里...


导出到 .framework 的 Kotlin 多平台库在 Xcode 上崩溃

我正在尝试使用 Kotlin Multiplatform 实现一个库以在我的 iOS 项目中使用,因此我下载了官方库模板,它实现了斐波那契数列。 我只做了 2 处更改


可能会抛出“NullPointerException”; “getBody()”可以返回 null

ResponseEntity commonResponseDto = testClient.getCategoryById(sampleEntity.getCategoryId()); if(Objects.nonNull(commonResponseDto) && Objects.nonNull(


在 SQL Server 中比较 NULL 与 NULL

我有一些代码,其中 WHERE 子句中使用的变量可以为空。因此,我必须使用 IF ELSE 查询数据来检查 NULL。有没有办法在一个查询中写入? 声明@


SecurityException:不允许启动服务Intent { act=com.google.android.c2dm.intent.REGISTER pkg=com.google.android.gms (有额外功能)}

我尝试从 Google 获取我的 GCM 注册 ID。 我的代码: 字符串SENDER_ID =“722*****53”; /** * 向 GCM 服务器异步注册应用程序。 * * 存储注册信息... 我尝试从 Google 获取我的 GCM 注册 ID。 我的代码: String SENDER_ID = "722******53"; /** * Registers the application with GCM servers asynchronously. * <p> * Stores the registration ID and the app versionCode in the application's * shared preferences. */ private void registerInBackground() { new AsyncTask<Void, Void, String>() { @Override protected String doInBackground(Void... params) { String msg = ""; try { if (gcm == null) { gcm = GoogleCloudMessaging.getInstance(context); } regid = gcm.register(SENDER_ID); msg = "Device registered, registration ID=" + regid; // You should send the registration ID to your server over // HTTP, so it // can use GCM/HTTP or CCS to send messages to your app. sendRegistrationIdToBackend(); // For this demo: we don't need to send it because the // device will send // upstream messages to a server that echo back the message // using the // 'from' address in the message. // Persist the regID - no need to register again. storeRegistrationId(context, regid); } catch (IOException ex) { msg = "Error :" + ex.getMessage(); // If there is an error, don't just keep trying to register. // Require the user to click a button again, or perform // exponential back-off. } return msg; } @Override protected void onPostExecute(String msg) { mDisplay.append(msg + "\n"); } }.execute(null, null, null); } 我收到错误: 03-01 19:15:36.261: E/AndroidRuntime(3467): FATAL EXCEPTION: AsyncTask #1 03-01 19:15:36.261: E/AndroidRuntime(3467): java.lang.RuntimeException: An error occured while executing doInBackground() 03-01 19:15:36.261: E/AndroidRuntime(3467): at android.os.AsyncTask$3.done(AsyncTask.java:299) 03-01 19:15:36.261: E/AndroidRuntime(3467): at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:352) 03-01 19:15:36.261: E/AndroidRuntime(3467): at java.util.concurrent.FutureTask.setException(FutureTask.java:219) 03-01 19:15:36.261: E/AndroidRuntime(3467): at java.util.concurrent.FutureTask.run(FutureTask.java:239) 03-01 19:15:36.261: E/AndroidRuntime(3467): at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230) 03-01 19:15:36.261: E/AndroidRuntime(3467): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080) 03-01 19:15:36.261: E/AndroidRuntime(3467): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573) 03-01 19:15:36.261: E/AndroidRuntime(3467): at java.lang.Thread.run(Thread.java:841) 03-01 19:15:36.261: E/AndroidRuntime(3467): Caused by: java.lang.SecurityException: Not allowed to start service Intent { act=com.google.android.c2dm.intent.REGISTER pkg=com.google.android.gms (has extras) } without permission com.google.android.c2dm.permission.RECEIVE 03-01 19:15:36.261: E/AndroidRuntime(3467): at android.app.ContextImpl.startServiceAsUser(ContextImpl.java:1800) 03-01 19:15:36.261: E/AndroidRuntime(3467): at android.app.ContextImpl.startService(ContextImpl.java:1772) 03-01 19:15:36.261: E/AndroidRuntime(3467): at android.content.ContextWrapper.startService(ContextWrapper.java:480) 03-01 19:15:36.261: E/AndroidRuntime(3467): at com.google.android.gms.gcm.GoogleCloudMessaging.b(Unknown Source) 03-01 19:15:36.261: E/AndroidRuntime(3467): at com.google.android.gms.gcm.GoogleCloudMessaging.register(Unknown Source) 03-01 19:15:36.261: E/AndroidRuntime(3467): at com.example.gcm.DemoActivity$1.doInBackground(DemoActivity.java:177) 03-01 19:15:36.261: E/AndroidRuntime(3467): at com.example.gcm.DemoActivity$1.doInBackground(DemoActivity.java:1) 03-01 19:15:36.261: E/AndroidRuntime(3467): at android.os.AsyncTask$2.call(AsyncTask.java:287) 03-01 19:15:36.261: E/AndroidRuntime(3467): at java.util.concurrent.FutureTask.run(FutureTask.java:234) 03-01 19:15:36.261: E/AndroidRuntime(3467): ... 4 more 这是我的清单: <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.manyexampleapp" android:installLocation="preferExternal" android:versionCode="1" android:versionName="1.0" > <uses-sdk android:minSdkVersion="11" android:targetSdkVersion="18" /> <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <uses-permission android:name="android.permission.GET_ACCOUNTS" /> <uses-permission android:name="android.permission.WAKE_LOCK" /> <uses-permission android:name="com.example.manyexampleapp.c2dm.permission.RECEIVE" /> <uses-permission android:name="com.example.manyexampleapp.gcm.permission.C2D_MESSAGE" /> <permission android:name="com.example.manyexampleapp.gcm.permission.C2D_MESSAGE" android:protectionLevel="signature" /> <application android:name="com.zoomer.ifs.BaseApplication" android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" /> <activity android:name="com.zoomer.ifs.MainActivity" android:label="@string/app_name" android:configChanges="orientation|keyboardHidden|screenSize" android:launchMode="singleTop"> <!-- <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> --> </activity> <!-- PUSH --> <!-- WakefulBroadcastReceiver that will receive intents from GCM services and hand them to the custom IntentService. The com.google.android.c2dm.permission.SEND permission is necessary so only GCM services can send data messages for the app. --> <receiver android:name="com.example.gcm.GcmBroadcastReceiver" android:permission="com.google.android.c2dm.permission.SEND" > <intent-filter> <!-- Receives the actual messages. --> <action android:name="com.google.android.c2dm.intent.RECEIVE" /> <category android:name="com.example.manyexampleapp" /> </intent-filter> </receiver> <service android:name="com.example.gcm.GcmIntentService" /> <activity android:name="com.example.gcm.DemoActivity"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <!-- DB --> <activity android:name="com.example.db.DbActivity" android:label="@string/app_name" > <intent-filter> </intent-filter> </activity> <activity android:name="com.example.http.RestGetActivity" android:label="@string/app_name" android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen" > </activity> <activity android:name="com.example.fb.FacebookLoginActivity" android:label="@string/app_name" > <!-- <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> --> </activity> <activity android:name="com.example.http.SendFeedbackActivity" android:label="@string/app_name" > <!-- <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> --> </activity> <activity android:name="com.zoomer.general.SearchNearbyOffersActivity" android:label="@string/app_name" > <intent-filter> </intent-filter> </activity> <activity android:name="com.facebook.LoginActivity" android:label="@string/app_name" > <intent-filter> </intent-filter> </activity> <activity android:name="com.example.manyexampleapp.StoresListActivity" > <intent-filter> </intent-filter> </activity> <activity android:name="com.example.fb.ShareActivity" > <intent-filter> </intent-filter> </activity> <activity android:name="com.example.notifications.NotificationsActivity" > <intent-filter> </intent-filter> </activity> <activity android:name="com.example.fb2.no_use.MainActivity" > <intent-filter> </intent-filter> </activity> <activity android:name="com.zoomer.offers.OffersListActivity" > <!-- <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> --> </activity> <activity android:name="com.example.http.SearchNearbyOffersActivity" > <!-- <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> --> </activity> <service android:name="com.example.geo.LocationService" android:enabled="true" /> <receiver android:name="com.example.manyexampleapp.BootReceiver" > <intent-filter> <action android:name="android.intent.action.BOOT_COMPLETED" /> <action android:name="com.example.manyexampleapp.LocationService.LOCATION_BROAD_MSG" /> </intent-filter> </receiver> <meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/app_id" /> </application> </manifest> 改变 <uses-permission android:name="com.example.manyexampleapp.c2dm.permission.RECEIVE" /> 到 <!-- This app has permission to register and receive data message. --> <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" /> 您收到异常是因为您尚未定义所需的权限 如果应用程序开发后安装了播放服务, 可能会发生 com.google.android.c2dm.permission.RECEIVE 权限已被授予但 android 仍在抱怨同样的错误。 在这种情况下,您必须完全重新安装开发的应用程序才能使此权限发挥作用。 我认为你必须检查 Kotlin 版本兼容性。


如何在 Kotlin 的主 Activity 中启用/禁用片段按钮

与此类似的问题有几个答案,但在 Kotlin 中没有。 我有一个带有一个按钮和两个片段的主要活动。在第一个片段中有一个导航按钮,可以启动...


SQL - 删除除一组最大值之外的所有记录

请帮忙SQL查询。我有一张桌子: 创建表 tblTest ( Id INT 主键不为空, 重量 INT NULL, 批处理 INT NULL, t_stamp 日期时间 null ); 让我们假设它充满了值: ...


when Kotlin when-语句中的关键字“is”

在我读到的代码中 当(传感器状态){ SensorState.Available -> TODO("初始化测量") 是 SensorState.Measuring -> { 传感器.measure() } 是 SensorState.Paused -&...


MySQL:存储罕见的长字符串

有一个MySQL表: 创建表`变量` ( `名称` VARCHAR(50) NOT NULL, `值` VARCHAR(250) NOT NULL, 主键(`名称`) ) 引擎=InnoDB 字符集=utf8mb4; 只有一...


SonarQube 警告:可能会抛出“NullPointerException”; “getBody()”可以返回 null

ResponseEntity commonResponseDto = testClient.getCategoryById(sampleEntity.getCategoryId()); if(Objects.nonNull(commonResponseDto) && Objects.nonNull(


从 Silverstripe BulkManager 添加和删除操作

向 modelAdmin 添加批量管理器,如下所示: 使用Colymba\BulkManager; FAQAdmin 类扩展了 ModelAdmin { 公共函数 getEditForm($id = null, $fields = null) { $form = 父级::getEd...


在 .NET 8 上的主构造函数 EF Core 中调用时,DbContext 为 Null

我使用的是.NET 8,在主构造函数中调用时,我的 DbContext 为 null,但在普通构造函数中调用时,我的 DbContext 为 null。 这是我的 DbContext: 公共类 DataContext(DbContextOptions 优化...


未定义的变量:Laravel 8 上的 __env

这是我的代码: @foreach($comments->where("id_answered_comment", null) as $comment) @php


“struct Obj* obj”和“Obj* obj”之间的区别[重复]

结构元素{ 元素() {} int 数据 = NULL; 结构元素*右,*左; }; 或者 结构体元素{ 元素() {} int 数据 = NULL; 元素*右,*左; }; 我正在与


如何高效且线程安全地实现单例? [重复]

单例类的通常模式是这样的 静态 Foo &getInst() { 静态 Foo *inst = NULL; if(inst == NULL) inst = new Foo(...); 返回*安装; } 然而,这是我的


Spring security 6.2 JSESSIONID 未返回

我正在使用 Kotlin 创建一个 Spring Boot 应用程序。我已经将 WebSecurity 配置为: @配置 类安全配置{ @Autowired Lateinit var dataSource: 数据源 @值(...


如何在 Gradle 脚本中传递默认 JVM 参数,同时允许扩展变量?

我的 build.gradle.kts 文件中有以下内容: 插件{ kotlin(“jvm”) 版本“1.9.20” 应用 } 应用 { mainClass.set("MainKt")


Kotlin - 主要和次要构造函数

class SmartDevice(val 名称: String, val 类别: String) { var deviceStatus = "在线" 构造函数(名称:字符串,类别:字符串,状态代码:Int):this(名称,类别){ ...


如何在 kotlin 中模拟接受回调的函数

假设我有以下两个课程: 类 Foo { 有趣 执行(回调:()-> RES):RES { 返回回调.invoke() } } 类酒吧( 私人 val foo: Foo, ){...


Android Compose 基础知识 - 项目:创建名片应用程序

在此处输入图像描述当前正在完成此练习 https://developer.android.com/codelabs/basic-android-kotlin-compose-business-card?continue=https%3A%2F%2Fdeveloper.android.com%2Fcourses%


未解决的参考:lifecycle_version [developer.android.com/codelabs]

代码在这里: 起始代码网址: https://github.com/google-developer-training/basic-android-kotlin-compose-training-dessert-clicker 带有起始代码的分支名称:main Codelab 中的说明:


如何使用闭包表遍历树结构以便在 Eloquent 模型中创建 json?

在我的应用程序中,我有下表: 创建表文件( id bigint IDENTITY(1,1) NOT NULL, 名称 nvarchar(255) 整理 SQL_Latin1_General_CP1_CI_AS NOT NULL, 文件夹 bigint NUL...


graphql-spqr 在响应 json 中发送空值

我们已将 Spring Boot 应用程序配置为不以 json 形式发送回 null 值,但我们仍然会返回 null 值。使用 Jackson ObjectMapper 不发送空值的设置位于


点击邮递员的请求时在 POSTMapping 中获取 null

我是 spring 新手,在创建一个 POSTMapping 到 addUser 时,我在邮递员上收到 406 错误,在控制器类中收到 null 。 包 com.codedecode.userinfo.DTO; 导入龙目岛。*; @数据 @


无法下载eclipse插件

我正在尝试下载 eclipse 的 kotlin 插件。我能够连接到 eclipse 市场,但是当我尝试下载它时,出现错误: 无法读取存储库 https://dl.bintray.com/


最新问题
© www.soinside.com 2019 - 2024. All rights reserved.