Error: Field 'wLanguage' cannot be nullable or have type 'Null', it must be `int`, `double`, `Pointer`, or a subtype of `Struct` or `Union`

huangapple go评论75阅读模式
英文:

Error: Field 'wLanguage' cannot be nullable or have type 'Null', it must be `int`, `double`, `Pointer`, or a subtype of `Struct` or `Union`

问题

当运行 flutter build appbundle 命令时,我遇到以下错误:

../../.pub-cache/hosted/pub.dev/package_info_plus_windows-2.1.0/lib/src/file_version_info.dart:13:17: 
错误:字段 'wLanguage' 不能是可空的或具有类型 'Null',它必须是 `int`、`double`、`Pointer` 或 `Struct` 或 `Union` 的子类型。
  external int? wLanguage;
                ^

../../.pub-cache/hosted/pub.dev/package_info_plus_windows-2.1.0/lib/src/file_version_info.dart:16:17: 
错误:字段 'wCodePage' 不能是可空的或具有类型 'Null',它必须是 `int`、`double`、`Pointer` 或 `Struct` 或 `Union` 的子类型。
  external int? wCodePage;
                ^
目标 kernel_snapshot 失败:异常

失败:构建失败并出现异常。

我正在使用 Flutter 3.10.0。在更新 Flutter 版本之前,项目运行正常。

英文:

When running the flutter build appbundle command, I get the following error :

../../.pub-cache/hosted/pub.dev/package_info_plus_windows-2.1.0/lib/src/file_version_info.dart:13:17: 
Error: Field 'wLanguage' cannot be nullable or have type 'Null', it must be `int`, `double`, `Pointer`, or a subtype of `Struct` or `Union`.
  external int? wLanguage;
                ^

../../.pub-cache/hosted/pub.dev/package_info_plus_windows-2.1.0/lib/src/file_version_info.dart:16:17: 
Error: Field 'wCodePage' cannot be nullable or have type 'Null', it must be `int`, `double`, `Pointer`, or a subtype of `Struct` or `Union`.
  external int? wCodePage;
                ^
Target kernel_snapshot failed: Exception

FAILURE: Build failed with an exception.

I am using Flutter 3.10.0. The project was running fine before I updated the flutter version.

答案1

得分: 16

I finally fix my problem by overriding these packages in my project's pubspec.yaml:

dependency_overrides:
  package_info_plus: ^4.0.1
  wakelock_windows: any
  win32: any

or

dependency_overrides:
  package_info_plus: any

Overriding the package_info_plus to ^4.0.1 gave me the following error message because of my project dependencies:

Because no versions of wakelock_windows match >0.2.1 <0.3.0 and wakelock_windows <0.2.1 depends on win32 ^2.0.0, wakelock_windows <0.2.1-∞ or >0.2.1 <0.3.0 requires win32 ^2.0.0. And because wakelock_windows 0.2.1 depends on win32 ^3.0.0, wakelock_windows <0.3.0 requires win32 ^2.0.0 or ^3.0.0. And because package_info_plus >=4.0.1 depends on win32 >=4.0.0 <6.0.0 and wakelock 0.6.2 depends on wakelock_windows ^0.2.0, package_info_plus >=4.0.1 is incompatible with wakelock 0.6.2. Because chewie >=1.3.5 depends on wakelock ^0.6.2 and no versions of wakelock match >0.6.2 <0.7.0, chewie >=1.3.5 requires wakelock 0.6.2. Thus, package_info_plus >=4.0.1 is incompatible with chewie >=1.3.5. So, because start depends on both chewie ^1.4.0 and package_info_plus ^4.0.1, version solving failed.

If you have a similar message after overriding the package_info_plus, you can check the dependent packages and add them to dependency_overrides and set the version to any as in my above example.

The Any keyword can be used to specify that any version of a package is acceptable. This can be useful if you want to make sure that your app is compatible with the latest version of a package, or if you want to avoid breaking changes that may be introduced in a future version of a package.

英文:

I finally fix my problem by overriding these packages in my project's pubspec.yaml

dependency_overrides:
  package_info_plus: ^4.0.1
  wakelock_windows: any
  win32: any

or

dependency_overrides:
  package_info_plus: any

Overriding the package_info_plus to ^4.0.1 gave me the following error message because of my project dependencies.

