Category Archives: How to Fix

[Solved] Error while trying to use the following icon from the Manifest

Error while trying to use the following icon from the manifest: http://localhost:8080/img/icons/android -chrome-192×192.png (Download error or resource isn’t a valid image)

The main reason for this error is that the android-chrome-192×192.png image in the icons folder under img under public is deleted by mistake
my solution: re create the same folder and file (if you find a picture, you won’t report an error!)

Unable to read workspace file ‘D:\angular.json‘: Invalid JSON character: “ “ at

Question:

Unable to read workspace file 'D:\font-end\antd\angular.json': Invalid JSON character: " " at 36:71.`Insert code snippet here`

Step 1: introduce the notes of the angular ecarts.min.js
you have a problem with the angular ecarts.min.js, but if the notes are started, the following error will be reported:

Error: The target entry-point "ngx-echarts" has missing 

Inconsistency between adapter data and UI data after dragging recyclerview (data disorder)

Firstly, the function of dragging and sliding is added on the basis of recyclerview. It is written directly according to the official document as follows

 ItemTouchHelper(object : ItemTouchHelper.Callback() {
            override fun getMovementFlags(
                recyclerView: RecyclerView,
                viewHolder: RecyclerView.ViewHolder,
            ): Int {
                //item dragging direction
                var dragflag =
                    ItemTouchHelper.UP or ItemTouchHelper.DOWN or ItemTouchHelper.LEFT or ItemTouchHelper.RIGHT
                return makeMovementFlags(dragflag, 0)
            }

            override fun onMove(
                recyclerView: RecyclerView,
                viewHolder: RecyclerView.ViewHolder,
                target: RecyclerView.ViewHolder,
            ): Boolean {
                myAdapter.notifyItemMoved(viewHolder.layoutPosition, target.layoutPosition)
                return true
            }


            override fun onSwiped(viewHolder: RecyclerView.ViewHolder, direction: Int) {}

            override fun canDropOver(
                recyclerView: RecyclerView,
                current: RecyclerView.ViewHolder,
                target: RecyclerView.ViewHolder,
            ): Boolean {
                //The current ViewHolder can be placed on the target ViewHolder
                return true
            }

            override fun isLongPressDragEnabled(): Boolean {
                //Turn on long press drag
                return true
            }

        }).attachToRecyclerView(binding.myRV)//add to RecyclerView

After running, it is found that the UI is normal, but when obtaining adapter.items, it is found that the data has not changed, so perform data exchange and sorting in onmove:

ItemTouchHelper(object : ItemTouchHelper.Callback() {
            override fun getMovementFlags(
                recyclerView: RecyclerView,
                viewHolder: RecyclerView.ViewHolder,
            ): Int {
                var dragflag =
                    ItemTouchHelper.UP or ItemTouchHelper.DOWN or ItemTouchHelper.LEFT or ItemTouchHelper.RIGHT
                return makeMovementFlags(dragflag, 0)
            }

            override fun onMove(
                recyclerView: RecyclerView,
                viewHolder: RecyclerView.ViewHolder,
                target: RecyclerView.ViewHolder,
            ): Boolean {
                if (viewHolder.layoutPosition < target.layoutPosition) {
                    for (i in viewHolder.layoutPosition until target.layoutPosition) {
                        Collections.swap(myAdapter.items, i, i + 1) 
                    }
                } else {
                    for (i in viewHolder.layoutPosition downTo target.layoutPosition + 1) {
                        Collections.swap(myAdapter.items, i, i - 1) 
                    }

                }
                myAdapter.notifyItemMoved(viewHolder.layoutPosition, target.layoutPosition)
                myAdapter.notifyItemChanged(target.layoutPosition)
                return true
            }


            override fun onSwiped(viewHolder: RecyclerView.ViewHolder, direction: Int) {}

            override fun canDropOver(
                recyclerView: RecyclerView,
                current: RecyclerView.ViewHolder,
                target: RecyclerView.ViewHolder,
            ): Boolean {
                return true
            }

            override fun isLongPressDragEnabled(): Boolean {
                return true
            }

        }).attachToRecyclerView(binding.myRV)

If you want to listen to the end of drag, you can override the Clearview method to listen

Unrecognized option: –add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED

Upgrade to IntelliJ idea 2021.2 and start the project with an error

Unrecognized option: –add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED

Solution: delete the. Idea folder and re import the project.

Recommended solution:

Change the red box to your JDK version. Mine is 1.8, so check 8. If this problem cannot be solved, use the above solution again.

 

Redis reports an error when integrating springsecurity: could not read JSON: unrecognized field “enabled”“

When springboot integrates springsecurity, an error occurs:

  By viewing the error reporting information, it is found that the errors are reported where redis is used. In the project, redis is used as a cache to store user information. Everything is normal when spring security is not integrated, but there is a problem after the integration. I checked several blogs on the Internet and found that there is a problem when redis serializes and stores user objects.

Key error messages:

Could not read JSON: Unrecognized field "enabled" (class com.xyc.community.entity.User), not marked as ignorable (11 known properties: "authorities", "status", "activationCode", "username", "createTime", "type", "id", "email", "headerUrl", "salt", "password"])
 at [Source: (byte[])"{"@class":"com.xyc.community.entity.User","id":134,"username":"www","password":"3d3aeebb9cd302ae581dfa8fedd86ceb","salt":"dfc00","email":"[email protected]","type":0,"status":1,"activationCode":null,"headerUrl":"http://images.nowcoder.com/head/134t.png","createTime":["java.util.Date",1555668837000],"enabled":true,"accountNonExpired":true,"accountNonLocked":true,"credentialsNonExpired":true}"; line: 1, column: 318] (through reference chain: com.xyc.community.entity.User["enabled"]); nested exception is com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "enabled" (class com.xyc.community.entity.User), not marked as ignorable (11 known properties: "authorities", "status", "activationCode", "username", "createTime", "type", "id", "email", "headerUrl", "salt", "password"])
 at [Source: (byte[])"{"@class":"com.xyc.community.entity.User","id":134,"username":"www","password":"3d3aeebb9cd302ae581dfa8fedd86ceb","salt":"dfc00","email":"[email protected]","type":0,"status":1,"activationCode":null,"headerUrl":"http://images.nowcoder.com/head/134t.png","createTime":["java.util.Date",1555668837000],"enabled":true,"accountNonExpired":true,"accountNonLocked":true,"credentialsNonExpired":true}"; line: 1, column: 318] (through reference chain: com.xyc.community.entity.User["enabled"])

You can see that several fields are added during serialization because the userdetails interface is implemented in the user class in order to integrate springsecurity. These methods have been rewritten

  terms of settlement:

Using the @ jsonignoreproperties annotation, you can ignore these fields when the user object is serialized

Add before user class:

@JsonIgnoreProperties({"enabled","accountNonExpired", "accountNonLocked", "credentialsNonExpired", "authorities"})

Cocos creator 2.4.5 2D RPG (Infinite scrolling background implementation)

main points:

By default, the scene comes with a camera to render all objects in the scene. The camera node can be regarded as an empty node, and a camera component is attached under it, so it is invisible. Each scene can have multiple cameras. The rendering levels of multiple cameras are grouped and rendered by associating group names. The rendering levels of multiple cameras comply with the node tree rules. First, the priority is divided according to the level of the camera node, and the lower camera, Its associated group is rendered later; For nodes under the same camera group, the lower the node, the later the rendering. The more you render, the closer the node looks to the top.

case

Camera practice: implementation of infinite parallax rolling map

1、 Camera group rendering

In the menu of Cocos creator, ` item ‘- & gt` Project settings ` – & gt` Changing or adding a group in group management is the same setting as the group management of physical collision.

Add multiple cameras in the scene, then add multiple groups in group management, and then set the settings of the camera   cullingMask   Attribute is the corresponding group. Each camera rendered object is filtered through this cullingmask.

The steps are as follows:

1. Create a camera node. Create an empty node in the hierarchy manager and add a camera component on this node, so that a camera node can be created. According to this method, two camera nodes, farcamera and nearcamera, are added to render the foreground and close-up respectively.

Empty node

Add camera

2. Group management. Add two groups in group management, nearbg and farbg.

Add group

3. Add close view and long view nodes and set group names respectively

prospect

Close range

4. Set the cullmask property of camera, farcamera to farbg and nearcamera to nearbg.

Perspective camera

Close range camera

Here, the multi camera and group rendering settings are completed, and the interface can be seen by running the simulator.

Operation results

2、 Parallax principle

There are two ways of parallax background. The traditional way is to keep the observation point unchanged, move the close view and long-range map, control the speed of close view and long-range map to produce parallax, and form an infinite rolling parallax background.

But what we are talking about here is the opposite process. The background picture is fixed and the observation point (camera) is moved. Due to the relativity of motion, the background picture moves in the opposite direction.

Principle I

As shown in the figure, if the camera keeps moving, it will soon exceed the visual boundary of farbg1. Therefore, two background images should be made. When moving to the boundary of farbg1, put another same background next to the boundary of farbg1. In this way, continuously set the position of farbg alternately, and you can scroll infinitely.

Principle I

The same principle sets the close range. The moving speed of the background is equal to the moving speed of the camera, and the direction is opposite. If the moving speed of the two cameras is different, an infinite rolling parallax background is formed.

3、 Jingjing

Some elements do not move. We call them static scenes, such as the sun and the moon. How to achieve them?

It’s actually very simple. Just use a camera to render them without moving the camera.

Implementation method: add a group celestial, turn on maincamera, set cullingmask to celestial, add a sun node, and set the group to celestial.

Also, when you play the characters, you need to set up a camera to render. This will make some special effects of lens, such as camera following, lens zoom, etc. This will be explained in detail in other articles. Please pay attention to the official account.

Implementation method: add a group player in the project settings, add a player node in the scene editor for character running, and set the group as player. A new node named playercamera is added to the scene editor. A camera component is added and cullingmast is set to player.

Playercamera only renders one player node, so you can see that the characters on the interface are running all the time. In fact, the characters are not moving at all, but the camera in the background is moving.

Final effect:

Effect preview

How to Use ffmpeg to convert MP4 and other formats to MP3 format

Single conversion

command

ffmpeg -i {input file} {output file}

Example

Mp4 to MP3

ffmpeg -i foo.mp4 foobar.mp3

flv 转 mp3

ffmpeg -i foo.flv foobar.mp3

mp4 transfer wav

ffmpeg -i foo.mp4 foobar.wav

wav transfer mp3

ffmpeg -i foo.wav foobar.mp3

Batch conversion

For example, there are *. MP4 files under the folder. To batch convert them to XX. MP3 files, you can use the following methods

for i in ./*.mp4
do
ffmpeg -i $i ${i}.mp3
done

For another example, all files under the folder should be converted into XX. MP3 files in batch. You can use the following methods

for i in ./*
do
ffmpeg -i $i ${i}.mp3
done

Connect two videos

ffmpeg -i "concat:1.ts|2.ts" -acodec copy -vcodec copy -absf aac_adtstoasc output.mp4

Multiple audio merging

ffmpeg.exe -i "concat:1.mp3|2.mp3" -acodec copy output.mp3

After SAP Spartacus successfully logs in, does the request base site need access token

I did test in two Spartacus instances,one is setup locally, the other one is http://cx-qa.eastus.cloudapp.azure.com:4200/

    create a new storefront using Schematics with version 3.1.

OCC endpoint: https://20.51.210.49:9002/
Login with url http://localhost:4200/electronics-spa/en/USD/
Wait for 1 minute till the access token is expired.
Refresh the browser.
Login page is displayed. This is working as designed.

    login with http://cx.eastus.cloudapp.azure.com:4200/

Wait for 1 minute till the access token is expired.
Refresh the browser.
No login page is displayed. Instead, blank screen is displayed.
The cause of blank page is, the OCC API to retrieve CMS structure of login page fails with 400 response:

Because the url itself is wrong:
https://20.51.210.49:9002/occ/v2/cms/pages?pageType=ContentPage&pageLabelOrId=%2Flogin&lang=en&curr=USD
The base site is missing in url.
The correct url should be:
https://20.51.210.49:9002/occ/v2/electronics-spa/cms/pages?pageType=ContentPage&pageLabelOrId=%2Flogin&lang=en&curr=USD
Due to this error, pageStructure.page is undefined, and the code below leads to JavaScript error in console. The login page fails to display. Then blank screen.

But why http://localhost:4200/electronics-spa/en/USD/ can work as expected?
In Spartacus 3.1, there is no Authorization field appended to OCC API for base site request:

But in our QA instance, the access token is appended in API request headers, so 401 error occurs.

Due to this error, base site cannot be retrieved, so subsequent request for login page structure is failed as well. Finally no login page displayed.
Here is some specific debugging information.
http://cx.eastus.cloudapp.azure.com:4200/electronics-spa/en/USD/

This method is called by cms-page.connector.ts.

Read the context of the login page.

This request to read the page structure of the login page has succeeded.

Request parameters successfully read.


The context is now only PreHeader and SiteLogin.





On a properly working local Storefront, the basesite request returns success: