Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 477 Vote(s) - 3.54 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Generator cannot target libraries that have not been migrated to null-safety

#1
This problem occurs when trying the following command:

`flutter pub run build_runner build --delete-conflicting-outputs`

The error message:

[SEVERE] json_serializable:json_serializable on lib/models/shipping_address/shipping_address.dart:

Generator cannot target libraries that have not been migrated to null-safety.
package:deals_and_delivery/models/shipping_address/shipping_address.dart:6:7

6 │ class ShippingAddress {
│ ^^^^^^^^^^^^^^^

[INFO] Running build completed, took 3.6s

[INFO] Caching finalized dependency graph...
[INFO] Caching finalized dependency graph completed, took 49ms

[SEVERE] Failed after 3.7s
pub finished with exit code 1

pubspec.yaml:

dependencies:
json_annotation: ^4.0.0
flutter:
sdk: flutter
...
dev_dependencies:
build_runner: ^1.11.5
json_serializable: ^4.0.2
flutter_test:
sdk: flutter

These are the current flutter and dart versions:

[√] Flutter (Channel stable, 2.0.0, on Microsoft Windows [Version
> 10.0.19042.844], locale en-US)
> • Flutter version 2.0.0 at C:\flutter
> • Framework revision 60bd88df91 (22 hours ago), 2021-03-03 09:13:17 -0800
> • Engine revision 40441def69
> • Dart version 2.12.0


I am stuck at this point, how to solve this problem.
Reply

#2
I found out that `json_serializable >=4.0.0` depends on `json_annotation >=4.0.0 <4.1.0`
and the `json_annotation: ^4.0.0` includes `Null Safety` but `json_serializable: ^4.0.2` **does not**, so the error is occurring.

So I downgraded both packages:

json_annotation: 3.1.1

and

json_serializable: 3.5.1

And they work again properly.
Reply

#3
I think this all depends on if you are intending on upgrading your overall project to enable [null safety][1] or not. If you want to use the latest *json_serializable* packages (that have enabled null safety), you will need up specify it as such in your environment.

In your pubspec.yaml, if you enable null safety with the following:

environment:
sdk: ">=2.12.0 <3.0.0"

... then the latest *json_serializable* packages should work without issue.

Reference: [Behind the scenes: SDK constraints][2]

Chances are, your "sdk" environment is something less than 2.12.0 if they are giving you that error.

However, if you are not interested in updating for null safety, then you will likely need to keep your associated *json_serializable* packages downgraded as you mentioned.


[1]:

[To see links please register here]

[2]:

[To see links please register here]

Reply

#4
I got the same problem and solve it with below steps:

1. Set `sdk: '>=2.12.0 <3.0.0'`

2. Change version of `json_serializable` and `json_annotation` to `^4.0.0` *(not 4.1.0)*
Reply

#5
Try to set:

```
sdk: '>=2.12.0 <3.0.0'
```
it works for me when I use `json_serializable: ^4.0.1` and `json_anotation: ^4.0.1`
Reply

#6
Upgrade your pubspec file,

sdk: '>=2.12.0 <3.0.0'

json_annotation: ^4.0.1
json_serializable: ^4.1.0
build_runner: ^1.12.2

After upgrade the packages to run this command:

flutter pub run build_runner build --delete-conflicting-outputs
Reply

#7
In your `pubspec.yaml` file, the lower SDK version should be `>=2.12`.

```
environment:
sdk: '>=2.12.0 <3.0.0'
```

Use the following versions (all are null-safe)

```
json_annotation: ^4.0.1
json_serializable: ^4.1.2
build_runner: ^2.0.3
```

After that, run:

```
flutter pub get
flutter pub run build_runner build --delete-conflicting-outputs
```
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through