> Because no versions of wakelock_windows match >0.2.1 <0.3.0 and wakelock_windows <0.2.1 depends on win32 ^2.0.0, wakelock_windows <0.2.1-∞ or >0.2.1 <0.3.0 requires win32 ^2.0.0.
And because wakelock_windows 0.2.1 depends on win32 ^3.0.0, wakelock_windows <0.3.0 requires win32 ^2.0.0 or ^3.0.0.
And because package_info_plus >=4.0.1 depends on win32 >=4.0.0 <6.0.0 and wakelock 0.6.2 depends on wakelock_windows ^0.2.0, package_info_plus >=4.0.1 is incompatible with wakelock 0.6.2.
Because chewie >=1.3.5 depends on wakelock ^0.6.2 and no versions of wakelock match >0.6.2 <0.7.0, chewie >=1.3.5 requires wakelock 0.6.2.
Thus, package_info_plus >=4.0.1 is incompatible with chewie >=1.3.5.
So, because start depends on both chewie ^1.4.0 and package_info_plus ^4.0.1, version solving failed.

If you have a similar message after overriding the package_info_plus, you can check the dependent packages and add them to dependency_overrides and set the version to any as in my above example.


The Any keyword can be used to specify that any version of a package is acceptable. This can be useful if you want to make sure that your app is compatible with the latest version of a package, or if you want to avoid breaking changes that may be introduced in a future version of a package.

答案2

得分: 9

我遇到了同样的问题,我通过进入我的file_version_info文件并将它们设置为非空来解决了我的问题。

例如:从这个:

class _LANGANDCODEPAGE extends Struct {
  @Uint16()
  external int? wLanguage;

  @Uint16()
  external int? wCodePage;
}

改为这样:

class _LANGANDCODEPAGE extends Struct {
  @Uint16()
  external int wLanguage;

  @Uint16()
  external int wCodePage;
}

你可以在这个路径找到这个文件:

/Users/name/.pub-cache/hosted/pub.dev/package_info_plus_windows-2.1.0/lib/src/file_version_info.dart

希望对你有所帮助。

英文:

I had same issue and I solved mine by going into my
file_version_info file and made them not nullable.

Example: From this:

class _LANGANDCODEPAGE extends Struct {
  @Uint16()
  external int? wLanguage;

  @Uint16()
  external int? wCodePage;
}

to this:

class _LANGANDCODEPAGE extends Struct {
  @Uint16()
  external int wLanguage;

  @Uint16()
  external int wCodePage;
}

you can find this file in

/Users/name/.pub-cache/hosted/pub.dev/package_info_plus_windows-2.1.0/lib/src/file_version_info.dart

I hope this helps.

答案3

得分: 5

对我来说是Flutter的屏幕工具和谷歌字体。

我首先做的是输入

flutter pub upgradeflutter pub upgrade --major-versions

然后我将android文件夹中的ext.kotlin更改为最新版本,然后在build.gradle中更改为

ext.kotlin = '1.6.20' 改为 ext.kotlin_version = '1.8.21'

然后我就能运行我的项目了,希望这能帮到你。

英文:

For me was flutter screen utils and google font

i did first is type

flutter pub upgrade or flutter pub upgrade --major-versions

then i change my ext.kotlin to latest in android folder then build gradle to

ext.kotlin = &#39;1.6.20' to ext.kotlin_version = &#39;1.8.21&#39;

then i able to run my project i hope this helps.

答案4

得分: 2

我阅读日志后遇到了相同的问题,我在pub spec文件中添加了这一部分:

dependency_overrides:
    package_info_plus: any

我还需要将firebase/auth包更新到版本10.9,我运行了以下命令:

pod update Firebase/Auth

英文:

I faced the same issue but after reading carefully the logs, I added this part in pub spec file

dependency_overrides:
    package_info_plus: any

I needed also to update the firebase/auth packages to 10.9. I run this command -->
pod update Firebase/Auth

答案5

得分: 2

为了解决这个问题,您需要打开以下路径中的file_version_info.dart文件:

../../.pub-cache/hosted/pub.dev/package_info_plus_windows 2.1.0/lib/src/file_version_info.dart

然后搜索int? wCodePage;int? wLanguage;,然后移除?

英文:

In order to fix this issue you will open file_version_info.dart
from your path

../../.pub-cache/hosted/pub.dev/package_info_plus_windows 2.1.0/lib/src/file_version_info.dart

and search about int? wCodePage; and int? wLanguage; then remove ?.

答案6

得分: 1

你可以通过覆盖依赖项来简单修复此问题,请将以下代码放入您的 pubspec.yaml 文件中,这将解决您的问题:

dependency_overrides:
 package_info_plus_windows: 3.0.0
英文:

you can simply fix this problem by overriding the dependency, put the following code in your pubspec.yaml and that would fix your problem:

dependency_overrides:
 package_info_plus_windows: 3.0.0

答案7

得分: 1

将以下内容添加到pubspec.yaml文件中应该解决这个问题:

dependency_overrides:
 package_info_plus: ^4.0.1
