core | :house_with_garden: Open source home automation that puts local control and privacy first

 by   home-assistant Python Version: 2023.3.5 License: Apache-2.0

kandi X-RAY | core Summary

core is a Python library typically used in Institutions, Learning, Administration, Public Services, Internet of Things (IoT), Raspberry Pi applications. core has no bugs, it has no vulnerabilities, it has build file available, it has a Permissive License and it has high support. You can install using 'pip install core' or download it from GitHub, PyPI.
:house_with_garden: Open source home automation that puts local control and privacy first.
    Support
      Quality
        Security
          License
            Reuse
            Support
              Quality
                Security
                  License
                    Reuse

                      kandi-support Support

                        summary
                        core has a highly active ecosystem.
                        summary
                        It has 59124 star(s) with 22481 fork(s). There are 1353 watchers for this library.
                        summary
                        There were 10 major release(s) in the last 6 months.
                        summary
                        There are 2225 open issues and 34859 have been closed. On average issues are closed in 87 days. There are 561 open pull requests and 0 closed requests.
                        summary
                        It has a positive sentiment in the developer community.
                        summary
                        The latest version of core is 2023.3.5
                        core Support
                          Best in #Python
                            Average in #Python
                            core Support
                              Best in #Python
                                Average in #Python

                                  kandi-Quality Quality

                                    summary
                                    core has 0 bugs and 0 code smells.
                                    core Quality
                                      Best in #Python
                                        Average in #Python
                                        core Quality
                                          Best in #Python
                                            Average in #Python

                                              kandi-Security Security

                                                summary
                                                core has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
                                                summary
                                                core code analysis shows 0 unresolved vulnerabilities.
                                                summary
                                                There are 0 security hotspots that need review.
                                                core Security
                                                  Best in #Python
                                                    Average in #Python
                                                    core Security
                                                      Best in #Python
                                                        Average in #Python

                                                          kandi-License License

                                                            summary
                                                            core is licensed under the Apache-2.0 License. This license is Permissive.
                                                            summary
                                                            Permissive licenses have the least restrictions, and you can use them in most projects.
                                                            core License
                                                              Best in #Python
                                                                Average in #Python
                                                                core License
                                                                  Best in #Python
                                                                    Average in #Python

                                                                      kandi-Reuse Reuse

                                                                        summary
                                                                        core releases are available to install and integrate.
                                                                        summary
                                                                        Deployable package is available in PyPI.
                                                                        summary
                                                                        Build file is available. You can build the component from source.
                                                                        summary
                                                                        It has 1010905 lines of code, 57647 functions and 7875 files.
                                                                        summary
                                                                        It has high code complexity. Code complexity directly impacts maintainability of the code.
                                                                        core Reuse
                                                                          Best in #Python
                                                                            Average in #Python
                                                                            core Reuse
                                                                              Best in #Python
                                                                                Average in #Python
                                                                                  Top functions reviewed by kandi - BETA
                                                                                  kandi has reviewed core and discovered the below as its top functions. This is intended to give you an instant insight into core implemented functionality, and help decide if they suit your requirements.
                                                                                  • Create indexes for a given version .
                                                                                    • Update an entity .
                                                                                      • Register services .
                                                                                        • Setup async services .
                                                                                          • Browse a single media item .
                                                                                            • Prepare subscribe topics .
                                                                                              • Compiles the statistics for the given session .
                                                                                                • Update devices .
                                                                                                  • Checks if attributes exist in states .
                                                                                                    • Returns the next departure .
                                                                                                      Get all kandi verified functions for this library.
                                                                                                      Get all kandi verified functions for this library.

                                                                                                      core Key Features

                                                                                                      :house_with_garden: Open source home automation that puts local control and privacy first.

                                                                                                      core Examples and Code Snippets

                                                                                                      How to remove Profiling *.gcda:Cannot open errors with python virtualenv builder?
                                                                                                      Pythondot imgLines of Code : 2dot imgLicense : Strong Copyleft (CC BY-SA 4.0)
                                                                                                      copy iconCopy
                                                                                                      sudo chown -R homeassistant:homeassistant /home/pi/Python-3.6.3
                                                                                                      
                                                                                                      Could not import runpy module
                                                                                                      Pythondot imgLines of Code : 6dot imgLicense : Strong Copyleft (CC BY-SA 4.0)
                                                                                                      copy iconCopy
                                                                                                      export PYTHONPATH=/mnt/usb/srv/homeassistant/lib/python3.4/site-packages
                                                                                                      
                                                                                                      /usr/bin/python
                                                                                                      
                                                                                                      export PYTHONPATH=/mnt/usb/srv/homeassistant/lib/python3.4/site-packages:/usr/lib/python3.6/site-packages:/usr/lib/python3.6/site-packages
                                                                                                      
                                                                                                      Pandas timebased mean
                                                                                                      Pythondot imgLines of Code : 25dot imgLicense : Strong Copyleft (CC BY-SA 4.0)
                                                                                                      copy iconCopy
                                                                                                      # calculate durations
                                                                                                      df['date'] = df['time'].dt.date
                                                                                                      df['time_next'] = df['time'].shift(-1).ffill()
                                                                                                      df['duration_s'] = (df['time_next'] - df['time']).dt.seconds
                                                                                                      
                                                                                                      # calculate weighted average by date
                                                                                                      df.groupby('date').apply(
                                                                                                          lambda z: np.average(z['value'], weights=z['duration_s']))
                                                                                                      
                                                                                                      date
                                                                                                      2021-03-09    0.105416
                                                                                                      dtype: float64
                                                                                                      
                                                                                                      # add day-end values
                                                                                                      z = df.append(
                                                                                                          df.resample('1d', label='right').last().ffill()
                                                                                                      ).sort_index()
                                                                                                      
                                                                                                      # calculate durations
                                                                                                      z['duration_s'] = -z.index.to_series().diff(-1).dt.total_seconds()
                                                                                                      
                                                                                                      # calculate weighted average by date
                                                                                                      z.groupby(z.index.date).apply(
                                                                                                          lambda z: np.average(z['value'], weights=z['duration_s'])).dropna()
                                                                                                      
                                                                                                      Python: Mock ImportError with pytest.fixture
                                                                                                      Pythondot imgLines of Code : 29dot imgLicense : Strong Copyleft (CC BY-SA 4.0)
                                                                                                      copy iconCopy
                                                                                                      $ pytest -vsx test_11.py
                                                                                                      platform linux2 -- Python 2.7.15+, pytest-4.6.6, py-1.8.0, pluggy-0.13.0 -- /usr/bin/python
                                                                                                      cachedir: .pytest_cache
                                                                                                      metadata: {'Python': '2.7.15+', 'Platform': 'Linux-4.15.0-60-generic-x86_64-with-Ubuntu-18.04-bionic', 'Packages': {'py': '1.8.0', 'pytest': '4.6.6', 'pluggy': '0.13.0'}, 'Plugins': {u'html': u'1.22.0', u'metadata': u'1.8.0'}}
                                                                                                      rootdir: /home/nikhilesh
                                                                                                      plugins: html-1.22.0, metadata-1.8.0
                                                                                                      collected 2 items                                                                                                                                                      
                                                                                                      
                                                                                                      test_11.py::test_success ('Value is ', )
                                                                                                      PASSED
                                                                                                      test_11.py::test_fail ('Value is ', None)
                                                                                                      PASSED
                                                                                                      
                                                                                                      ======================================================================= 2 passed in 0.07 seconds =======================================================================
                                                                                                      $ cat test_11.py 
                                                                                                      import utility
                                                                                                      import mock
                                                                                                      
                                                                                                      
                                                                                                      
                                                                                                      def test_success():
                                                                                                          print("Value is ", utility.os)
                                                                                                      
                                                                                                      
                                                                                                      
                                                                                                      @mock.patch("utility.os", return_value = None)
                                                                                                      def test_fail(mock_os):
                                                                                                          print("Value is ", utility.os.return_value)
                                                                                                      
                                                                                                      Community Discussions

                                                                                                      Trending Discussions on core

                                                                                                      The unauthenticated git protocol on port 9418 is no longer supported
                                                                                                      chevron right
                                                                                                      Java, Intellij IDEA problem Unrecognized option: --add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED
                                                                                                      chevron right
                                                                                                      Springboot 2.6.0 / Spring fox 3 - Failed to start bean 'documentationPluginsBootstrapper'
                                                                                                      chevron right
                                                                                                      Your project requires a newer version of the Kotlin Gradle plugin. (Android Studio)
                                                                                                      chevron right
                                                                                                      ESlint - Error: Must use import to load ES Module
                                                                                                      chevron right
                                                                                                      Switch' is not exported from 'react-router-dom'
                                                                                                      chevron right
                                                                                                      throwError(error) is now deprecated, but there is no new Error(HttpErrorResponse)
                                                                                                      chevron right
                                                                                                      How to use appsettings.json in Asp.net core 6 Program.cs file
                                                                                                      chevron right
                                                                                                      AttributeError: Can't get attribute 'new_block' on
                                                                                                      chevron right
                                                                                                      android:exported needs to be explicitly specified for . Apps targeting Android 12 and higher are required to specify
                                                                                                      chevron right

                                                                                                      QUESTION

                                                                                                      The unauthenticated git protocol on port 9418 is no longer supported
                                                                                                      Asked 2022-Mar-27 at 13:23

                                                                                                      I have been using github actions for quite sometime but today my deployments started failing. Below is the error from github action logs

                                                                                                      Command: git
                                                                                                      Arguments: ls-remote --tags --heads git://github.com/adobe-webplatform/eve.git
                                                                                                      Directory: /home/runner/work/stackstream-fe/stackstream-fe
                                                                                                      Output:
                                                                                                      fatal: remote error: 
                                                                                                        The unauthenticated git protocol on port 9418 is no longer supported.
                                                                                                      

                                                                                                      Upon investigation, it appears that below section in my yml file is causing the issue.

                                                                                                          - name: Installing modules
                                                                                                            run: yarn install
                                                                                                      

                                                                                                      I have looked into this change log but can't seem to comprehend the issue.

                                                                                                      Additional Details: Server: EC2 Instance Github actions steps:

                                                                                                        steps:
                                                                                                        - name: Checkout
                                                                                                          uses: actions/checkout@v2
                                                                                                      
                                                                                                        - id: vars
                                                                                                          run: |
                                                                                                            if [ '${{ github.ref }}' == 'refs/heads/master' ]; then echo "::set-output name=environment::prod_stackstream" ; echo "::set-output name=api-url::api" ; elif [ '${{ github.ref }}' == 'refs/heads/staging' ]; then echo "::set-output name=environment::staging_stackstream"  ; echo "::set-output name=api-url::stagingapi" ; else echo "::set-output name=environment::dev_stackstream" ; echo "::set-output name=api-url::devapi" ; fi
                                                                                                      
                                                                                                        - uses: pCYSl5EDgo/cat@master
                                                                                                          id: slack
                                                                                                          with:
                                                                                                            path: .github/workflows/slack.txt
                                                                                                      
                                                                                                        - name: Slack Start Notification
                                                                                                          uses: 8398a7/action-slack@v3
                                                                                                          env:
                                                                                                            SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
                                                                                                            ENVIRONMENT: '`${{ steps.vars.outputs.environment }}`'
                                                                                                            COLOR: good
                                                                                                            STATUS: '`Started`'
                                                                                                          with:
                                                                                                            status: custom
                                                                                                            fields: workflow,job,commit,repo,ref,author,took
                                                                                                            custom_payload: |
                                                                                                              ${{ steps.slack.outputs.text }}
                                                                                                      
                                                                                                        - name: Installing modules
                                                                                                          env:
                                                                                                            REACT_APP_API_URL: 'https://${{ steps.vars.outputs.api-url }}mergestack.com/api/v1'
                                                                                                          run: yarn install
                                                                                                      
                                                                                                        - name: Create Frontend Build
                                                                                                          env:
                                                                                                            REACT_APP_API_URL: 'https://${{ steps.vars.outputs.api-url }}mergestack.com/api/v1'
                                                                                                          run: yarn build
                                                                                                      
                                                                                                        - name: Deploy to Frontend Server DEV
                                                                                                          if: ${{ contains(github.ref, 'dev') }}
                                                                                                          uses: easingthemes/ssh-deploy@v2.1.5
                                                                                                          env:
                                                                                                            SSH_PRIVATE_KEY: ${{ secrets.DEV_KEY }}
                                                                                                            ARGS: '-rltgoDzvO --delete'
                                                                                                            SOURCE: 'deploy/'
                                                                                                            REMOTE_HOST: ${{ secrets.DEV_HOST }}
                                                                                                            REMOTE_USER: plyfolio-dev
                                                                                                            TARGET: '/home/plyfolio-dev/${{ steps.vars.outputs.environment }}/fe/deploy'
                                                                                                      

                                                                                                      package.json file

                                                                                                         {
                                                                                                        "name": "stackstream-fe",
                                                                                                        "version": "1.0.0",
                                                                                                        "authors": [
                                                                                                          "fayyaznofal@gmail.com"
                                                                                                        ],
                                                                                                        "private": true,
                                                                                                        "dependencies": {
                                                                                                          "@fortawesome/fontawesome-svg-core": "^1.2.34",
                                                                                                          "@fortawesome/free-solid-svg-icons": "^5.15.2",
                                                                                                          "@fortawesome/react-fontawesome": "^0.1.14",
                                                                                                          "@fullcalendar/bootstrap": "^5.5.0",
                                                                                                          "@fullcalendar/core": "^5.5.0",
                                                                                                          "@fullcalendar/daygrid": "^5.5.0",
                                                                                                          "@fullcalendar/interaction": "^5.5.0",
                                                                                                          "@fullcalendar/react": "^5.5.0",
                                                                                                          "@lourenci/react-kanban": "^2.1.0",
                                                                                                          "@redux-saga/simple-saga-monitor": "^1.1.2",
                                                                                                          "@testing-library/jest-dom": "^5.11.9",
                                                                                                          "@testing-library/react": "^11.2.3",
                                                                                                          "@testing-library/user-event": "^12.6.0",
                                                                                                          "@toast-ui/react-chart": "^1.0.2",
                                                                                                          "@types/jest": "^26.0.14",
                                                                                                          "@types/node": "^14.10.3",
                                                                                                          "@types/react": "^16.9.49",
                                                                                                          "@types/react-dom": "^16.9.8",
                                                                                                          "@vtaits/react-color-picker": "^0.1.1",
                                                                                                          "apexcharts": "^3.23.1",
                                                                                                          "availity-reactstrap-validation": "^2.7.0",
                                                                                                          "axios": "^0.21.1",
                                                                                                          "axios-mock-adapter": "^1.19.0",
                                                                                                          "axios-progress-bar": "^1.2.0",
                                                                                                          "bootstrap": "^5.0.0-beta2",
                                                                                                          "chart.js": "^2.9.4",
                                                                                                          "chartist": "^0.11.4",
                                                                                                          "classnames": "^2.2.6",
                                                                                                          "components": "^0.1.0",
                                                                                                          "dotenv": "^8.2.0",
                                                                                                          "draft-js": "^0.11.7",
                                                                                                          "echarts": "^4.9.0",
                                                                                                          "echarts-for-react": "^2.0.16",
                                                                                                          "firebase": "^8.2.3",
                                                                                                          "google-maps-react": "^2.0.6",
                                                                                                          "history": "^4.10.1",
                                                                                                          "i": "^0.3.6",
                                                                                                          "i18next": "^19.8.4",
                                                                                                          "i18next-browser-languagedetector": "^6.0.1",
                                                                                                          "jsonwebtoken": "^8.5.1",
                                                                                                          "leaflet": "^1.7.1",
                                                                                                          "lodash": "^4.17.21",
                                                                                                          "lodash.clonedeep": "^4.5.0",
                                                                                                          "lodash.get": "^4.4.2",
                                                                                                          "metismenujs": "^1.2.1",
                                                                                                          "mkdirp": "^1.0.4",
                                                                                                          "moment": "2.29.1",
                                                                                                          "moment-timezone": "^0.5.32",
                                                                                                          "nouislider-react": "^3.3.9",
                                                                                                          "npm": "^7.6.3",
                                                                                                          "prop-types": "^15.7.2",
                                                                                                          "query-string": "^6.14.0",
                                                                                                          "react": "^16.13.1",
                                                                                                          "react-apexcharts": "^1.3.7",
                                                                                                          "react-auth-code-input": "^1.0.0",
                                                                                                          "react-avatar": "^3.10.0",
                                                                                                          "react-bootstrap": "^1.5.0",
                                                                                                          "react-bootstrap-editable": "^0.8.2",
                                                                                                          "react-bootstrap-sweetalert": "^5.2.0",
                                                                                                          "react-bootstrap-table-next": "^4.0.3",
                                                                                                          "react-bootstrap-table2-editor": "^1.4.0",
                                                                                                          "react-bootstrap-table2-paginator": "^2.1.2",
                                                                                                          "react-bootstrap-table2-toolkit": "^2.1.3",
                                                                                                          "react-chartist": "^0.14.3",
                                                                                                          "react-chartjs-2": "^2.11.1",
                                                                                                          "react-color": "^2.19.3",
                                                                                                          "react-confirm-alert": "^2.7.0",
                                                                                                          "react-content-loader": "^6.0.1",
                                                                                                          "react-countdown": "^2.3.1",
                                                                                                          "react-countup": "^4.3.3",
                                                                                                          "react-cropper": "^2.1.4",
                                                                                                          "react-data-table-component": "^6.11.8",
                                                                                                          "react-date-picker": "^8.0.6",
                                                                                                          "react-datepicker": "^3.4.1",
                                                                                                          "react-dom": "^16.13.1",
                                                                                                          "react-draft-wysiwyg": "^1.14.5",
                                                                                                          "react-drag-listview": "^0.1.8",
                                                                                                          "react-drawer": "^1.3.4",
                                                                                                          "react-dropzone": "^11.2.4",
                                                                                                          "react-dual-listbox": "^2.0.0",
                                                                                                          "react-facebook-login": "^4.1.1",
                                                                                                          "react-flatpickr": "^3.10.6",
                                                                                                          "react-google-login": "^5.2.2",
                                                                                                          "react-hook-form": "^7.15.2",
                                                                                                          "react-i18next": "^11.8.5",
                                                                                                          "react-icons": "^4.2.0",
                                                                                                          "react-image-lightbox": "^5.1.1",
                                                                                                          "react-input-mask": "^2.0.4",
                                                                                                          "react-jvectormap": "^0.0.16",
                                                                                                          "react-leaflet": "^3.0.5",
                                                                                                          "react-meta-tags": "^1.0.1",
                                                                                                          "react-modal-video": "^1.2.6",
                                                                                                          "react-notifications": "^1.7.2",
                                                                                                          "react-number-format": "^4.7.3",
                                                                                                          "react-perfect-scrollbar": "^1.5.8",
                                                                                                          "react-rangeslider": "^2.2.0",
                                                                                                          "react-rating": "^2.0.5",
                                                                                                          "react-rating-tooltip": "^1.1.6",
                                                                                                          "react-redux": "^7.2.1",
                                                                                                          "react-responsive-carousel": "^3.2.11",
                                                                                                          "react-router-dom": "^5.2.0",
                                                                                                          "react-script": "^2.0.5",
                                                                                                          "react-scripts": "3.4.3",
                                                                                                          "react-select": "^4.3.1",
                                                                                                          "react-sparklines": "^1.7.0",
                                                                                                          "react-star-ratings": "^2.3.0",
                                                                                                          "react-super-responsive-table": "^5.2.0",
                                                                                                          "react-switch": "^6.0.0",
                                                                                                          "react-table": "^7.6.3",
                                                                                                          "react-toastify": "^7.0.3",
                                                                                                          "react-toastr": "^3.0.0",
                                                                                                          "react-twitter-auth": "0.0.13",
                                                                                                          "reactstrap": "^8.8.1",
                                                                                                          "recharts": "^2.0.8",
                                                                                                          "redux": "^4.0.5",
                                                                                                          "redux-saga": "^1.1.3",
                                                                                                          "reselect": "^4.0.0",
                                                                                                          "sass": "^1.37.5",
                                                                                                          "simplebar-react": "^2.3.0",
                                                                                                          "styled": "^1.0.0",
                                                                                                          "styled-components": "^5.2.1",
                                                                                                          "toastr": "^2.1.4",
                                                                                                          "typescript": "^4.0.2",
                                                                                                          "universal-cookie": "^4.0.4"
                                                                                                        },
                                                                                                        "devDependencies": {
                                                                                                          "@typescript-eslint/eslint-plugin": "^2.27.0",
                                                                                                          "@typescript-eslint/parser": "^2.27.0",
                                                                                                          "@typescript-eslint/typescript-estree": "^4.15.2",
                                                                                                          "eslint-config-prettier": "^6.10.1",
                                                                                                          "eslint-plugin-prettier": "^3.1.2",
                                                                                                          "husky": "^4.2.5",
                                                                                                          "lint-staged": "^10.1.3",
                                                                                                          "prettier": "^1.19.1",
                                                                                                          "react-test-renderer": "^16.13.1",
                                                                                                          "redux-devtools-extension": "^2.13.8",
                                                                                                          "redux-mock-store": "^1.5.4"
                                                                                                        },
                                                                                                        "scripts": {
                                                                                                          "start": "react-scripts start",
                                                                                                          "build": "react-scripts build && mv build ./deploy/build",
                                                                                                          "build-local": "react-scripts build",
                                                                                                          "test": "react-scripts test",
                                                                                                          "eject": "react-scripts eject"
                                                                                                        },
                                                                                                        "eslintConfig": {
                                                                                                          "extends": "react-app"
                                                                                                        },
                                                                                                        "husky": {
                                                                                                          "hooks": {
                                                                                                            "pre-commit": "lint-staged"
                                                                                                          }
                                                                                                        },
                                                                                                        "lint-staged": {
                                                                                                          "*.{js,ts,tsx}": [
                                                                                                            "eslint --fix"
                                                                                                          ]
                                                                                                        },
                                                                                                        "browserslist": {
                                                                                                          "production": [
                                                                                                            ">0.2%",
                                                                                                            "not dead",
                                                                                                            "not op_mini all"
                                                                                                          ],
                                                                                                          "development": [
                                                                                                            "last 1 chrome version",
                                                                                                            "last 1 firefox version",
                                                                                                            "last 1 safari version"
                                                                                                          ]
                                                                                                        }
                                                                                                      }
                                                                                                      

                                                                                                      ANSWER

                                                                                                      Answered 2022-Mar-16 at 07:01

                                                                                                      First, this error message is indeed expected on Jan. 11th, 2022.
                                                                                                      See "Improving Git protocol security on GitHub".

                                                                                                      January 11, 2022 Final brownout.

                                                                                                      This is the full brownout period where we’ll temporarily stop accepting the deprecated key and signature types, ciphers, and MACs, and the unencrypted Git protocol.
                                                                                                      This will help clients discover any lingering use of older keys or old URLs.

                                                                                                      Second, check your package.json dependencies for any git:// URL, as in this example, fixed in this PR.

                                                                                                      As noted by Jörg W Mittag:

                                                                                                      There was a 4-month warning.
                                                                                                      The entire Internet has been moving away from unauthenticated, unencrypted protocols for a decade, it's not like this is a huge surprise.

                                                                                                      Personally, I consider it less an "issue" and more "detecting unmaintained dependencies".

                                                                                                      Plus, this is still only the brownout period, so the protocol will only be disabled for a short period of time, allowing developers to discover the problem.

                                                                                                      The permanent shutdown is not until March 15th.

                                                                                                      For GitHub Actions:

                                                                                                      As in actions/checkout issue 14, you can add as a first step:

                                                                                                          - name: Fix up git URLs
                                                                                                            run: echo -e '[url "https://github.com/"]\n  insteadOf = "git://github.com/"' >> ~/.gitconfig
                                                                                                      

                                                                                                      That will change any git://github.com/ into https://github.com/.

                                                                                                      For local projects

                                                                                                      For all your repositories, you can set:

                                                                                                      git config --global url."https://github.com/".insteadOf git://github.com/
                                                                                                      

                                                                                                      You can also use SSH, but GitHub Security reminds us that, as of March 15th, 2022, GitHub stopped accepting DSA keys. RSA keys uploaded after Nov 2, 2021 will work only with SHA-2 signatures.
                                                                                                      The deprecated MACs, ciphers, and unencrypted Git protocol are permanently disabled.

                                                                                                      So this (with the right key) would work:

                                                                                                      git config --global url."git@github.com:".insteadOf git://github.com/
                                                                                                      

                                                                                                      That will change any git://github.com/ (unencrypted Git protocol) into git@github.com: (SSH URL).

                                                                                                      Source https://stackoverflow.com/questions/70663523

                                                                                                      QUESTION

                                                                                                      Java, Intellij IDEA problem Unrecognized option: --add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED
                                                                                                      Asked 2022-Mar-26 at 15:23

                                                                                                      I have newly installed

                                                                                                      IntelliJ IDEA 2021.2 (Ultimate Edition)
                                                                                                      Build #IU-212.4746.92, built on July 27, 2021
                                                                                                      Licensed to XXXXXX
                                                                                                      Subscription is active until August 15, 2021.
                                                                                                      Runtime version: 11.0.11+9-b1504.13 amd64
                                                                                                      VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
                                                                                                      Linux 5.4.0-80-generic
                                                                                                      GC: G1 Young Generation, G1 Old Generation
                                                                                                      Memory: 2048M
                                                                                                      Cores: 3
                                                                                                      
                                                                                                      Kotlin: 212-1.5.10-release-IJ4746.92
                                                                                                      Current Desktop: X-Cinnamon
                                                                                                      

                                                                                                      I cloned project I work with on other workstation without issues, but cannot start any class with main method and IDEA says:

                                                                                                      Abnormal build process termination: 
                                                                                                      /usr/lib/jvm/java-1.8.0-openjdk-amd64/bin/java -Xmx700m -Djava.awt.headless=true -Djava.endorsed.dirs=\"\" -Dcompile.parallel=false -Drebuild.on.dependency.change=true -Djdt.compiler.useSingleThread=true -Daether.connector.resumeDownloads=false -Dio.netty.initialSeedUniquifier=-5972351880001011455 -Dfile.encoding=UTF-8 -Duser.language=en -Duser.country=US -Didea.paths.selector=IntelliJIdea2021.2 -Didea.home.path=/home/pm/idea-IU-212.4746.92 -Didea.config.path=/home/pm/.config/JetBrains/IntelliJIdea2021.2 -Didea.plugins.path=/home/pm/.local/share/JetBrains/IntelliJIdea2021.2 -Djps.log.dir=/home/pm/.cache/JetBrains/IntelliJIdea2021.2/log/build-log -Djps.fallback.jdk.home=/home/pm/idea-IU-212.4746.92/jbr -Djps.fallback.jdk.version=11.0.11 -Dio.netty.noUnsafe=true -Djava.io.tmpdir=/home/pm/.cache/JetBrains/IntelliJIdea2021.2/compile-server/rfg-survey-api_cc70fc05/_temp_ -Djps.backward.ref.index.builder=true -Djps.track.ap.dependencies=false --add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED --add-opens=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED --add-opens=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED --add-opens=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED --add-opens=jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED --add-opens=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED --add-opens=jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED --add-opens=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED --add-opens=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED --add-opens=jdk.compiler/com.sun.tools.javac.jvm=ALL-UNNAMED -Dtmh.instrument.annotations=true -Dtmh.generate.line.numbers=true -Dkotlin.incremental.compilation=true -Dkotlin.incremental.compilation.js=true -Dkotlin.daemon.enabled -Dkotlin.daemon.client.alive.path=\"/tmp/kotlin-idea-12426594439704512301-is-running\" -classpath /home/pm/idea-IU-212.4746.92/plugins/java/lib/jps-launcher.jar:/usr/lib/jvm/java-1.8.0-openjdk-amd64/lib/tools.jar org.jetbrains.jps.cmdline.Launcher /home/pm/idea-IU-212.4746.92/lib/slf4j.jar:/home/pm/idea-IU-212.4746.92/lib/idea_rt.jar:/home/pm/idea-IU-212.4746.92/lib/platform-api.jar:/home/pm/idea-IU-212.4746.92/plugins/java/lib/maven-resolver-transport-file-1.3.3.jar:/home/pm/idea-IU-212.4746.92/lib/forms_rt.jar:/home/pm/idea-IU-212.4746.92/lib/util.jar:/home/pm/idea-IU-212.4746.92/lib/annotations.jar:/home/pm/idea-IU-212.4746.92/lib/3rd-party.jar:/home/pm/idea-IU-212.4746.92/lib/kotlin-stdlib-jdk8.jar:/home/pm/idea-IU-212.4746.92/plugins/java/lib/maven-resolver-connector-basic-1.3.3.jar:/home/pm/idea-IU-212.4746.92/lib/jna-platform.jar:/home/pm/idea-IU-212.4746.92/lib/protobuf-java-3.15.8.jar:/home/pm/idea-IU-212.4746.92/plugins/java/lib/jps-builders-6.jar:/home/pm/idea-IU-212.4746.92/plugins/java/lib/javac2.jar:/home/pm/idea-IU-212.4746.92/plugins/java/lib/aether-dependency-resolver.jar:/home/pm/idea-IU-212.4746.92/plugins/java/lib/jps-builders.jar:/home/pm/idea-IU-212.4746.92/plugins/java/lib/jps-javac-extension-1.jar:/home/pm/idea-IU-212.4746.92/lib/jna.jar:/home/pm/idea-IU-212.4746.92/lib/jps-model.jar:/home/pm/idea-IU-212.4746.92/plugins/java/lib/maven-resolver-transport-http-1.3.3.jar:/home/pm/idea-IU-212.4746.92/plugins/JavaEE/lib/jasper-v2-rt.jar:/home/pm/idea-IU-212.4746.92/plugins/Kotlin/lib/kotlin-reflect.jar:/home/pm/idea-IU-212.4746.92/plugins/Kotlin/lib/kotlin-plugin.jar:/home/pm/idea-IU-212.4746.92/plugins/ant/lib/ant-jps.jar:/home/pm/idea-IU-212.4746.92/plugins/uiDesigner/lib/jps/java-guiForms-jps.jar:/home/pm/idea-IU-212.4746.92/plugins/eclipse/lib/eclipse-jps.jar:/home/pm/idea-IU-212.4746.92/plugins/eclipse/lib/eclipse-common.jar:/home/pm/idea-IU-212.4746.92/plugins/IntelliLang/lib/java-langInjection-jps.jar:/home/pm/idea-IU-212.4746.92/plugins/Groovy/lib/groovy-jps.jar:/home/pm/idea-IU-212.4746.92/plugins/Groovy/lib/groovy-constants-rt.jar:/home/pm/idea-IU-212.4746.92/plugins/maven/lib/maven-jps.jar:/home/pm/idea-IU-212.4746.92/plugins/gradle-java/lib/gradle-jps.jar:/home/pm/idea-IU-212.4746.92/plugins/devkit/lib/devkit-jps.jar:/home/pm/idea-IU-212.4746.92/plugins/javaFX/lib/javaFX-jps.jar:/home/pm/idea-IU-212.4746.92/plugins/javaFX/lib/javaFX-common.jar:/home/pm/idea-IU-212.4746.92/plugins/JavaEE/lib/javaee-jps.jar:/home/pm/idea-IU-212.4746.92/plugins/webSphereIntegration/lib/jps/javaee-appServers-websphere-jps.jar:/home/pm/idea-IU-212.4746.92/plugins/weblogicIntegration/lib/jps/javaee-appServers-weblogic-jps.jar:/home/pm/idea-IU-212.4746.92/plugins/JPA/lib/jps/javaee-jpa-jps.jar:/home/pm/idea-IU-212.4746.92/plugins/Grails/lib/groovy-grails-jps.jar:/home/pm/idea-IU-212.4746.92/plugins/Grails/lib/groovy-grails-compilerPatch.jar:/home/pm/idea-IU-212.4746.92/plugins/Kotlin/lib/jps/kotlin-jps-plugin.jar:/home/pm/idea-IU-212.4746.92/plugins/Kotlin/lib/kotlin-jps-common.jar:/home/pm/idea-IU-212.4746.92/plugins/Kotlin/lib/kotlin-common.jar org.jetbrains.jps.cmdline.BuildMain 127.0.0.1 34781 9f0681bb-da2a-48db-8344-900ddeb29804 /home/pm/.cache/JetBrains/IntelliJIdea2021.2/compile-server
                                                                                                      Unrecognized option: --add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED
                                                                                                      Error: Could not create the Java Virtual Machine.
                                                                                                      Error: A fatal exception has occurred. Program will exit.
                                                                                                      

                                                                                                      I found other comment to check Lombok works and I see it is fine.

                                                                                                      How to fix the problem?

                                                                                                      ANSWER

                                                                                                      Answered 2021-Jul-28 at 07:22

                                                                                                      You are running the project via Java 1.8 and add the --add-opens option to the runner. However Java 1.8 does not support it.

                                                                                                      So, the first option is to use Java 11 to run the project, as Java 11 can recognize this VM option.

                                                                                                      Another solution is to find a place where --add-opens is added and remove it. Check Run configuration in IntelliJ IDEA (VM options field) and Maven/Gradle configuration files for argLine (Maven) and jvmArgs (Gradle)

                                                                                                      Source https://stackoverflow.com/questions/68554693

                                                                                                      QUESTION

                                                                                                      Springboot 2.6.0 / Spring fox 3 - Failed to start bean 'documentationPluginsBootstrapper'
                                                                                                      Asked 2022-Mar-25 at 06:14

                                                                                                      I'm trying to initiate a Springboot project using Open Jdk 15, Springboot 2.6.0, Springfox 3. We are working on a project that replaced Netty as the webserver and used Jetty instead because we do not need a non-blocking environment.

                                                                                                      In the code we depend primarily on Reactor API (Flux, Mono), so we can not remove org.springframework.boot:spring-boot-starter-webflux dependencies.

                                                                                                      I replicated the problem that we have in a new project.: https://github.com/jvacaq/spring-fox.

                                                                                                      I figured out that these lines in our build.gradle file are the origin of the problem.

                                                                                                      compile("org.springframework.boot:spring-boot-starter-web") {
                                                                                                         exclude module: "spring-boot-starter-tomcat"
                                                                                                      }
                                                                                                      compile("org.springframework.boot:spring-boot-starter-jetty")
                                                                                                      

                                                                                                      Here is the build.gradle file:

                                                                                                      plugins {
                                                                                                          id 'org.springframework.boot' version '2.6.0'
                                                                                                          id 'io.spring.dependency-management' version '1.0.11.RELEASE'
                                                                                                          id 'java'
                                                                                                      }
                                                                                                      
                                                                                                      group = 'com.example'
                                                                                                      version = '0.0.1-SNAPSHOT'
                                                                                                      sourceCompatibility = '11'
                                                                                                      
                                                                                                      repositories {
                                                                                                          mavenCentral()
                                                                                                      }
                                                                                                      
                                                                                                      dependencies {
                                                                                                          compile("org.springframework.boot:spring-boot-starter-web") {
                                                                                                              exclude module: "spring-boot-starter-tomcat"
                                                                                                          }
                                                                                                          compile("org.springframework.boot:spring-boot-starter-jetty")
                                                                                                          implementation 'org.springframework.boot:spring-boot-starter-webflux'
                                                                                                          testImplementation 'org.springframework.boot:spring-boot-starter-test'
                                                                                                          testImplementation 'io.projectreactor:reactor-test'
                                                                                                          implementation "io.springfox:springfox-boot-starter:3.0.0"
                                                                                                      }
                                                                                                      
                                                                                                      test {
                                                                                                          useJUnitPlatform()
                                                                                                      }
                                                                                                      
                                                                                                      

                                                                                                      I issued the command gradle clean bootrun. The result is this error:

                                                                                                       gradle clean bootrun                                                                                                                                                                                                               
                                                                                                      
                                                                                                      > Task :bootRun FAILED
                                                                                                      
                                                                                                        .   ____          _            __ _ _
                                                                                                       /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
                                                                                                      ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
                                                                                                       \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
                                                                                                        '  |____| .__|_| |_|_| |_\__, | / / / /
                                                                                                       =========|_|==============|___/=/_/_/_/
                                                                                                       :: Spring Boot ::                (v2.6.0)
                                                                                                      
                                                                                                      2021-11-19 09:41:06.665  INFO 16666 --- [           main] c.e.springfox.SpringFoxApplication       : Starting SpringFoxApplication using Java 15.0.2 on advance-Inspiron-5379 with PID 16666 (/home/advance/projects/spring-fox/build/classes/java/main started by advance in /home/advance/projects/spring-fox)
                                                                                                      2021-11-19 09:41:06.666  INFO 16666 --- [           main] c.e.springfox.SpringFoxApplication       : No active profile set, falling back to default profiles: default
                                                                                                      2021-11-19 09:41:07.294  INFO 16666 --- [           main] org.eclipse.jetty.util.log               : Logging initialized @1132ms to org.eclipse.jetty.util.log.Slf4jLog
                                                                                                      2021-11-19 09:41:07.396  INFO 16666 --- [           main] o.s.b.w.e.j.JettyServletWebServerFactory : Server initialized with port: 8080
                                                                                                      2021-11-19 09:41:07.398  INFO 16666 --- [           main] org.eclipse.jetty.server.Server          : jetty-9.4.44.v20210927; built: 2021-09-27T23:02:44.612Z; git: 8da83308eeca865e495e53ef315a249d63ba9332; jvm 15.0.2+7-27
                                                                                                      2021-11-19 09:41:07.417  INFO 16666 --- [           main] o.e.j.s.h.ContextHandler.application     : Initializing Spring embedded WebApplicationContext
                                                                                                      2021-11-19 09:41:07.417  INFO 16666 --- [           main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 713 ms
                                                                                                      2021-11-19 09:41:07.474  INFO 16666 --- [           main] org.eclipse.jetty.server.session         : DefaultSessionIdManager workerName=node0
                                                                                                      2021-11-19 09:41:07.474  INFO 16666 --- [           main] org.eclipse.jetty.server.session         : No SessionScavenger set, using defaults
                                                                                                      2021-11-19 09:41:07.475  INFO 16666 --- [           main] org.eclipse.jetty.server.session         : node0 Scavenging every 660000ms
                                                                                                      2021-11-19 09:41:07.480  INFO 16666 --- [           main] o.e.jetty.server.handler.ContextHandler  : Started o.s.b.w.e.j.JettyEmbeddedWebAppContext@6aa3bfc{application,/,[file:///tmp/jetty-docbase.8080.2024342829220941812/, jar:file:/home/advance/.gradle/caches/modules-2/files-2.1/io.springfox/springfox-swagger-ui/3.0.0/1e665fbe22148f7c36fa8a08e515a0047cd4390b/springfox-swagger-ui-3.0.0.jar!/META-INF/resources],AVAILABLE}
                                                                                                      2021-11-19 09:41:07.480  INFO 16666 --- [           main] org.eclipse.jetty.server.Server          : Started @1318ms
                                                                                                      2021-11-19 09:41:07.920  INFO 16666 --- [           main] o.e.j.s.h.ContextHandler.application     : Initializing Spring DispatcherServlet 'dispatcherServlet'
                                                                                                      2021-11-19 09:41:07.920  INFO 16666 --- [           main] o.s.web.servlet.DispatcherServlet        : Initializing Servlet 'dispatcherServlet'
                                                                                                      2021-11-19 09:41:07.921  INFO 16666 --- [           main] o.s.web.servlet.DispatcherServlet        : Completed initialization in 1 ms
                                                                                                      2021-11-19 09:41:07.931  INFO 16666 --- [           main] o.e.jetty.server.AbstractConnector       : Started ServerConnector@2643d762{HTTP/1.1, (http/1.1)}{0.0.0.0:8080}
                                                                                                      2021-11-19 09:41:07.932  INFO 16666 --- [           main] o.s.b.web.embedded.jetty.JettyWebServer  : Jetty started on port(s) 8080 (http/1.1) with context path '/'
                                                                                                      2021-11-19 09:41:07.934  WARN 16666 --- [           main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Failed to start bean 'documentationPluginsBootstrapper'; nested exception is java.lang.NullPointerException: Cannot invoke "org.springframework.web.servlet.mvc.condition.PatternsRequestCondition.getPatterns()" because "this.condition" is null
                                                                                                      2021-11-19 09:41:07.949  INFO 16666 --- [           main] o.e.jetty.server.AbstractConnector       : Stopped ServerConnector@2643d762{HTTP/1.1, (http/1.1)}{0.0.0.0:8080}
                                                                                                      2021-11-19 09:41:07.950  INFO 16666 --- [           main] org.eclipse.jetty.server.session         : node0 Stopped scavenging
                                                                                                      2021-11-19 09:41:07.951  INFO 16666 --- [           main] o.e.j.s.h.ContextHandler.application     : Destroying Spring FrameworkServlet 'dispatcherServlet'
                                                                                                      2021-11-19 09:41:07.951  INFO 16666 --- [           main] o.e.jetty.server.handler.ContextHandler  : Stopped o.s.b.w.e.j.JettyEmbeddedWebAppContext@6aa3bfc{application,/,[file:///tmp/jetty-docbase.8080.2024342829220941812/, jar:file:/home/advance/.gradle/caches/modules-2/files-2.1/io.springfox/springfox-swagger-ui/3.0.0/1e665fbe22148f7c36fa8a08e515a0047cd4390b/springfox-swagger-ui-3.0.0.jar!/META-INF/resources],STOPPED}
                                                                                                      2021-11-19 09:41:07.958  INFO 16666 --- [           main] ConditionEvaluationReportLoggingListener : 
                                                                                                      
                                                                                                      Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
                                                                                                      2021-11-19 09:41:07.970 ERROR 16666 --- [           main] o.s.boot.SpringApplication               : Application run failed
                                                                                                      
                                                                                                      org.springframework.context.ApplicationContextException: Failed to start bean 'documentationPluginsBootstrapper'; nested exception is java.lang.NullPointerException: Cannot invoke "org.springframework.web.servlet.mvc.condition.PatternsRequestCondition.getPatterns()" because "this.condition" is null
                                                                                                              at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:181) ~[spring-context-5.3.13.jar:5.3.13]
                                                                                                              at org.springframework.context.support.DefaultLifecycleProcessor.access$200(DefaultLifecycleProcessor.java:54) ~[spring-context-5.3.13.jar:5.3.13]
                                                                                                              at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.start(DefaultLifecycleProcessor.java:356) ~[spring-context-5.3.13.jar:5.3.13]
                                                                                                              at java.base/java.lang.Iterable.forEach(Iterable.java:75) ~[na:na]
                                                                                                              at org.springframework.context.support.DefaultLifecycleProcessor.startBeans(DefaultLifecycleProcessor.java:155) ~[spring-context-5.3.13.jar:5.3.13]
                                                                                                              at org.springframework.context.support.DefaultLifecycleProcessor.onRefresh(DefaultLifecycleProcessor.java:123) ~[spring-context-5.3.13.jar:5.3.13]
                                                                                                              at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:935) ~[spring-context-5.3.13.jar:5.3.13]
                                                                                                              at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:586) ~[spring-context-5.3.13.jar:5.3.13]
                                                                                                              at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:145) ~[spring-boot-2.6.0.jar:2.6.0]
                                                                                                              at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:730) ~[spring-boot-2.6.0.jar:2.6.0]
                                                                                                              at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:412) ~[spring-boot-2.6.0.jar:2.6.0]
                                                                                                              at org.springframework.boot.SpringApplication.run(SpringApplication.java:302) ~[spring-boot-2.6.0.jar:2.6.0]
                                                                                                              at org.springframework.boot.SpringApplication.run(SpringApplication.java:1301) ~[spring-boot-2.6.0.jar:2.6.0]
                                                                                                              at org.springframework.boot.SpringApplication.run(SpringApplication.java:1290) ~[spring-boot-2.6.0.jar:2.6.0]
                                                                                                              at com.example.springfox.SpringFoxApplication.main(SpringFoxApplication.java:10) ~[main/:na]
                                                                                                      Caused by: java.lang.NullPointerException: Cannot invoke "org.springframework.web.servlet.mvc.condition.PatternsRequestCondition.getPatterns()" because "this.condition" is null
                                                                                                              at springfox.documentation.spring.web.WebMvcPatternsRequestConditionWrapper.getPatterns(WebMvcPatternsRequestConditionWrapper.java:56) ~[springfox-spring-webmvc-3.0.0.jar:3.0.0]
                                                                                                              at springfox.documentation.RequestHandler.sortedPaths(RequestHandler.java:113) ~[springfox-core-3.0.0.jar:3.0.0]
                                                                                                              at springfox.documentation.spi.service.contexts.Orderings.lambda$byPatternsCondition$3(Orderings.java:89) ~[springfox-spi-3.0.0.jar:3.0.0]
                                                                                                              at java.base/java.util.Comparator.lambda$comparing$77a9974f$1(Comparator.java:469) ~[na:na]
                                                                                                              at java.base/java.util.TimSort.countRunAndMakeAscending(TimSort.java:355) ~[na:na]
                                                                                                              at java.base/java.util.TimSort.sort(TimSort.java:220) ~[na:na]
                                                                                                              at java.base/java.util.Arrays.sort(Arrays.java:1306) ~[na:na]
                                                                                                              at java.base/java.util.ArrayList.sort(ArrayList.java:1721) ~[na:na]
                                                                                                              at java.base/java.util.stream.SortedOps$RefSortingSink.end(SortedOps.java:392) ~[na:na]
                                                                                                              at java.base/java.util.stream.Sink$ChainedReference.end(Sink.java:258) ~[na:na]
                                                                                                              at java.base/java.util.stream.Sink$ChainedReference.end(Sink.java:258) ~[na:na]
                                                                                                              at java.base/java.util.stream.Sink$ChainedReference.end(Sink.java:258) ~[na:na]
                                                                                                              at java.base/java.util.stream.Sink$ChainedReference.end(Sink.java:258) ~[na:na]
                                                                                                              at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:485) ~[na:na]
                                                                                                              at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474) ~[na:na]
                                                                                                              at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:913) ~[na:na]
                                                                                                              at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[na:na]
                                                                                                              at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:578) ~[na:na]
                                                                                                              at springfox.documentation.spring.web.plugins.WebMvcRequestHandlerProvider.requestHandlers(WebMvcRequestHandlerProvider.java:81) ~[springfox-spring-webmvc-3.0.0.jar:3.0.0]
                                                                                                              at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195) ~[na:na]
                                                                                                              at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1625) ~[na:na]
                                                                                                              at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484) ~[na:na]
                                                                                                              at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474) ~[na:na]
                                                                                                              at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:913) ~[na:na]
                                                                                                              at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[na:na]
                                                                                                              at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:578) ~[na:na]
                                                                                                              at springfox.documentation.spring.web.plugins.AbstractDocumentationPluginsBootstrapper.withDefaults(AbstractDocumentationPluginsBootstrapper.java:107) ~[springfox-spring-web-3.0.0.jar:3.0.0]
                                                                                                              at springfox.documentation.spring.web.plugins.AbstractDocumentationPluginsBootstrapper.buildContext(AbstractDocumentationPluginsBootstrapper.java:91) ~[springfox-spring-web-3.0.0.jar:3.0.0]
                                                                                                              at springfox.documentation.spring.web.plugins.AbstractDocumentationPluginsBootstrapper.bootstrapDocumentationPlugins(AbstractDocumentationPluginsBootstrapper.java:82) ~[springfox-spring-web-3.0.0.jar:3.0.0]
                                                                                                              at springfox.documentation.spring.web.plugins.DocumentationPluginsBootstrapper.start(DocumentationPluginsBootstrapper.java:100) ~[springfox-spring-web-3.0.0.jar:3.0.0]
                                                                                                              at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:178) ~[spring-context-5.3.13.jar:5.3.13]
                                                                                                              ... 14 common frames omitted
                                                                                                      
                                                                                                      
                                                                                                      FAILURE: Build failed with an exception.
                                                                                                      
                                                                                                      * What went wrong:
                                                                                                      Execution failed for task ':bootRun'.
                                                                                                      > Process 'command '/home/advance/.sdkman/candidates/java/15.0.2-open/bin/java'' finished with non-zero exit value 1
                                                                                                      
                                                                                                      * 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
                                                                                                      
                                                                                                      Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
                                                                                                      Use '--warning-mode all' to show the individual deprecation warnings.
                                                                                                      See https://docs.gradle.org/6.9.1/userguide/command_line_interface.html#sec:command_line_warnings
                                                                                                      
                                                                                                      BUILD FAILED in 2s
                                                                                                      5 actionable tasks: 5 executed
                                                                                                      

                                                                                                      Does anyone have an idea how to solve it?

                                                                                                      ANSWER

                                                                                                      Answered 2022-Feb-08 at 12:36

                                                                                                      This problem's caused by a bug in Springfox. It's making an assumption about how Spring MVC is set up that doesn't always hold true. Specifically, it's assuming that MVC's path matching will use the Ant-based path matcher and not the PathPattern-based matcher. PathPattern-based matching has been an option for some time now and is the default as of Spring Boot 2.6.

                                                                                                      As described in Spring Boot 2.6's release notes, you can restore the configuration that Springfox assumes will be used by setting spring.mvc.pathmatch.matching-strategy to ant-path-matcher in your application.properties file. Note that this will only work if you are not using Spring Boot's Actuator. The Actuator always uses PathPattern-based parsing, irrespective of the configured matching-strategy. A change to Springfox will be required if you want to use it with the Actuator in Spring Boot 2.6 and later.

                                                                                                      Source https://stackoverflow.com/questions/70036953

                                                                                                      QUESTION

                                                                                                      Your project requires a newer version of the Kotlin Gradle plugin. (Android Studio)
                                                                                                      Asked 2022-Mar-17 at 15:50

                                                                                                      I've just updated my flutter project packages to be null-safety compliant and now Android Studio wants me to update my project to use the latest version of Kotling Gradle Plugin. Can't see where to change this though. I have tried to change "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" into "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.6.10" but this has no effect.

                                                                                                      My build.grade-file looks like this:

                                                                                                      def localProperties = new Properties()
                                                                                                      def localPropertiesFile = rootProject.file('local.properties')
                                                                                                      if (localPropertiesFile.exists()) {
                                                                                                          localPropertiesFile.withReader('UTF-8') { reader ->
                                                                                                              localProperties.load(reader)
                                                                                                          }
                                                                                                      }
                                                                                                      
                                                                                                      def flutterRoot = localProperties.getProperty('flutter.sdk')
                                                                                                      if (flutterRoot == null) {
                                                                                                          throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
                                                                                                      }
                                                                                                      
                                                                                                      def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
                                                                                                      if (flutterVersionCode == null) {
                                                                                                          flutterVersionCode = '1'
                                                                                                      }
                                                                                                      
                                                                                                      def flutterVersionName = localProperties.getProperty('flutter.versionName')
                                                                                                      if (flutterVersionName == null) {
                                                                                                          flutterVersionName = '1.0'
                                                                                                      }
                                                                                                      
                                                                                                      apply plugin: 'com.android.application'
                                                                                                      apply plugin: 'kotlin-android'
                                                                                                      apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
                                                                                                      
                                                                                                      def keystoreProperties = new Properties()
                                                                                                      def keystorePropertiesFile = rootProject.file('key.properties')
                                                                                                      if (keystorePropertiesFile.exists()) {
                                                                                                          keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
                                                                                                      }
                                                                                                      
                                                                                                      android {
                                                                                                          compileSdkVersion 31
                                                                                                      
                                                                                                          sourceSets {
                                                                                                              main.java.srcDirs += 'src/main/kotlin'
                                                                                                          }
                                                                                                      
                                                                                                          lintOptions {
                                                                                                              disable 'InvalidPackage'
                                                                                                          }
                                                                                                      
                                                                                                          defaultConfig {
                                                                                                              // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
                                                                                                              applicationId "*********"
                                                                                                              minSdkVersion 30
                                                                                                              targetSdkVersion 30
                                                                                                              versionCode flutterVersionCode.toInteger()
                                                                                                              versionName flutterVersionName
                                                                                                              testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
                                                                                                          }
                                                                                                      
                                                                                                      
                                                                                                      
                                                                                                          signingConfigs {
                                                                                                              release {
                                                                                                                  keyAlias keystoreProperties['keyAlias']
                                                                                                                  keyPassword keystoreProperties['keyPassword']
                                                                                                                  storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
                                                                                                                  storePassword keystoreProperties['storePassword']
                                                                                                              }
                                                                                                          }
                                                                                                          buildTypes {
                                                                                                              release {
                                                                                                                  signingConfig signingConfigs.release
                                                                                                              }
                                                                                                          }
                                                                                                      
                                                                                                      }
                                                                                                      
                                                                                                      flutter {
                                                                                                          source '../..'
                                                                                                      }
                                                                                                      
                                                                                                      dependencies {
                                                                                                          implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
                                                                                                          testImplementation 'junit:junit:4.12'
                                                                                                          androidTestImplementation 'androidx.test:runner:1.1.1'
                                                                                                          androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
                                                                                                          implementation 'com.google.firebase:firebase-analytics:17.2.2'
                                                                                                      }
                                                                                                      apply plugin: 'com.google.gms.google-services'
                                                                                                      

                                                                                                      Build output:

                                                                                                      BUILD FAILED in 8s
                                                                                                      [!] Your project requires a newer version of the Kotlin Gradle plugin.
                                                                                                          Find the latest version on https://kotlinlang.org/docs/gradle.html#plugin-and-versions, then update project/android/build.gradle:
                                                                                                          ext.kotlin_version = ''
                                                                                                      Exception: Gradle task assembleDebug failed with exit code 1
                                                                                                      

                                                                                                      ANSWER

                                                                                                      Answered 2022-Jan-30 at 21:52

                                                                                                      change build gradle to this :

                                                                                                      classpath 'com.android.tools.build:gradle:4.1.0'
                                                                                                      

                                                                                                      and gradle-wrapper to this :

                                                                                                      distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip
                                                                                                      

                                                                                                      Source https://stackoverflow.com/questions/70919127

                                                                                                      QUESTION

                                                                                                      ESlint - Error: Must use import to load ES Module
                                                                                                      Asked 2022-Mar-17 at 12:13

                                                                                                      I am currently setting up a boilerplate with React, Typescript, styled components, webpack etc. and I am getting an error when trying to run eslint:

                                                                                                      Error: Must use import to load ES Module

                                                                                                      Here is a more verbose version of the error:

                                                                                                      /Users/ben/Desktop/development projects/react-boilerplate-styled-context/src/api/api.ts
                                                                                                        0:0  error  Parsing error: Must use import to load ES Module: /Users/ben/Desktop/development projects/react-boilerplate-styled-context/node_modules/eslint/node_modules/eslint-scope/lib/definition.js
                                                                                                      require() of ES modules is not supported.
                                                                                                      require() of /Users/ben/Desktop/development projects/react-boilerplate-styled-context/node_modules/eslint/node_modules/eslint-scope/lib/definition.js from /Users/ben/Desktop/development projects/react-boilerplate-styled-context/node_modules/babel-eslint/lib/require-from-eslint.js is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
                                                                                                      Instead rename definition.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from /Users/ben/Desktop/development projects/react-boilerplate-styled-context/node_modules/eslint/node_modules/eslint-scope/package.json
                                                                                                      

                                                                                                      The error occurs in every single one of my .js and .ts/ .tsx files where I only use import or the file doesn't even have an import at all. I understand what the error is saying but I have no idea why it is being thrown when in fact I only use imports or even no imports at all in some files.

                                                                                                      Here is my package.json where I trigger the linter from using npm run lint:eslint:quiet:

                                                                                                      {
                                                                                                        "name": "my-react-boilerplate",
                                                                                                        "version": "1.0.0",
                                                                                                        "description": "",
                                                                                                        "main": "index.tsx",
                                                                                                        "directories": {
                                                                                                          "test": "test"
                                                                                                        },
                                                                                                        "engines": {
                                                                                                          "node": ">=14.0.0"
                                                                                                        },
                                                                                                        "type": "module",
                                                                                                        "scripts": {
                                                                                                          "build": "webpack --config webpack.prod.js",
                                                                                                          "dev": "webpack serve --config webpack.dev.js",
                                                                                                          "lint": "npm run typecheck && npm run lint:css && npm run lint:eslint:quiet",
                                                                                                          "lint:css": "stylelint './src/**/*.{js,ts,tsx}'",
                                                                                                          "lint:eslint:quiet": "eslint --ext .ts,.tsx,.js,.jsx  ./src --no-error-on-unmatched-pattern --quiet",
                                                                                                          "lint:eslint": "eslint --ext .ts,.tsx,.js,.jsx  ./src --no-error-on-unmatched-pattern",
                                                                                                          "lint:eslint:fix": "eslint --ext .ts,.tsx,.js,.jsx  ./src --no-error-on-unmatched-pattern --quiet --fix",
                                                                                                          "test": "cross-env NODE_ENV=test jest --coverage",
                                                                                                          "test:watch": "cross-env NODE_ENV=test jest --watchAll",
                                                                                                          "typecheck": "tsc --noEmit",
                                                                                                          "precommit": "npm run lint"
                                                                                                        },
                                                                                                        "lint-staged": {
                                                                                                          "*.{ts,tsx,js,jsx}": [
                                                                                                            "npm run lint:eslint:fix",
                                                                                                            "git add --force"
                                                                                                          ],
                                                                                                          "*.{md,json}": [
                                                                                                            "prettier --write",
                                                                                                            "git add --force"
                                                                                                          ]
                                                                                                        },
                                                                                                        "husky": {
                                                                                                          "hooks": {
                                                                                                            "pre-commit": "npx lint-staged && npm run typecheck"
                                                                                                          }
                                                                                                        },
                                                                                                        "resolutions": {
                                                                                                          "styled-components": "^5"
                                                                                                        },
                                                                                                        "author": "",
                                                                                                        "license": "ISC",
                                                                                                        "devDependencies": {
                                                                                                          "@babel/core": "^7.5.4",
                                                                                                          "@babel/plugin-proposal-class-properties": "^7.5.0",
                                                                                                          "@babel/preset-env": "^7.5.4",
                                                                                                          "@babel/preset-react": "^7.0.0",
                                                                                                          "@types/history": "^4.7.6",
                                                                                                          "@types/react": "^17.0.29",
                                                                                                          "@types/react-dom": "^17.0.9",
                                                                                                          "@types/react-router": "^5.1.17",
                                                                                                          "@types/react-router-dom": "^5.1.5",
                                                                                                          "@types/styled-components": "^5.1.15",
                                                                                                          "@typescript-eslint/eslint-plugin": "^5.0.0",
                                                                                                          "babel-cli": "^6.26.0",
                                                                                                          "babel-eslint": "^10.0.2",
                                                                                                          "babel-loader": "^8.0.0-beta.6",
                                                                                                          "babel-polyfill": "^6.26.0",
                                                                                                          "babel-preset-env": "^1.7.0",
                                                                                                          "babel-preset-react": "^6.24.1",
                                                                                                          "babel-preset-stage-2": "^6.24.1",
                                                                                                          "clean-webpack-plugin": "^4.0.0",
                                                                                                          "dotenv-webpack": "^7.0.3",
                                                                                                          "error-overlay-webpack-plugin": "^1.0.0",
                                                                                                          "eslint": "^8.0.0",
                                                                                                          "eslint-config-airbnb": "^18.2.0",
                                                                                                          "eslint-config-prettier": "^8.3.0",
                                                                                                          "eslint-config-with-prettier": "^6.0.0",
                                                                                                          "eslint-plugin-compat": "^3.3.0",
                                                                                                          "eslint-plugin-import": "^2.25.2",
                                                                                                          "eslint-plugin-jsx-a11y": "^6.2.3",
                                                                                                          "eslint-plugin-prettier": "^4.0.0",
                                                                                                          "eslint-plugin-react": "^7.14.2",
                                                                                                          "eslint-plugin-react-hooks": "^4.2.0",
                                                                                                          "extract-text-webpack-plugin": "^3.0.2",
                                                                                                          "file-loader": "^6.2.0",
                                                                                                          "html-webpack-plugin": "^5.3.2",
                                                                                                          "husky": "^7.0.2",
                                                                                                          "prettier": "^2.4.1",
                                                                                                          "raw-loader": "^4.0.2",
                                                                                                          "style-loader": "^3.3.0",
                                                                                                          "stylelint": "^13.13.1",
                                                                                                          "stylelint-config-recommended": "^5.0.0",
                                                                                                          "stylelint-config-styled-components": "^0.1.1",
                                                                                                          "stylelint-processor-styled-components": "^1.10.0",
                                                                                                          "ts-loader": "^9.2.6",
                                                                                                          "tslint": "^6.1.3",
                                                                                                          "typescript": "^4.4.4",
                                                                                                          "url-loader": "^4.1.1",
                                                                                                          "webpack": "^5.58.2",
                                                                                                          "webpack-cli": "^4.2.0",
                                                                                                          "webpack-dev-server": "^4.3.1",
                                                                                                          "webpack-merge": "^5.3.0"
                                                                                                        },
                                                                                                        "dependencies": {
                                                                                                          "history": "^4.10.0",
                                                                                                          "process": "^0.11.10",
                                                                                                          "react": "^17.0.1",
                                                                                                          "react-dom": "^17.0.1",
                                                                                                          "react-router-dom": "^5.2.0",
                                                                                                          "styled-components": "^5.2.1"
                                                                                                        }
                                                                                                      }
                                                                                                      

                                                                                                      Here is my .eslintrc file:

                                                                                                      {
                                                                                                        "extends": ["airbnb", "prettier"],
                                                                                                        "parser": "babel-eslint",
                                                                                                        "plugins": ["prettier", "@typescript-eslint"],
                                                                                                        "parserOptions": {
                                                                                                          "ecmaVersion": 8,
                                                                                                          "ecmaFeatures": {
                                                                                                            "experimentalObjectRestSpread": true,
                                                                                                            "impliedStrict": true,
                                                                                                            "classes": true
                                                                                                          }
                                                                                                        },
                                                                                                        "env": {
                                                                                                          "browser": true,
                                                                                                          "node": true,
                                                                                                          "jest": true
                                                                                                        },
                                                                                                        "rules": {
                                                                                                          "arrow-body-style": ["error", "as-needed"],
                                                                                                          "class-methods-use-this": 0,
                                                                                                          "react/jsx-filename-extension": 0,
                                                                                                          "global-require": 0,
                                                                                                          "react/destructuring-assignment": 0,
                                                                                                          "import/named": 2,
                                                                                                          "linebreak-style": 0,
                                                                                                          "import/no-dynamic-require": 0,
                                                                                                          "import/no-named-as-default": 0,
                                                                                                          "import/no-unresolved": 2,
                                                                                                          "import/prefer-default-export": 0,
                                                                                                          "semi": [2, "always"],
                                                                                                          "max-len": [
                                                                                                            "error",
                                                                                                            {
                                                                                                              "code": 80,
                                                                                                              "ignoreUrls": true,
                                                                                                              "ignoreComments": true,
                                                                                                              "ignoreStrings": true,
                                                                                                              "ignoreTemplateLiterals": true
                                                                                                            }
                                                                                                          ],
                                                                                                          "new-cap": [
                                                                                                            2,
                                                                                                            {
                                                                                                              "capIsNew": false,
                                                                                                              "newIsCap": true
                                                                                                            }
                                                                                                          ],
                                                                                                          "no-param-reassign": 0,
                                                                                                          "no-shadow": 0,
                                                                                                          "no-tabs": 2,
                                                                                                          "no-underscore-dangle": 0,
                                                                                                          "react/forbid-prop-types": [
                                                                                                            "error",
                                                                                                            {
                                                                                                              "forbid": ["any"]
                                                                                                            }
                                                                                                          ],
                                                                                                          "import/no-extraneous-dependencies": ["error", { "devDependencies": true }],
                                                                                                          "react/jsx-no-bind": [
                                                                                                            "error",
                                                                                                            {
                                                                                                              "ignoreRefs": true,
                                                                                                              "allowArrowFunctions": true,
                                                                                                              "allowBind": false
                                                                                                            }
                                                                                                          ],
                                                                                                          "react/no-unknown-property": [
                                                                                                            2,
                                                                                                            {
                                                                                                              "ignore": ["itemscope", "itemtype", "itemprop"]
                                                                                                            }
                                                                                                          ]
                                                                                                        }
                                                                                                      }
                                                                                                      

                                                                                                      And i'm not sure if relevant but also my tsconfig.eslint.json file:

                                                                                                      {
                                                                                                        "extends": "./tsconfig.json",
                                                                                                        "include": ["./src/**/*.ts", "./src/**/*.tsx", "./src/**/*.js"],
                                                                                                        "exclude": ["node_modules/**", "build/**", "coverage/**"]
                                                                                                      }
                                                                                                      

                                                                                                      Not sure if anyone has come across this before? Googling the error does not present any useful forums or raised bugs, most of them just state not to use require in your files which I am not.

                                                                                                      ANSWER

                                                                                                      Answered 2022-Mar-15 at 16:08

                                                                                                      I think the problem is that you are trying to use the deprecated babel-eslint parser, last updated a year ago, which looks like it doesn't support ES6 modules. Updating to the latest parser seems to work, at least for simple linting.

                                                                                                      So, do this:

                                                                                                      • In package.json, update the line "babel-eslint": "^10.0.2", to "@babel/eslint-parser": "^7.5.4",. This works with the code above but it may be better to use the latest version, which at the time of writing is 7.16.3.
                                                                                                      • Run npm i from a terminal/command prompt in the folder
                                                                                                      • In .eslintrc, update the parser line "parser": "babel-eslint", to "parser": "@babel/eslint-parser",
                                                                                                      • In .eslintrc, add "requireConfigFile": false, to the parserOptions section (underneath "ecmaVersion": 8,) (I needed this or babel was looking for config files I don't have)
                                                                                                      • Run the command to lint a file

                                                                                                      Then, for me with just your two configuration files, the error goes away and I get appropriate linting errors.

                                                                                                      Source https://stackoverflow.com/questions/69554485

                                                                                                      QUESTION

                                                                                                      Switch' is not exported from 'react-router-dom'
                                                                                                      Asked 2022-Mar-01 at 09:07

                                                                                                      In package.json file react-router-dom dependencies added. App component wrapped by BrowswerRouter , but when I wrap route by switch it says the following error Switch' is not exported from 'react-router-dom'. I deleted the package.json.lock ,node modules, installed npm again and npm install @babel/core --save. Still not working. I successfully wasted 6 hour for this. Can you please help me to fix this? why it's not importing?

                                                                                                      Index.js

                                                                                                      import {BrowserRouter} from 'react-router-dom';
                                                                                                      
                                                                                                      ReactDOM.render(
                                                                                                        
                                                                                                           
                                                                                                        ,
                                                                                                        document.getElementById('root')
                                                                                                      );
                                                                                                      

                                                                                                      App.js:

                                                                                                       import logo from './logo.svg';
                                                                                                      import './App.css';
                                                                                                      import React from 'react';
                                                                                                      import {Switch,Route,Link} from 'react-router-dom';
                                                                                                      import Home from './Home';
                                                                                                      class App extends React.Component {
                                                                                                        componentDidMount(){
                                                                                                          alert('mounting');
                                                                                                        }
                                                                                                        componentDidUpdate(){
                                                                                                          alert('updated');
                                                                                                        }
                                                                                                       render(){
                                                                                                        return (
                                                                                                          
                                                                                                          
                                                                                                           
                                                                                                          
                                                                                                            Home
                                                                                                          
                                                                                                      
                                                                                                          
                                                                                                      
                                                                                                          
                                                                                                            
                                                                                                              
                                                                                                            
                                                                                                          
                                                                                                       
                                                                                                        
                                                                                                       
                                                                                                      );
                                                                                                       }
                                                                                                      }
                                                                                                      
                                                                                                      export default App;
                                                                                                      
                                                                                                      import React from 'react';
                                                                                                      
                                                                                                          const Home = () => {
                                                                                                          return Home;
                                                                                                        };
                                                                                                        
                                                                                                        export default Home;
                                                                                                      

                                                                                                      package.json

                                                                                                      "dependencies": {
                                                                                                          "@babel/core": "^7.16.0",
                                                                                                          "@testing-library/jest-dom": "^5.11.4",
                                                                                                          "@testing-library/react": "^11.1.0",
                                                                                                          "@testing-library/user-event": "^12.1.10",
                                                                                                          "react": "^17.0.2",
                                                                                                          "react-dom": "^17.0.2",
                                                                                                          "react-router": "^6.0.0",
                                                                                                          "react-router-dom": "^6.0.0",
                                                                                                          "react-scripts": "4.0.3",
                                                                                                          "web-vitals": "^1.0.1"
                                                                                                        },
                                                                                                      

                                                                                                      ANSWER

                                                                                                      Answered 2021-Nov-04 at 18:10
                                                                                                      Using Routes instead of Switch in react-router v6

                                                                                                      You are using react-router-dom version 6, which replaced Switch with the Routes component

                                                                                                      import {
                                                                                                        BrowserRouter,
                                                                                                        Routes, // instead of "Switch"
                                                                                                        Route,
                                                                                                      } from "react-router-dom";
                                                                                                      
                                                                                                      // ...
                                                                                                      
                                                                                                          
                                                                                                            
                                                                                                              }>
                                                                                                                
                                                                                                              
                                                                                                            
                                                                                                          
                                                                                                      

                                                                                                      Note that you now also pass your component as the element prop instead of using children.

                                                                                                      Source https://stackoverflow.com/questions/69843615

                                                                                                      QUESTION

                                                                                                      throwError(error) is now deprecated, but there is no new Error(HttpErrorResponse)
                                                                                                      Asked 2022-Mar-01 at 00:42

                                                                                                      Apparently throwError(error) is now deprecated. The IntelliSense of VS Code suggests throwError(() => new Error('error'). new Error(...) accepts only strings. What's the correct way to replace it without breaking my HttpErrorHandlerService ?

                                                                                                      http-error.interceptor.ts
                                                                                                      import { Injectable } from '@angular/core';
                                                                                                      import {
                                                                                                        HttpEvent,
                                                                                                        HttpInterceptor,
                                                                                                        HttpHandler,
                                                                                                        HttpRequest,
                                                                                                        HttpErrorResponse,
                                                                                                        HttpResponse,
                                                                                                        HttpHeaders
                                                                                                      } from '@angular/common/http';
                                                                                                      import { Observable, EMPTY, finalize, catchError, timeout, map, throwError } from 'rxjs';
                                                                                                      
                                                                                                      import { HttpErrorHandlerService } from '@core/services';
                                                                                                      
                                                                                                      @Injectable()
                                                                                                      export class HttpErrorInterceptor implements HttpInterceptor {
                                                                                                        private readonly APP_XHR_TIMEOUT = 6000;
                                                                                                      
                                                                                                        constructor(private errorHandlerService: HttpErrorHandlerService) {}
                                                                                                      
                                                                                                        intercept(request: HttpRequest, next: HttpHandler): Observable> {
                                                                                                          return next.handle(this.performRequest(request)).pipe(
                                                                                                            timeout(this.APP_XHR_TIMEOUT),
                                                                                                            map((event: HttpEvent) => this.handleSuccessfulResponse(event)),
                                                                                                            catchError((error: HttpErrorResponse) => this.processRequestError(error, request, next)),
                                                                                                            finalize(this.handleRequestCompleted.bind(this))
                                                                                                          );
                                                                                                        }
                                                                                                      
                                                                                                        private performRequest(request: HttpRequest): HttpRequest {
                                                                                                          let headers: HttpHeaders = request.headers;
                                                                                                          //headers = headers.set('MyCustomHeaderKey', `MyCustomHeaderValue`);
                                                                                                          return request.clone({ headers });
                                                                                                        }
                                                                                                      
                                                                                                        private handleSuccessfulResponse(event: HttpEvent): HttpEvent {
                                                                                                          if (event instanceof HttpResponse) {
                                                                                                            event = event.clone({ body: event.body.response });
                                                                                                          }
                                                                                                          return event;
                                                                                                        }
                                                                                                      
                                                                                                        private processRequestError(
                                                                                                          error: HttpErrorResponse,
                                                                                                          request: HttpRequest,
                                                                                                          next: HttpHandler
                                                                                                        ): Observable> {
                                                                                                          console.log('http error response');
                                                                                                      
                                                                                                          if ([401].includes(error.status)) {
                                                                                                            return throwError(error);
                                                                                                          }
                                                                                                      
                                                                                                          this.errorHandlerService.handle(error);
                                                                                                      
                                                                                                          return throwError(error);
                                                                                                        }
                                                                                                      
                                                                                                        private handleRequestCompleted(): void {
                                                                                                          // console.log(`Request finished`);
                                                                                                        }
                                                                                                      }
                                                                                                      
                                                                                                      import { Injectable } from '@angular/core';
                                                                                                      import { HttpErrorResponse } from '@angular/common/http';
                                                                                                      
                                                                                                      import { MessageService } from 'primeng/api';
                                                                                                      import { TimeoutError } from 'rxjs';
                                                                                                      
                                                                                                      /**
                                                                                                       * Shows a user-friendly error message when a HTTP request fails.
                                                                                                       */
                                                                                                      @Injectable({
                                                                                                        providedIn: 'root'
                                                                                                      })
                                                                                                      export class HttpErrorHandlerService {
                                                                                                        constructor(private messageService: MessageService) {}
                                                                                                      
                                                                                                        handle(error: Error | HttpErrorResponse) {
                                                                                                          if (error instanceof TimeoutError) {
                                                                                                            return this.openDialog('error', `Няма връзка до сървъра.`);
                                                                                                          }
                                                                                                      
                                                                                                          if (error instanceof HttpErrorResponse && error.error && error.error.message) {
                                                                                                            return this.openDialog('error', error.error.message);
                                                                                                          }
                                                                                                      
                                                                                                          if (error instanceof Error) {
                                                                                                            switch (error.message) {
                                                                                                              default:
                                                                                                                return this.openDialog('error', `An unknown error occurred`);
                                                                                                            }
                                                                                                          }
                                                                                                      
                                                                                                          // Generic HTTP errors
                                                                                                          switch (error.status) {
                                                                                                            case 400:
                                                                                                              switch (error.error) {
                                                                                                                case 'invalid_username_or_password':
                                                                                                                  return this.openDialog('error', 'Невалидно потребителско име или парола');
                                                                                                                default:
                                                                                                                  return this.openDialog('error', 'Bad request');
                                                                                                              }
                                                                                                      
                                                                                                            case 401:
                                                                                                              return this.openDialog('error', 'Ще трябва да се логнете отново');
                                                                                                      
                                                                                                            case 403:
                                                                                                              return this.openDialog('error', `You don't have the required permissions`);
                                                                                                      
                                                                                                            case 404:
                                                                                                              return this.openDialog('error', 'Resource not found');
                                                                                                      
                                                                                                            case 422:
                                                                                                              return this.openDialog('error', 'Invalid data provided');
                                                                                                      
                                                                                                            case 500:
                                                                                                            case 501:
                                                                                                            case 502:
                                                                                                            case 503:
                                                                                                              return this.openDialog('error', 'An internal server error occurred');
                                                                                                      
                                                                                                            case -1:
                                                                                                              return this.openDialog(
                                                                                                                'error',
                                                                                                                'You appear to be offline. Please check your internet connection and try again.'
                                                                                                              );
                                                                                                      
                                                                                                            case 0:
                                                                                                              return this.openDialog('error', `CORS issue?`);
                                                                                                      
                                                                                                            default:
                                                                                                              return this.openDialog('error', `An unknown error occurred`);
                                                                                                          }
                                                                                                        }
                                                                                                      
                                                                                                        private openDialog(severity: string, message: string) {
                                                                                                          if (message?.trim()) {
                                                                                                            this.messageService.add({
                                                                                                              key: 'interceptor',
                                                                                                              severity: severity,
                                                                                                              summary: 'Информация',
                                                                                                              detail: message,
                                                                                                              life: 3000
                                                                                                            });
                                                                                                          }
                                                                                                        }
                                                                                                      }
                                                                                                      
                                                                                                      
                                                                                                      auth.interceptor.ts
                                                                                                      import { Injectable } from '@angular/core';
                                                                                                      import {
                                                                                                        HttpRequest,
                                                                                                        HttpHandler,
                                                                                                        HttpEvent,
                                                                                                        HttpInterceptor,
                                                                                                        HttpErrorResponse
                                                                                                      } from '@angular/common/http';
                                                                                                      import {
                                                                                                        BehaviorSubject,
                                                                                                        catchError,
                                                                                                        EMPTY,
                                                                                                        filter,
                                                                                                        finalize,
                                                                                                        Observable,
                                                                                                        switchMap,
                                                                                                        take,
                                                                                                        throwError
                                                                                                      } from 'rxjs';
                                                                                                      
                                                                                                      import { AuthService } from '@core/services';
                                                                                                      import { AuthResponse } from '@core/types';
                                                                                                      
                                                                                                      @Injectable()
                                                                                                      export class AuthInterceptor implements HttpInterceptor {
                                                                                                        private refreshTokenInProgress: boolean;
                                                                                                        private refreshToken$ = new BehaviorSubject(null);
                                                                                                      
                                                                                                        constructor(private authService: AuthService) {}
                                                                                                      
                                                                                                        intercept(request: HttpRequest, next: HttpHandler): Observable> {
                                                                                                          return next
                                                                                                            .handle(this.performRequest(request))
                                                                                                            .pipe(
                                                                                                              catchError((error: HttpErrorResponse) => this.processRequestError(error, request, next))
                                                                                                            );
                                                                                                        }
                                                                                                      
                                                                                                        private performRequest(request: HttpRequest): HttpRequest {
                                                                                                          const accessToken = this.authService.getAccessToken();
                                                                                                      
                                                                                                          let headers = request.headers;
                                                                                                          if (accessToken) {
                                                                                                            headers = headers.set('Authorization', `Bearer ${accessToken}`);
                                                                                                          }
                                                                                                      
                                                                                                          return request.clone({ headers });
                                                                                                        }
                                                                                                      
                                                                                                        private processRequestError(
                                                                                                          error: HttpErrorResponse,
                                                                                                          request: HttpRequest,
                                                                                                          next: HttpHandler
                                                                                                        ): Observable> {
                                                                                                          console.log('auth interceptor called');
                                                                                                      
                                                                                                          if (
                                                                                                            error instanceof HttpErrorResponse &&
                                                                                                            error.status === 401 &&
                                                                                                            this.authService.isSignedIn()
                                                                                                          ) {
                                                                                                            return this.refreshToken(request, next);
                                                                                                          }
                                                                                                      
                                                                                                          return throwError(error);
                                                                                                        }
                                                                                                      
                                                                                                        private refreshToken(request: HttpRequest, next: HttpHandler): Observable> {
                                                                                                          console.log('refresh token in auth.interceptor called');
                                                                                                      
                                                                                                          // in case the page consists of more than one requests
                                                                                                          if (!this.refreshTokenInProgress) {
                                                                                                            this.refreshToken$.next(null);
                                                                                                            this.refreshTokenInProgress = true;
                                                                                                      
                                                                                                            return this.authService.refreshToken().pipe(
                                                                                                              switchMap((response) => {
                                                                                                                if (response) {
                                                                                                                  this.refreshToken$.next(response);
                                                                                                                  return next.handle(this.performRequest(request));
                                                                                                                }
                                                                                                      
                                                                                                                this.authService.signOut();
                                                                                                                return throwError(() => new Error("RefreshTokenFailed"));
                                                                                                              }),
                                                                                                              catchError((error) => {
                                                                                                                this.authService.signOut();
                                                                                                                return throwError(error);
                                                                                                              }),
                                                                                                              finalize(() => (this.refreshTokenInProgress = false))
                                                                                                            );
                                                                                                          } else {
                                                                                                            // wait while getting new token
                                                                                                            return this.refreshToken$.pipe(
                                                                                                              filter((result) => result !== null),
                                                                                                              take(1),
                                                                                                              switchMap(() => next.handle(this.performRequest(request)))
                                                                                                            );
                                                                                                          }
                                                                                                        }
                                                                                                      }
                                                                                                      
                                                                                                      

                                                                                                      ANSWER

                                                                                                      Answered 2021-Aug-04 at 19:08

                                                                                                      Instead of this:

                                                                                                          catchError((error) => {
                                                                                                            this.authService.signOut();
                                                                                                            return throwError(error);
                                                                                                          }),
                                                                                                      

                                                                                                      You could try this:

                                                                                                          catchError((error) => {
                                                                                                            this.authService.signOut();
                                                                                                            return throwError(() => error);
                                                                                                          }),
                                                                                                      

                                                                                                      I wasn't able to test it thoroughly, but a simple attempt seemed to work.

                                                                                                      This was my simple test (using RxJS v7.2):

                                                                                                      Service

                                                                                                        getProducts(): Observable {
                                                                                                          return this.http.get(this.productUrl)
                                                                                                            .pipe(
                                                                                                              tap(data => console.log('All: ', JSON.stringify(data))),
                                                                                                              catchError(this.handleError)
                                                                                                            );
                                                                                                        }
                                                                                                      
                                                                                                        private handleError(err: HttpErrorResponse): Observable {
                                                                                                          // just a test ... more could would go here
                                                                                                          return throwError(() => err);
                                                                                                        }
                                                                                                      

                                                                                                      Notice that err here is of type HttpErrorResponse.

                                                                                                      Component

                                                                                                        ngOnInit(): void {
                                                                                                          this.sub = this.productService.getProducts().subscribe({
                                                                                                            next: products => {
                                                                                                              this.products = products;
                                                                                                              this.filteredProducts = this.products;
                                                                                                            },
                                                                                                            error: err => this.errorMessage = err.message
                                                                                                          });
                                                                                                        }
                                                                                                      

                                                                                                      Here I was able to retrieve the message property from the error response and display it in my UI.

                                                                                                      Let me know if this works for you.

                                                                                                      Source https://stackoverflow.com/questions/68655492

                                                                                                      QUESTION

                                                                                                      How to use appsettings.json in Asp.net core 6 Program.cs file
                                                                                                      Asked 2022-Feb-25 at 21:39

                                                                                                      I'm trying to access appsettings.json in my Asp.net core v6 application Program.cs file, but in this version of .Net the Startup class and Program class are merged together and the using and another statements are simplified and removed from Program.cs. In this situation, How to access IConfiguration or how to use dependency injection for example ?

                                                                                                      Edited : Here is my default Program.cs that Asp.net 6 created for me

                                                                                                      var builder = WebApplication.CreateBuilder(args);
                                                                                                      // Add services to the container.
                                                                                                      builder.Services.AddControllers();
                                                                                                      builder.Services.AddStackExchangeRedisCache(options =>
                                                                                                      {
                                                                                                          options.Configuration = "localhost:6379";
                                                                                                      });
                                                                                                      
                                                                                                      builder.Services.AddSwaggerGen(c =>
                                                                                                      {
                                                                                                          c.SwaggerDoc("v1", new() { Title = "BasketAPI", Version = "v1" });
                                                                                                      });
                                                                                                      var app = builder.Build();
                                                                                                      // Configure the HTTP request pipeline.
                                                                                                      if (app.Environment.IsDevelopment())
                                                                                                      {
                                                                                                          app.UseSwagger();
                                                                                                          app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "BasketAPI v1"));
                                                                                                      }
                                                                                                      app.UseHttpsRedirection();
                                                                                                      app.UseAuthorization();
                                                                                                      app.MapControllers();
                                                                                                      app.Run();
                                                                                                      

                                                                                                      For example , I want to use appsettings.json instead of hard typed connectionstring in this line :

                                                                                                      options.Configuration = "localhost:6379";
                                                                                                      

                                                                                                      ANSWER

                                                                                                      Answered 2021-Sep-30 at 11:13

                                                                                                      Assuming an appsettings.json

                                                                                                      {
                                                                                                          "RedisCacheOptions" : {
                                                                                                              "Configuration": "localhost:6379"
                                                                                                          }
                                                                                                      }
                                                                                                      

                                                                                                      There is nothing stopping you from building a configuration object to extract the desired settings.

                                                                                                      IConfiguration configuration = new ConfigurationBuilder()
                                                                                                                                  .AddJsonFile("appsettings.json")
                                                                                                                                  .Build();
                                                                                                      
                                                                                                      var builder = WebApplication.CreateBuilder(args);
                                                                                                      // Add services to the container.
                                                                                                      builder.Services.AddControllers();
                                                                                                      builder.Services.AddStackExchangeRedisCache(options => {
                                                                                                          options.Configuration = configuration["RedisCacheOptions:Configuration"];
                                                                                                      });
                                                                                                      
                                                                                                      //...
                                                                                                      

                                                                                                      Source https://stackoverflow.com/questions/69390676

                                                                                                      QUESTION

                                                                                                      AttributeError: Can't get attribute 'new_block' on
                                                                                                      Asked 2022-Feb-25 at 13:18

                                                                                                      I was using pyspark on AWS EMR (4 r5.xlarge as 4 workers, each has one executor and 4 cores), and I got AttributeError: Can't get attribute 'new_block' on . Below is a snippet of the code that threw this error:

                                                                                                      search =  SearchEngine(db_file_dir = "/tmp/db")
                                                                                                      conn = sqlite3.connect("/tmp/db/simple_db.sqlite")
                                                                                                      pdf_ = pd.read_sql_query('''select  zipcode, lat, lng, 
                                                                                                                              bounds_west, bounds_east, bounds_north, bounds_south from 
                                                                                                                              simple_zipcode''',conn)
                                                                                                      brd_pdf = spark.sparkContext.broadcast(pdf_) 
                                                                                                      conn.close()
                                                                                                      
                                                                                                      
                                                                                                      @udf('string')
                                                                                                      def get_zip_b(lat, lng):
                                                                                                          pdf = brd_pdf.value 
                                                                                                          out = pdf[(np.array(pdf["bounds_north"]) >= lat) & 
                                                                                                                    (np.array(pdf["bounds_south"]) <= lat) & 
                                                                                                                    (np.array(pdf['bounds_west']) <= lng) & 
                                                                                                                    (np.array(pdf['bounds_east']) >= lng) ]
                                                                                                          if len(out):
                                                                                                              min_index = np.argmin( (np.array(out["lat"]) - lat)**2 + (np.array(out["lng"]) - lng)**2)
                                                                                                              zip_ = str(out["zipcode"].iloc[min_index])
                                                                                                          else:
                                                                                                              zip_ = 'bad'
                                                                                                          return zip_
                                                                                                      
                                                                                                      df = df.withColumn('zipcode', get_zip_b(col("latitude"),col("longitude")))
                                                                                                      

                                                                                                      Below is the traceback, where line 102, in get_zip_b refers to pdf = brd_pdf.value:

                                                                                                      21/08/02 06:18:19 WARN TaskSetManager: Lost task 12.0 in stage 7.0 (TID 1814, ip-10-22-17-94.pclc0.merkle.local, executor 6): org.apache.spark.api.python.PythonException: Traceback (most recent call last):
                                                                                                        File "/mnt/yarn/usercache/hadoop/appcache/application_1627867699893_0001/container_1627867699893_0001_01_000009/pyspark.zip/pyspark/worker.py", line 605, in main
                                                                                                          process()
                                                                                                        File "/mnt/yarn/usercache/hadoop/appcache/application_1627867699893_0001/container_1627867699893_0001_01_000009/pyspark.zip/pyspark/worker.py", line 597, in process
                                                                                                          serializer.dump_stream(out_iter, outfile)
                                                                                                        File "/mnt/yarn/usercache/hadoop/appcache/application_1627867699893_0001/container_1627867699893_0001_01_000009/pyspark.zip/pyspark/serializers.py", line 223, in dump_stream
                                                                                                          self.serializer.dump_stream(self._batched(iterator), stream)
                                                                                                        File "/mnt/yarn/usercache/hadoop/appcache/application_1627867699893_0001/container_1627867699893_0001_01_000009/pyspark.zip/pyspark/serializers.py", line 141, in dump_stream
                                                                                                          for obj in iterator:
                                                                                                        File "/mnt/yarn/usercache/hadoop/appcache/application_1627867699893_0001/container_1627867699893_0001_01_000009/pyspark.zip/pyspark/serializers.py", line 212, in _batched
                                                                                                          for item in iterator:
                                                                                                        File "/mnt/yarn/usercache/hadoop/appcache/application_1627867699893_0001/container_1627867699893_0001_01_000009/pyspark.zip/pyspark/worker.py", line 450, in mapper
                                                                                                          result = tuple(f(*[a[o] for o in arg_offsets]) for (arg_offsets, f) in udfs)
                                                                                                        File "/mnt/yarn/usercache/hadoop/appcache/application_1627867699893_0001/container_1627867699893_0001_01_000009/pyspark.zip/pyspark/worker.py", line 450, in 
                                                                                                          result = tuple(f(*[a[o] for o in arg_offsets]) for (arg_offsets, f) in udfs)
                                                                                                        File "/mnt/yarn/usercache/hadoop/appcache/application_1627867699893_0001/container_1627867699893_0001_01_000009/pyspark.zip/pyspark/worker.py", line 90, in 
                                                                                                          return lambda *a: f(*a)
                                                                                                        File "/mnt/yarn/usercache/hadoop/appcache/application_1627867699893_0001/container_1627867699893_0001_01_000009/pyspark.zip/pyspark/util.py", line 121, in wrapper
                                                                                                          return f(*args, **kwargs)
                                                                                                        File "/mnt/var/lib/hadoop/steps/s-1IBFS0SYWA19Z/Mobile_ID_process_center.py", line 102, in get_zip_b
                                                                                                        File "/mnt/yarn/usercache/hadoop/appcache/application_1627867699893_0001/container_1627867699893_0001_01_000009/pyspark.zip/pyspark/broadcast.py", line 146, in value
                                                                                                          self._value = self.load_from_path(self._path)
                                                                                                        File "/mnt/yarn/usercache/hadoop/appcache/application_1627867699893_0001/container_1627867699893_0001_01_000009/pyspark.zip/pyspark/broadcast.py", line 123, in load_from_path
                                                                                                          return self.load(f)
                                                                                                        File "/mnt/yarn/usercache/hadoop/appcache/application_1627867699893_0001/container_1627867699893_0001_01_000009/pyspark.zip/pyspark/broadcast.py", line 129, in load
                                                                                                          return pickle.load(file)
                                                                                                      AttributeError: Can't get attribute 'new_block' on 
                                                                                                      

                                                                                                      Some observations and thought process:

                                                                                                      1, After doing some search online, the AttributeError in pyspark seems to be caused by mismatched pandas versions between driver and workers?

                                                                                                      2, But I ran the same code on two different datasets, one worked without any errors but the other didn't, which seems very strange and undeterministic, and it seems like the errors may not be caused by mismatched pandas versions. Otherwise, neither two datasets would succeed.

                                                                                                      3, I then ran the same code on the successful dataset again, but this time with different spark configurations: setting spark.driver.memory from 2048M to 4192m, and it threw AttributeError.

                                                                                                      4, In conclusion, I think the AttributeError has something to do with driver. But I can't tell how they are related from the error message, and how to fix it: AttributeError: Can't get attribute 'new_block' on

                                                                                                      ANSWER

                                                                                                      Answered 2021-Aug-26 at 14:53

                                                                                                      I had the same error using pandas 1.3.2 in the server while 1.2 in my client. Downgrading pandas to 1.2 solved the problem.

                                                                                                      Source https://stackoverflow.com/questions/68625748

                                                                                                      QUESTION

                                                                                                      android:exported needs to be explicitly specified for . Apps targeting Android 12 and higher are required to specify
                                                                                                      Asked 2022-Feb-23 at 14:13

                                                                                                      After upgrading to android 12, the application is not compiling. It shows

                                                                                                      "Manifest merger failed with multiple errors, see logs"

                                                                                                      Error showing in Merged manifest:

                                                                                                      Merging Errors: Error: android:exported needs to be explicitly specified for . Apps targeting Android 12 and higher are required to specify an explicit value for android:exported when the corresponding component has an intent filter defined. See https://developer.android.com/guide/topics/manifest/activity-element#exported for details. main manifest (this file)

                                                                                                      I have set all the activity with android:exported="false". But it is still showing this issue.

                                                                                                      My manifest file:

                                                                                                      
                                                                                                      
                                                                                                      
                                                                                                          
                                                                                                      
                                                                                                          
                                                                                                          
                                                                                                          
                                                                                                          
                                                                                                          
                                                                                                          
                                                                                                          
                                                                                                          
                                                                                                          
                                                                                                          
                                                                                                          
                                                                                                          
                                                                                                          
                                                                                                          
                                                                                                          
                                                                                                          
                                                                                                      
                                                                                                          
                                                                                                          
                                                                                                          
                                                                                                      
                                                                                                          
                                                                                                          
                                                                                                          
                                                                                                          
                                                                                                          
                                                                                                          
                                                                                                      
                                                                                                          
                                                                                                          
                                                                                                          
                                                                                                      
                                                                                                          
                                                                                                              
                                                                                                              
                                                                                                              
                                                                                                              
                                                                                                              
                                                                                                              
                                                                                                              
                                                                                                              
                                                                                                              
                                                                                                      
                                                                                                              
                                                                                                      
                                                                                                              
                                                                                                                  
                                                                                                                      
                                                                                                                      
                                                                                                                      
                                                                                                                      
                                                                                                                  
                                                                                                              
                                                                                                      
                                                                                                              
                                                                                                              
                                                                                                              
                                                                                                              
                                                                                                              
                                                                                                                  
                                                                                                                      
                                                                                                      
                                                                                                                      
                                                                                                                  
                                                                                                              
                                                                                                              
                                                                                                              
                                                                                                              
                                                                                                                  
                                                                                                                      
                                                                                                      
                                                                                                                      
                                                                                                                      
                                                                                                      
                                                                                                                      
                                                                                                                  
                                                                                                                  
                                                                                                                      
                                                                                                      
                                                                                                                      
                                                                                                                      
                                                                                                      
                                                                                                                      
                                                                                                                      
                                                                                                                      
                                                                                                                      
                                                                                                                  
                                                                                                                  
                                                                                                                      
                                                                                                      
                                                                                                                      
                                                                                                      
                                                                                                                      
                                                                                                                      
                                                                                                                  
                                                                                                              
                                                                                                              
                                                                                                                  
                                                                                                                      
                                                                                                                  
                                                                                                              
                                                                                                              
                                                                                                                  
                                                                                                                      
                                                                                                      
                                                                                                                      
                                                                                                                  
                                                                                                              
                                                                                                              
                                                                                                              
                                                                                                              
                                                                                                              
                                                                                                                  
                                                                                                                      
                                                                                                      
                                                                                                                      
                                                                                                      
                                                                                                                      
                                                                                                                  
                                                                                                              
                                                                                                              
                                                                                                              
                                                                                                              
                                                                                                              
                                                                                                              
                                                                                                              
                                                                                                              
                                                                                                                  
                                                                                                                      
                                                                                                                      
                                                                                                      
                                                                                                                      
                                                                                                      
                                                                                                                      
                                                                                                                  
                                                                                                                  
                                                                                                                      
                                                                                                                      
                                                                                                      
                                                                                                                      
                                                                                                      
                                                                                                                      
                                                                                                                  
                                                                                                      
                                                                                                                  
                                                                                                                  
                                                                                                              
                                                                                                              
                                                                                                              
                                                                                                              
                                                                                                              
                                                                                                      
                                                                                                              
                                                                                                              
                                                                                                              
                                                                                                                  
                                                                                                                      
                                                                                                                  
                                                                                                              
                                                                                                              
                                                                                                      
                                                                                                              
                                                                                                                  
                                                                                                              
                                                                                                              
                                                                                                      
                                                                                                              
                                                                                                                  
                                                                                                                      
                                                                                                                  
                                                                                                              
                                                                                                              
                                                                                                              
                                                                                                              
                                                                                                          
                                                                                                      
                                                                                                      
                                                                                                      

                                                                                                      My second manifest file:

                                                                                                      
                                                                                                      
                                                                                                      
                                                                                                          
                                                                                                              
                                                                                                              
                                                                                                              
                                                                                                              
                                                                                                                  
                                                                                                                      
                                                                                                                      
                                                                                                      
                                                                                                                      
                                                                                                                      
                                                                                                                  
                                                                                                                  
                                                                                                                      
                                                                                                                      
                                                                                                      
                                                                                                                      
                                                                                                                      
                                                                                                                  
                                                                                                                  
                                                                                                                      
                                                                                                      
                                                                                                                      
                                                                                                                      
                                                                                                      
                                                                                                                      
                                                                                                                      
                                                                                                                      
                                                                                                                      
                                                                                                                      
                                                                                                                      
                                                                                                                      
                                                                                                                      
                                                                                                                      
                                                                                                                      
                                                                                                                  
                                                                                                                  
                                                                                                                      
                                                                                                      
                                                                                                                      
                                                                                                                      
                                                                                                      
                                                                                                                      
                                                                                                                      
                                                                                                                      
                                                                                                                      
                                                                                                                      
                                                                                                                      
                                                                                                                      
                                                                                                                      
                                                                                                                      
                                                                                                                      
                                                                                                                  
                                                                                                              
                                                                                                          
                                                                                                      
                                                                                                      
                                                                                                      

                                                                                                      My gradle file:

                                                                                                      import com.android.build.OutputFile
                                                                                                      
                                                                                                      // Top-level build file where you can add configuration options common to all
                                                                                                      // sub-projects/modules.
                                                                                                      buildscript {
                                                                                                          ext.kotlin_version = "1.5.21"
                                                                                                          repositories {
                                                                                                              google()
                                                                                                              mavenCentral()
                                                                                                              maven { url 'https://jitpack.io' }
                                                                                                              gradlePluginPortal()
                                                                                                          }
                                                                                                          dependencies {
                                                                                                              classpath 'com.android.tools.build:gradle:4.2.2'
                                                                                                              classpath 'com.google.gms:google-services:4.3.8'
                                                                                                              classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
                                                                                                          }
                                                                                                      }
                                                                                                      
                                                                                                      apply plugin: 'com.android.application'
                                                                                                      apply plugin: 'kotlin-android'
                                                                                                      apply plugin: 'kotlin-kapt'
                                                                                                      apply plugin: 'com.google.gms.google-services'
                                                                                                      
                                                                                                      repositories {
                                                                                                          google()
                                                                                                          mavenCentral()
                                                                                                          jcenter()
                                                                                                          maven { url 'https://jitpack.io' }
                                                                                                      }
                                                                                                      
                                                                                                      configurations {
                                                                                                          conversationsFreeCompatImplementation
                                                                                                      }
                                                                                                      
                                                                                                      dependencies {
                                                                                                          implementation 'androidx.viewpager:viewpager:1.0.0'
                                                                                                          implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
                                                                                                      
                                                                                                          implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
                                                                                                      
                                                                                                          implementation 'org.sufficientlysecure:openpgp-api:10.0'
                                                                                                          implementation 'com.theartofdev.edmodo:android-image-cropper:2.8.0'
                                                                                                          implementation 'androidx.appcompat:appcompat:1.3.1'
                                                                                                          implementation 'androidx.exifinterface:exifinterface:1.3.2'
                                                                                                          implementation 'androidx.cardview:cardview:1.0.0'
                                                                                                          implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
                                                                                                          implementation 'androidx.emoji:emoji:1.1.0'
                                                                                                          implementation 'com.google.android.material:material:1.4.0'
                                                                                                          conversationsFreeCompatImplementation 'androidx.emoji:emoji-bundled:1.1.0'
                                                                                                          implementation 'org.bouncycastle:bcmail-jdk15on:1.64'
                                                                                                          //zxing stopped supporting Java 7 so we have to stick with 3.3.3
                                                                                                          //https://github.com/zxing/zxing/issues/1170
                                                                                                          implementation 'com.google.zxing:core:3.4.1'
                                                                                                          implementation 'de.measite.minidns:minidns-hla:0.2.4'
                                                                                                          implementation 'me.leolin:ShortcutBadger:1.1.22@aar'
                                                                                                          implementation 'org.whispersystems:signal-protocol-java:2.8.1'
                                                                                                          implementation 'com.makeramen:roundedimageview:2.3.0'
                                                                                                          implementation "com.wefika:flowlayout:0.4.1"
                                                                                                          implementation 'net.ypresto.androidtranscoder:android-transcoder:0.3.0'
                                                                                                          implementation 'org.jxmpp:jxmpp-jid:1.0.1'
                                                                                                          implementation 'org.osmdroid:osmdroid-android:6.1.10'
                                                                                                          implementation 'org.hsluv:hsluv:0.2'
                                                                                                          implementation 'org.conscrypt:conscrypt-android:2.5.2'
                                                                                                          implementation 'me.drakeet.support:toastcompat:1.1.0'
                                                                                                          implementation "com.leinardi.android:speed-dial:3.2.0"
                                                                                                      
                                                                                                          implementation "com.squareup.retrofit2:retrofit:2.9.0"
                                                                                                          implementation "com.squareup.retrofit2:converter-gson:2.9.0"
                                                                                                          implementation "com.squareup.okhttp3:okhttp:5.0.0-alpha.2"
                                                                                                          implementation 'com.squareup.okhttp3:logging-interceptor:5.0.0-alpha.2'
                                                                                                      
                                                                                                          implementation 'com.google.guava:guava:30.1.1-android'
                                                                                                          implementation 'org.webrtc:google-webrtc:1.0.32006'
                                                                                                      
                                                                                                          // Lifecycle Helper
                                                                                                          implementation "androidx.activity:activity-ktx:1.3.0-rc02"
                                                                                                          implementation "androidx.fragment:fragment-ktx:1.3.6"
                                                                                                      
                                                                                                          //Navigation
                                                                                                          implementation 'androidx.navigation:navigation-fragment-ktx:2.3.5'
                                                                                                          implementation 'androidx.navigation:navigation-ui-ktx:2.3.5'
                                                                                                      
                                                                                                          //CardView
                                                                                                          implementation "androidx.cardview:cardview:1.0.0"
                                                                                                      
                                                                                                          //Country Code Picker
                                                                                                          implementation 'com.hbb20:ccp:2.5.3'
                                                                                                      
                                                                                                          //Firebase
                                                                                                          implementation 'com.google.firebase:firebase-bom:28.3.0'
                                                                                                          implementation 'com.google.firebase:firebase-auth-ktx:21.0.1'
                                                                                                          implementation 'androidx.browser:browser:1.3.0'
                                                                                                      
                                                                                                          //OTP view
                                                                                                          implementation 'com.github.mukeshsolanki:android-otpview-pinview:2.1.2'
                                                                                                      
                                                                                                          //Retrofit
                                                                                                          implementation 'com.squareup.retrofit2:retrofit:2.9.0'
                                                                                                          implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
                                                                                                      
                                                                                                          //Gson
                                                                                                          implementation 'com.google.code.gson:gson:2.8.7'
                                                                                                      
                                                                                                          //Multidex
                                                                                                          implementation 'androidx.multidex:multidex:2.0.1'
                                                                                                      
                                                                                                          //Round Image
                                                                                                          implementation 'de.hdodenhof:circleimageview:3.1.0'
                                                                                                      
                                                                                                          // Button with image and text
                                                                                                          implementation 'com.github.Omega-R:OmegaCenterIconButton:0.0.4@aar'
                                                                                                      
                                                                                                          //Razor pay
                                                                                                          implementation 'com.razorpay:checkout:1.6.10'
                                                                                                      
                                                                                                          //Mixpanel Tracking
                                                                                                          implementation 'com.mixpanel.android:mixpanel-android:5.9.1'
                                                                                                      
                                                                                                          //Loading screen
                                                                                                          implementation 'com.wang.avi:library:2.1.3'
                                                                                                      
                                                                                                          //Loading
                                                                                                          implementation 'com.wang.avi:library:2.1.3'
                                                                                                      
                                                                                                          //Form
                                                                                                          implementation 'com.quickbirdstudios:surveykit:1.1.0'
                                                                                                      }
                                                                                                      
                                                                                                      ext {
                                                                                                          travisBuild = System.getenv("TRAVIS") == "true"
                                                                                                          preDexEnabled = System.getProperty("pre-dex", "true")
                                                                                                          abiCodes = ['armeabi-v7a': 1, 'x86': 2, 'x86_64': 3, 'arm64-v8a': 4]
                                                                                                      }
                                                                                                      
                                                                                                      android {
                                                                                                          compileSdkVersion 31
                                                                                                      
                                                                                                          defaultConfig {
                                                                                                              minSdkVersion 24
                                                                                                              targetSdkVersion 31
                                                                                                              versionCode 44
                                                                                                              versionName "2.0.4"
                                                                                                              multiDexEnabled = true
                                                                                                              archivesBaseName += "-$versionName"
                                                                                                              applicationId "com.app.app"
                                                                                                              resValue "string", "applicationId", applicationId
                                                                                                              def appName = "app"
                                                                                                              resValue "string", "app_name", appName
                                                                                                              buildConfigField "String", "APP_NAME", "\"$appName\""
                                                                                                          }
                                                                                                      
                                                                                                          splits {
                                                                                                              abi {
                                                                                                                  universalApk true
                                                                                                                  enable true
                                                                                                              }
                                                                                                          }
                                                                                                      
                                                                                                          configurations {
                                                                                                              compile.exclude group: 'org.jetbrains' , module:'annotations'
                                                                                                          }
                                                                                                      
                                                                                                          dataBinding {
                                                                                                              enabled true
                                                                                                          }
                                                                                                      
                                                                                                          dexOptions {
                                                                                                              // Skip pre-dexing when running on Travis CI or when disabled via -Dpre-dex=false.
                                                                                                              preDexLibraries = preDexEnabled && !travisBuild
                                                                                                              jumboMode true
                                                                                                          }
                                                                                                      
                                                                                                          compileOptions {
                                                                                                              sourceCompatibility JavaVersion.VERSION_1_8
                                                                                                              targetCompatibility JavaVersion.VERSION_1_8
                                                                                                          }
                                                                                                      
                                                                                                          flavorDimensions("mode", "distribution", "emoji")
                                                                                                      
                                                                                                          productFlavors {
                                                                                                      
                                                                                                              conversations {
                                                                                                                  dimension "mode"
                                                                                                              }
                                                                                                              free {
                                                                                                                  dimension "distribution"
                                                                                                                  versionNameSuffix "+f"
                                                                                                              }
                                                                                                              compat {
                                                                                                                  dimension "emoji"
                                                                                                                  versionNameSuffix "c"
                                                                                                              }
                                                                                                          }
                                                                                                      
                                                                                                          sourceSets {
                                                                                                              conversationsFreeCompat {
                                                                                                                  java {
                                                                                                                      srcDir 'src/freeCompat/java'
                                                                                                                      srcDir 'src/conversationsFree/java'
                                                                                                                  }
                                                                                                              }
                                                                                                          }
                                                                                                      
                                                                                                          buildTypes {
                                                                                                              release {
                                                                                                                  shrinkResources true
                                                                                                                  minifyEnabled true
                                                                                                                  proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
                                                                                                                  versionNameSuffix "r"
                                                                                                              }
                                                                                                              debug {
                                                                                                                  shrinkResources true
                                                                                                                  minifyEnabled true
                                                                                                                  proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
                                                                                                                  versionNameSuffix "d"
                                                                                                              }
                                                                                                          }
                                                                                                      
                                                                                                      
                                                                                                          if (new File("signing.properties").exists()) {
                                                                                                              Properties props = new Properties()
                                                                                                              props.load(new FileInputStream(file("signing.properties")))
                                                                                                      
                                                                                                              signingConfigs {
                                                                                                                  release {
                                                                                                                      storeFile file(props['keystore'])
                                                                                                                      storePassword props['keystore.password']
                                                                                                                      keyAlias props['keystore.alias']
                                                                                                                      keyPassword props['keystore.password']
                                                                                                                  }
                                                                                                              }
                                                                                                              buildTypes.release.signingConfig = signingConfigs.release
                                                                                                          }
                                                                                                      
                                                                                                          lintOptions {
                                                                                                              disable 'MissingTranslation', 'InvalidPackage','AppCompatResource'
                                                                                                          }
                                                                                                      
                                                                                                          subprojects {
                                                                                                      
                                                                                                              afterEvaluate {
                                                                                                                  if (getPlugins().hasPlugin('android') ||
                                                                                                                          getPlugins().hasPlugin('android-library')) {
                                                                                                      
                                                                                                                      configure(android.lintOptions) {
                                                                                                                          disable 'AndroidGradlePluginVersion', 'MissingTranslation'
                                                                                                                      }
                                                                                                                  }
                                                                                                      
                                                                                                              }
                                                                                                          }
                                                                                                      
                                                                                                          packagingOptions {
                                                                                                              exclude 'META-INF/BCKEY.DSA'
                                                                                                              exclude 'META-INF/BCKEY.SF'
                                                                                                          }
                                                                                                      
                                                                                                          android.applicationVariants.all { variant ->
                                                                                                              variant.outputs.each { output ->
                                                                                                                  def baseAbiVersionCode = project.ext.abiCodes.get(output.getFilter(OutputFile.ABI))
                                                                                                                  if (baseAbiVersionCode != null) {
                                                                                                                      output.versionCodeOverride = (100 * variant.versionCode) + baseAbiVersionCode
                                                                                                                  }
                                                                                                              }
                                                                                                      
                                                                                                          }
                                                                                                      }
                                                                                                      

                                                                                                      ANSWER

                                                                                                      Answered 2021-Aug-04 at 09:18

                                                                                                      I'm not sure what you're using to code, but in order to set it in Android Studio, open the manifest of your project and under the "activity" section, put android:exported="true"(or false if that is what you prefer). I have attached an example.

                                                                                                      Source https://stackoverflow.com/questions/68554294

                                                                                                      Community Discussions, Code Snippets contain sources that include Stack Exchange Network

                                                                                                      Vulnerabilities

                                                                                                      No vulnerabilities reported

                                                                                                      Install core

                                                                                                      You can install using 'pip install core' or download it from GitHub, PyPI.
                                                                                                      You can use core like any standard Python library. You will need to make sure that you have a development environment consisting of a Python distribution including header files, a compiler, pip, and git installed. Make sure that your pip, setuptools, and wheel are up to date. When using pip it is generally recommended to install packages in a virtual environment to avoid changes to the system.

                                                                                                      Support

                                                                                                      For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .
                                                                                                      Find more information at:
                                                                                                      Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
                                                                                                      Find more libraries
                                                                                                      Explore Kits - Develop, implement, customize Projects, Custom Functions and Applications with kandi kits​
                                                                                                      Save this library and start creating your kit
                                                                                                      CLONE
                                                                                                    • HTTPS

                                                                                                      https://github.com/home-assistant/core.git

                                                                                                    • CLI

                                                                                                      gh repo clone home-assistant/core

                                                                                                    • sshUrl

                                                                                                      git@github.com:home-assistant/core.git

                                                                                                    • Share this Page

                                                                                                      share link

                                                                                                      Consider Popular Python Libraries

                                                                                                      public-apis

                                                                                                      by public-apis

                                                                                                      system-design-primer

                                                                                                      by donnemartin

                                                                                                      Python

                                                                                                      by TheAlgorithms

                                                                                                      Python-100-Days

                                                                                                      by jackfrued

                                                                                                      youtube-dl

                                                                                                      by ytdl-org

                                                                                                      Try Top Libraries by home-assistant

                                                                                                      home-assistant.io

                                                                                                      by home-assistantHTML

                                                                                                      operating-system

                                                                                                      by home-assistantShell

                                                                                                      frontend

                                                                                                      by home-assistantTypeScript

                                                                                                      Iconic

                                                                                                      by home-assistantSwift

                                                                                                      android

                                                                                                      by home-assistantKotlin

                                                                                                      Compare Python Libraries with Highest Support

                                                                                                      core

                                                                                                      by home-assistant

                                                                                                      youtube-dl

                                                                                                      by ytdl-org

                                                                                                      scikit-learn

                                                                                                      by scikit-learn

                                                                                                      models

                                                                                                      by tensorflow

                                                                                                      fastapi

                                                                                                      by tiangolo

                                                                                                      Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
                                                                                                      Find more libraries
                                                                                                      Explore Kits - Develop, implement, customize Projects, Custom Functions and Applications with kandi kits​
                                                                                                      Save this library and start creating your kit