英文:

Adding this to pubspec.yaml should resolve the issue

dependency_overrides:
 package_info_plus: ^4.0.1

答案8

得分: 1

我在升级Flutter后遇到了这个错误,只需运行 "dart pub upgrade" 即可。

英文:

i had this error after upgrading flutter,
just run "dart pub upgrade"

答案9

得分: 1

我已经在这个错误上工作了两天:我的解决方案(但不是最佳解决方案)是更新 'file_version_info.dart' 文件如下:

class _LANGANDCODEPAGE extends Struct {
  @Uint16()
  external int wLanguage;

  @Uint16()
  external int wCodePage;
}

并删除 int?

它起作用了。

英文:

I've worked on this error for 2 days: my solution (but is not the best solution) is to update the 'file_version_info.dart' with:

class _LANGANDCODEPAGE extends Struct {
  @Uint16()
  external int wLanguage;

  @Uint16()
  external int wCodePage;
}

and remove the int?

It works.

答案10

得分: 1

This worked for me:

flutter pub remove package_info_plus
flutter pub add package_info_plus

This deletes the outdated packages:

These packages are no longer being depended on:
- package_info_plus 1.4.3+1
- package_info_plus_linux 1.0.5
- package_info_plus_macos 1.3.0
- package_info_plus_platform_interface 1.0.2
- package_info_plus_web 1.0.6
- package_info_plus_windows 2.1.0
Changed 6 dependencies!

Then it adds the new packages back in - without adding the outdated ones:

+ package_info_plus 4.1.0
+ package_info_plus_platform_interface 2.0.1
&gt; win32 5.0.6 (was 3.1.4)

I think what really happened here is that the package changed and didn't need these additional platform specific files anymore, but the package manager can't quite handle this change and doesn't remove the stale packages.

The stale package package_info_plus_windows then causes the error.

When we remove the package, it removes all dependencies correctly.

When we then add the package back in, it adds the new dependencies correctly.

Problem solved.

英文:

This worked for me:

flutter pub remove package_info_plus
flutter pub add package_info_plus

This deletes the outdated packages:

These packages are no longer being depended on:
- package_info_plus 1.4.3+1
- package_info_plus_linux 1.0.5
- package_info_plus_macos 1.3.0
- package_info_plus_platform_interface 1.0.2
- package_info_plus_web 1.0.6
- package_info_plus_windows 2.1.0
Changed 6 dependencies!

Then it adds the new packages back in - without adding the outdated ones

+ package_info_plus 4.1.0
+ package_info_plus_platform_interface 2.0.1
&gt; win32 5.0.6 (was 3.1.4)

I think what really happened here is that the package changed and didn't need these additional platform specific files anymore, but the package manager can't quite handle this change and doesn't remove the stale packages.

The stale package package_info_plus_windows then causes the error.

When we remove the package, it removes all dependencies correctly.

When we then add the package back in, it adds the new dependencies correctly.

Problem solved.

答案11

得分: 0

我遇到了相同的问题。

在我的情况下,与 flutter_app_version_checker 相关。
版本 0.3.2 有依赖于旧的 package_info_plus_x 包。

已经有人为 flutter_app_version_checker 提交了修复,但该包尚未发布。

所以我 fork 了仓库并在我的项目中应用了修复。

  # 从
dependencies:
  http: ^0.13.4
  package_info_plus: ^1.4.2

dev_dependencies:
  flutter_lints: ^1.0.0

  # 到
dependencies:
  http: ^0.13.6
  package_info_plus: ^4.0.0

dev_dependencies:
  flutter_lints: ^2.0.1

pubspec.yaml

....
 flutter_app_version_checker:
    git:
      url: git@github.com:kevin-chnp/app_version_checker.git
...
(您可以使用自己的存储库)
英文:

I have same problem.

In my case related to flutter_app_version_checker.
version 0.3.2 has dependency to old package_info_plus_x packages.

Somebody already PR the fix for flutter_app_version_checker, but package does not releases..

So I fork the repo and apply fix for my project.

  # from
dependencies:
  http: ^0.13.4
  package_info_plus: ^1.4.2

dev_dependencies:
  flutter_lints: ^1.0.0

  # to
dependencies:
  http: ^0.13.6
  package_info_plus: ^4.0.0

dev_dependencies:
  flutter_lints: ^2.0.1

pubspec.yaml

....
 flutter_app_version_checker:
    git:
      url: git@github.com:kevin-chnp/app_version_checker.git
...
(you can use your own repo)

huangapple
  • 本文由 发表于 2023年5月17日 16:05:03
  • 转载请务必保留本文链接:https://go.coder-hub.com/76269825.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定