Explore all Hardware open source software, libraries, packages, source code, cloud functions and APIs.

Explore Related Topics

Popular New Releases in Hardware

taichi

v1.0.0

gpu.js

Maintenance release

hashcat

hashcat v6.2.4

cupy

v10.3.1

EASTL

3.17.06

Popular Libraries in Hardware

taichi

by taichi-dev doticonc++doticon

star image 18670 doticonApache-2.0

Productive & portable high-performance programming in Python.

gpu.js

by gpujs doticonjavascriptdoticon

star image 13614 doticonMIT

GPU Accelerated JavaScript

hashcat

by hashcat doticoncdoticon

star image 10426 doticon

World's fastest and most advanced password recovery utility

perf-tools

by brendangregg doticonshelldoticon

star image 7549 doticonGPL-2.0

Performance analysis tools based on Linux perf_events (aka perf) and ftrace

qemu

by qemu doticoncdoticon

star image 6056 doticonNOASSERTION

Official QEMU mirror. Please see http://wiki.qemu.org/Contribute/SubmitAPatch for how to submit changes to QEMU. Pull Requests are ignored. Please only use release tarballs from the QEMU website.

cupy

by cupy doticonpythondoticon

star image 5918 doticonMIT

NumPy & SciPy for GPU

EASTL

by electronicarts doticonc++doticon

star image 5812 doticonBSD-3-Clause

EASTL stands for Electronic Arts Standard Template Library. It is an extensive and robust implementation that has an emphasis on high performance.

ethminer

by ethereum-mining doticonc++doticon

star image 5395 doticonGPL-3.0

Ethereum miner with OpenCL, CUDA and stratum support

polars

by pola-rs doticonrustdoticon

star image 5341 doticonMIT

Fast multi-threaded DataFrame library in Rust | Python | Node.js

Trending New libraries in Hardware

polars

by pola-rs doticonrustdoticon

star image 5341 doticonMIT

Fast multi-threaded DataFrame library in Rust | Python | Node.js

rust-gpu

by EmbarkStudios doticonrustdoticon

star image 4419 doticonNOASSERTION

🐉 Making Rust a first-class language and ecosystem for GPU shaders 🚧

MangoHud

by flightlessmango doticoncdoticon

star image 3482 doticonMIT

A Vulkan and OpenGL overlay for monitoring FPS, temperatures, CPU/GPU load and more. Discord: https://discordapp.com/invite/Gj5YmBb

vgpu_unlock

by DualCoder doticoncdoticon

star image 2587 doticonMIT

Unlock vGPU functionality for consumer grade GPUs.

FFmpeg-Builds

by BtbN doticonshelldoticon

star image 2521 doticonMIT

libcudacxx

by NVIDIA doticonc++doticon

star image 1953 doticonNOASSERTION

The C++ Standard Library for your entire system.

tiny-cuda-nn

by NVlabs doticonc++doticon

star image 1093 doticonNOASSERTION

Lightning fast C++/CUDA neural network framework

ZLUDA

by vosen doticonc++doticon

star image 977 doticonNOASSERTION

CUDA on Intel GPUs

nvitop

by XuehaiPan doticonpythondoticon

star image 784 doticonGPL-3.0

An interactive NVIDIA-GPU process viewer, the one-stop solution for GPU process management.

Top Authors in Hardware

1

NVIDIA

31 Libraries

star icon14035

2

intel

19 Libraries

star icon3063

3

ROCmSoftwarePlatform

11 Libraries

star icon621

4

komrad36

10 Libraries

star icon110

5

LLNL

10 Libraries

star icon555

6

rapidsai

9 Libraries

star icon6610

7

Azure

9 Libraries

star icon80

8

ROCm-Developer-Tools

9 Libraries

star icon3077

9

GPUOpen-LibrariesAndSDKs

8 Libraries

star icon1603

10

arrayfire

8 Libraries

star icon5138

1

31 Libraries

star icon14035

2

19 Libraries

star icon3063

3

11 Libraries

star icon621

4

10 Libraries

star icon110

5

10 Libraries

star icon555

6

9 Libraries

star icon6610

7

9 Libraries

star icon80

8

9 Libraries

star icon3077

9

8 Libraries

star icon1603

10

8 Libraries

star icon5138

Trending Kits in Hardware

SimpleCV is a computer vision library. Makers design it to simplify tasks such as image processing and machine learning.

It offers its image filters and enhancements. But it also works with other libraries for advanced features.

Here are 11 libraries used with SimpleCV for image filtering and enhancement:

  • opencv
  • numpy
  • dlib
  • scipy
  • pillow
  • ImageMagick
  • scikit-image
  • pycuda
  • CImg
  • pyopencl
  • mahotas

opencv:

  • SimpleCV relies on OpenCV for its image-processing operations.
  • OpenCV provides many image filters and enhancements. These include blurring, sharpening, edge detection, and more.
  • OpenCV optimized and implemented.

numpy:

  • NumPy provides efficient array operations, which are essential for many image-processing tasks.
  • SimpleCV relies on NumPy for handling image data.
  • NumPy does its array operations in optimized C and Fortran code. This leads to fast speeds.

dlib:

  • Dlib is an ML library that includes tools for image processing and computer vision.
  • SimpleCV can work with Dlib for some advanced image tasks. It can do face detection.
  • Dlib uses machine learning for many tasks. These include object detection, classification, and regression.

scipy:

  • SciPy integrates with NumPy, another fundamental library for numerical computing in Python.
  • SciPy offers many image-processing functions. They are for tasks like filtering, morphology, and geometric transformations.
  • SimpleCV utilizes SciPy for some of its advanced image-processing functionalities.

Pillow:

  • Pillow is a fork of the Python Imaging Library (PIL)
  • People use PIL for simple image tasks. It does things like resizing, cropping, and adjusting color.
  • SimpleCV integrates PIL for some of its image manipulation functions.

ImageMagick:

  • ImageMagick is a powerful tool for image editing and conversion.
  • ImageMagick supports batch processing and scripting.
  • SimpleCV can leverage ImageMagick for certain image-processing operations.

scikit-image:

  • Scikit-Picture presents a set of algorithms for picture processing. It also covers PC vision tasks.
  • SimpleCV integrates with scikit-image for some of its image filtering and enhancement functionalities.
  • scikit-image provides an interface and extensive documentation.

pycuda:

  • PyCUDA is a Python wrapper for NVIDIA's CUDA programming interface.
  • PyCUDA allows GPU-accelerated computing with Python. This can speed up some image tasks.
  • SimpleCV can use PyCUDA to speed up image processing operations.

CImg:

  • CImg is a C++ library for image processing that offers a wide range of functionalities.
  • SimpleCV may use CImg for certain low-level image processing tasks.
  • CImg is designed to provide flexibility and extensibility.

pyopencl:

  • pyOpenCL is a Python wrapper for the OpenCL framework.
  • PyOpenCL is another library for parallel computing using OpenCL.
  • SimpleCV may use PyOpenCL for GPU-accelerated image processing tasks.

mahotas:

  • It is a computer vision library. It specializes in speed and efficiency.
  • It offers many image processing and analysis algorithms.
  • SimpleCV can use Mahotas for certain advanced image-processing tasks.

FAQ

1. What is image filtering, and why is it important in SimpleCV?

Image filtering means changing an image by using math or algorithms. In SimpleCV, image filtering is key. It's used for tasks like removing noise, enhancing edges, and improving image quality. Filtering helps extract useful information from images. It prepares them for analysis or visualization.


2. How can I enhance images in SimpleCV? I mean tasks like changing brightness and contrast.

In SimpleCV, you can change image brightness and contrast. You do this using the brighten () and contrast () functions.

For example:

pythonCopy code

enhanced_img = original_img.brighten(0.5).contrast(1.5)

This code will increase the brightness by 50% and the contrast by 50% of the original image.


3. What are some advanced image enhancement techniques available in SimpleCV?

SimpleCV supports many advanced image enhancement techniques. These include histogram equalization, adaptive filtering, and denoising. You can use these techniques with specific functions. For example, equalizeHist(), adaptiveThreshold(), and dilate ().


4. How do I apply image segmentation techniques in SimpleCV?

You can do image segmentation in SimpleCV. You can use methods like thresholding, contour detection, and watershed segmentation. For instance, you can use the binarize () function to threshold an image. This creates binary masks based on pixel intensity values.


5. Can SimpleCV perform color manipulation and change?

Yes, SimpleCV provides functions for manipulating and adjusting colors in images. For example, you can change the color balance using the balance () function. Or you can adjust the hue, saturation, and value (HSV) using the hue (), saturation (), and value () functions.

SimpleCV is an open-source framework for building computer vision applications using Python. It provides a high-level interface to various image processing and computer vision algorithms. Those make it accessible to developers and researchers. The hobbyists with varying levels of expertise in computer vision.  


Key features of SimpleCV include:  

  • Image Processing  
  • Object Detection and Tracking  
  • Camera and Video Support  
  • Integration with OpenCV  
  • Interactive Shell  
  • Cross-Platform Compatibility  
  • Community and Documentation  


SimpleCV aims to democratize computer vision by providing an easy-to-use yet powerful platform. The building applications range from simple image manipulation tasks to complex object detection. It is suitable for educational purposes, research projects, prototyping, and developing production-grade applications.  

moviepy:  

  • MoviePy is a Python library for video editing, manipulation, and analysis.  
  • MoviePy allows to basic video editing tasks such as cutting, concatenation, and resizing.  
  • MoviePy provides various transition effects to smoothly transition between different video clips.  

scikit-video:  

  • Scikit-video is a library designed to provide easy access to video processing routines.  
  • Scikit-video simplifies reading and writing video files in various formats.  
  • Scikit-video allows the individual frames of a video using familiar NumPy arrays.  

PyAV:  

  • PyAV is a Pythonic binding for the FFmpeg multimedia library.  
  • PyAV wraps the functionality of FFmpeg. It allows to decode, encode, mux, demux, and audio and video streams.  
  • yAV offers high-level APIs for Common audio and video processing tasks.  

scikit-image:  

  • Scikit-image offers a variety of filters and enhancement techniques.  
  • The library provides algorithms for segmenting images into meaningful regions or objects.  
  • Scikit-image includes algorithms for detecting and describing image features. It is such as corners, edges, and key points.  

dlib:  

  • Dlib is a C++ toolkit that contains machine learning algorithms for creating software.  
  • Dlib provides tools for detecting and tracking objects in video streams.  
  • Dlib's facial landmark detection algorithms can identify key points on a face.  

kornia:  

  • Kornia is an open-source differentiable computer vision library built on top of PyTorch.  
  • Kornia provides a rich set of geometric transformations. It's such as rotation, scaling, translation, shearing, and perspective transformation.  
  • Kornia provides a variety of filtering operations. It's such as Gaussian blur, median blur, and Sobel edge detection.  

scipy:  

  • SciPy is a Python library that builds on NumPy and provides a wide range of computing tools.  
  • SciPy includes signal processing routines for tasks. It's such as filtering, Fourier analysis, spectral analysis, and wavelet analysis.  
  • SciPy provides a wide range of statistical functions for descriptive statistics.  

pycuda:  

  • PyCUDA is a Python wrapper for NVIDIA's CUDA parallel computation API.  
  • PyCUDA enables developers to offload computationally intensive tasks in video processing pipelines.  
  • PyCUDA allows developers to write custom CUDA kernels in Python and execute them on the GPU.  

cupy:  

  • CuPy leverages the parallel processing power of NVIDIA GPUs to speed up computations.  
  • CuPy supports a wide range of array manipulation functions, including element-wise operations.  
  • CuPy includes mathematical functions for arithmetic operations and trigonometric functions.  

mahotas:  

  • Mahotas is an open-source computer vision and image-processing library for Python.  
  • Mahotas includes algorithms for object detection, contour finding, and segmentation.  
  • The library provides algorithms for edge detection and boundary detection. It includes Sobel, Canny, and Laplacian edge detectors.  

imageio:  

  • Imageio is a Python library that provides an easy-to-use interface for a wide range of image data.  
  • Imageio supports reading and writing video files in popular formats such as AVI, MP4, MOV, and more.  
  • Imageio allows the extraction of individual frames from video files as NumPy or PIL images.  

FAQ  

1. What is SimpleCV?  

SimpleCV is an open-source framework for building computer vision applications using Python. It provides a high-level interface to various image processing and computer vision algorithms. Those make it accessible to developers, researchers, and hobbyists.  

  

2. Can SimpleCV handle video files?  

Yes, SimpleCV has support for reading and writing video files. It can use the Video class to load video files and extract frames. That performs various operations on video data.  

  

3. Can SimpleCV track objects across multiple frames in a video?  

Yes, SimpleCV includes functionality for object tracking. It allows you to track the movement of objects across consecutive frames in a video. Those can be useful for tasks such as object surveillance and activity monitoring.  

  

4. Does SimpleCV support motion detection in videos?  

Yes, SimpleCV provides tools for motion detection in videos. It can use techniques such as frame differencing and optical flow analysis. It detects motion between successive frames in a video.  

  

5. Is it possible to extract specific features or properties from video frames using SimpleCV?  

Yes, SimpleCV allows you to extract various features and properties from video frames. It's such as color histograms, texture descriptors, object centroids, and more. Those features can be used for object recognition, scene analysis, and content-based retrieval.  

The most powerful open source Java CPU libraries available today. It provides the core Java language with an incredible range of features and functions, including class loading, garbage collection, threading, synchronization, security, I/O management, exception handling, and more. Its flexibility makes it an amazing choice for those looking to build their own custom-made applications and programs. Java CPU libraries allow you to implement, adapt and use complex algorithms for the analysis of data. A profiler is a tool used by developers to see what part of their program or website is consuming resources such as memory or CPU time. Popular open source libraries for Java CPU include: oshi - Native Operating System and Hardware Information; AnotherMonitor - memory usage of Android devices; react-native-threads - Create new JS processes for CPU intensive work; r2cloud - Decode satellite signals on Raspberry PI or any other 64bit intel.

Ruby is a dynamic, object-oriented programming language focused on simplicity and productivity. It has an elegant syntax that is natural to read and easy to write. It is free, flexible and powerful. The Ruby CPU support is one of the most anticipated features in the upcoming Ruby 3.1 release. Ruby 3x3 aims to keep Ruby at the forefront of programming language performance. Ruby has a wide variety of useful CPU open source libraries that are constantly being improved upon in 2017. The CPU-intensive libraries are used for performing heavy calculations and some other types of processing that require a lot of electricity and computing power. Some of the most popular Open Source libraries for Ruby CPU among developers are: parallel - Ruby: parallel processing made simple and fast; zeus-parallel_tests - Zeus is a tool for speeding up your tests by preloading a Rails app; sys-proctable - crossplatform Ruby interface for gathering process information.

CPU (Central Processing Unit) delivers a set of tools for allocating objects in a way that reduces memory consumption and improves performance. It provides an API for writing distributed computing applications for large clusters of machines and is designed to scale to thousands of nodes. It reduces the amount of work that developers have to do to perform operations in parallel by providing high-level language features that automatically execute code in parallel when possible and make it easy to express parallel computations with minimum overhead cost. Some of the most widely used open source libraries for C# CPU among developers include: perfview - PerfView is a CPU and memory performance analysis tool; process-governor - application allows you to put various limits on a Windows process; Torch.NET - .NET bindings for PyTorch; taskbar-monitor - monitoring tool with graphs for Windows taskbar; GPU-CPU-Acceleration - This respository is suitable for OpenCL storage.

Python is one of the best general purpose programming language and high-level language that is relatively easy to learn . Python has always been an excellent language for quickly producing code that deals with networking or computation problems. It has always had an active community of open source developers. Python can be found in web applications, desktop applications, network servers, machine learning and media tools. Python supports multiple programming paradigms, including object-oriented, imperative and functional programming or procedural styles. It features a dynamic type system and automatic memory management and has a large and comprehensive standard library. Python library is used for handling CPU intensive tasks and provides many ways to perform calculations based on integers and floats. Popular open source libraries for Python CPU among developers include: incubator-tvm - Open deep learning compiler stack; s-tui - Terminal based CPU stress and monitoring utility; numpyro - Probabilistic programming with NumPy powered.

JavaScript is one of the most widely used programming languages in the world. The main purpose of the development of JavaScript was to provide dynamic interactivity on websites. The JS engine has attracted a significant number of developers from around the world. It become an industry standard for web development and backend programming. In 2020, JavaScript celebrated its 25th birthday, and it continues to be at the forefront of programming languages. When it comes to CPU libraries, there are many JavaScript libraries that can be used for your projects. It's hard to imagine a world without JavaScript CPU and it has many CPU-intensive tasks. Many developers depend on the following JavaScript CPU open source libraries are: scalene - high precision CPU, GPU, and memory profiler; ua-parser-js - UAParser.js Detect Browser, Engine, OS, CPU, and Device type/model from User Agent data; chillout - Reduce CPU usage by nonblocking async loop.

Go is an open source programming language that makes it easy to build simple, reliable, and efficient software. It's a great fit for CPU projects that need concurrency, parallelism and systems programming constructs. Go is a young language, it's already hard to imagine building server-side services without it. The Go language is the number one choice for CPU intensive applications. It has useful tools that can help to do anything from calculating percentages to writing image objects. The best development teams are increasingly relying on these Go packages to help them create more robust applications in less time. The go-CPU-utilization team is also known for its quick response time when it comes to addressing issues and responding to questions from users. Popular Go CPU open source libraries for developers include: gops - A tool to list and diagnose Go processes currently running on your system; automaxprocs - Automatically set GOMAXPROCS to match Linux container CPU quota; parca - Continuous profiling for analysis of CPU and memory usage, down to the line number and throughout ti.

C++ is a general-purpose programming language that is widely used in the software industry. One of its central features is object-oriented programming (OOP) as well as generic programming, which allows programmers to create efficient, easy-to-maintain and reusable code. C++ is widely used by programmers to develop application software with a personal computer. C++ has been the language of choice for many CPU libraries over the years. C++ CPU libraries are a staple for anyone working in artificial intelligence or machine learning. The availability of libraries in C++ has drastically reduced the time required to develop complex programs and applications. A few of the most popular C++ CPU open source libraries for developers are: thunder svm - Thunder SVM: A Fast SVM Library on GPUs and CPUs; mshadow - Matrix Shadow: Light weight CPU/GPU Matrix and Tensor Template Library in C/CUDA for Machine Learning; ToyPathTracer - Toy path tracer for my own learning purposes.

Java GPU Open Source libraries are a vital part of the Java ecosystem and a key component of many of the world's most popular websites. These projects are designed to enable high-performance Java applications on a variety of hardware and operating system architectures that can be used for various use cases like gaming, AI, ML, and Crypto mining. As GPU programming has become an active research area, many libraries have been proposed to speed up the development of scientific applications. We've done the research, and these are the 8 best Java GPU Open Source libraries listed in this kit. They are PixelFlow - A Processing/Java library for high-performance GPUComputing; CNNdroid - Open Source Library for GPUAccelerated Execution; aparapi - New Official Aparapi: a framework for executing native Java

A GPU (Graphics Processing Unit) is a programmable logic chip that executes many operations in parallel, especially for graphics computations. GPUs are essential for running heavy applications and thus are widely used in various areas of modern technology. In the world of web development, the GPU can be utilized to accelerate performing heavy computations. JavaScript is undoubtedly one of the most popular programming languages in the world. It is used to create dynamic web pages, build mobile apps and games, and even run servers thanks to NodeJS. And now it can also be used for GPU computing. NPM is the default package manager for JavaScript. It’s used by millions of developers to build and manage software. GPUs are already being used for quite some time in desktop and mobile applications like Adobe Premiere, Photoshop, After Effects or even games. Popular open-source libraries for JavaScript GPU among developers include: gpu.js - GPU Accelerated JavaScript; scalene - high precision CPU, GPU, and memory profiler; pai -Resource scheduling and cluster management for AI.

Python is the most popular programming language in the world. Its success lies in its versatility, allowing developers to create everything from simple APIs to complex applications. For machine learning and deep learning, Python has become a preferred language because of its flexibility. The data science and machine learning community has been developing many open source libraries for Python. GPUs are highly specialized chips designed to perform matrix multiplication operations at blazing speeds. Although they were initially intended for rendering computer graphics on screens, they have proved quite useful for machine learning applications as well. Python has a number of libraries that make it easy for us to leverage GPUs for both training and inference tasks. Some of these focus on improving generic performance by leveraging CUDA primitives and it provide higher level abstractions that allow you to quickly build complex architectures without worrying about implementation details. Some of the most popular open-source libraries for Python GPU among developers are: Jax - Composable transformations of Python NumPy programs; kitty - Cross platform, fast, feature rich, GPU based terminal; Image AI - python library built to empower developers to build applications.

Go (also known as go lang) is a programming language that was created by Google in 2009. It is designed for high performance and scalability with strict requirements on program correctness. The language combines elements of other languages such as Java, C++ and Python. The biggest difference between go and other languages such as Java or C++ is that it does not require compilation before running your code; instead, you can simply type “go build my program” into the terminal which will then execute all instructions one after another without needing an interpreter or compiler step first. GPU computing is a technology that has been around for a while, but only recently gained popularity due to the rise of deep learning and artificial intelligence. Developers tend to use some of the following open source libraries for Go GPU are: aresdb - A GPU powered real-time analytics storage and query engine; gapid - Graphics API Debugger; gpu-operator - NVIDIA GPU Operator creates.

C++ is a powerful programming language, which is widely used in many fields, especially in the embedded system. C++ is a statically typed, compiled programming language for general-purpose programming. It is also considered to be an intermediate-level language, as it comprises both high-level and low-level language features. These features make C++ a popular choice in the software industry and allow developers to create efficient applications that can be used in various domains. GPU libraries are widely used to accelerate the performance of matrix calculations, image processing and machine learning. GPUs are used not only in gaming and entertainment, but also in modern science. The number of computations that can be done on a GPU is significant. A few of the most popular open source libraries for C++ GPU are: Tensor RT - Tensor RT is a C library for high performance inference on NVIDIA GPUs and deep learning accelerators; array fire - Array Fire: a general purpose GPU library; compute - A C GPU Computing Library for OpenCL.

The next evolution of scientific computing will involve hardware accelerators, mainly FPGAs and GPUs, which have a higher number of cores and faster clock speeds than their CPU counterparts. With the ever-expanding functionality of personalized computing devices, it is now possible to achieve high performance computing on the graphics processing unit (GPU) with little knowledge of programming for parallel computing. Computing on the GPU has been shown to yield faster computation times than traditional CPU (central processing unit) programming by taking advantage of the high thread counts and large register files available on modern GPUs. Some of the most widely used open source libraries for C# GPU among developers include: Compute Sharp - NET 5 library to run C; GPU-particles - A GPU Particle System for Unity; Marching-Cubes-On-The-GPU - A implementation of the marching cubes algorithm on the GPU in Unity.

Here are 8 cool open-source projects related to GPUs used for AI and accelerated computing. 

Trending Discussions on Hardware

On my flutter project, How can I fix java.lang.AssertionError: annotationType(): unrecognized Attribute name MODULE?

android:exported needs to be explicitly specified for <activity>. Apps targeting Android 12 and higher are required to specify

Is if(A | B) always faster than if(A || B)?

Android emulator on apple silicon (arm64) could be run only using sudo mode

uploaded an APK which has an activity,activity alias,service or broadcast receiver with intentfilter, but without 'android : exported' property set

How to handle different implementations in SysML/UML?

Criteria for default garbage collector Hotspot JVM 11/17

Video_player Crashes Android Emulator in Flutter

Avoid volatile bit-field assignment expression reading or writing memory several times

How to cast nonconst variable to constant static integral class member variable via reinterpret_cast in C++?

QUESTION

On my flutter project, How can I fix java.lang.AssertionError: annotationType(): unrecognized Attribute name MODULE?

Asked 2022-Apr-03 at 07:11

Using fvm, I migrated the project from flutter 2.0.6 to flutter 2.5.2. After fixing all null safesty issues. I get the following error when I try to run my project:

1$ fvm flutter run
2Using hardware rendering with device sdk gphone x86. If you notice graphics artifacts, consider enabling software rendering with "--enable-software-rendering".
3Launching lib/main.dart on sdk gphone x86 in debug mode...
4Running Gradle task 'assembleDebug'...                          
5An exception has occurred in the compiler (1.8.0_242-release). Please file a bug against the Java compiler via the Java bug reporting page (http://bugreport.java.com) after checking the Bug Database (http://bugs.java.com) for duplicates. Include your program and the following diagnostic in your report. Thank you.
6java.lang.AssertionError: annotationType(): unrecognized Attribute name MODULE (class com.sun.tools.javac.util.UnsharedNameTable$NameImpl)
7        at com.sun.tools.javac.util.Assert.error(Assert.java:133)
8        at com.sun.tools.javac.code.TypeAnnotations.annotationType(TypeAnnotations.java:231)
9        at com.sun.tools.javac.code.TypeAnnotations$TypeAnnotationPositions.separateAnnotationsKinds(TypeAnnotations.java:294)
10        at com.sun.tools.javac.code.TypeAnnotations$TypeAnnotationPositions.visitVarDef(TypeAnnotations.java:1164)
11        at com.sun.tools.javac.tree.JCTree$JCVariableDecl.accept(JCTree.java:852)
12        at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
13        at com.sun.tools.javac.code.TypeAnnotations$TypeAnnotationPositions.scan(TypeAnnotations.java:275)
14        at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:57)
15        at com.sun.tools.javac.code.TypeAnnotations$TypeAnnotationPositions.visitClassDef(TypeAnnotations.java:1042)
16        at com.sun.tools.javac.tree.JCTree$JCClassDecl.accept(JCTree.java:693)
17        at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
18        at com.sun.tools.javac.code.TypeAnnotations$TypeAnnotationPositions.scan(TypeAnnotations.java:275)
19        at com.sun.tools.javac.code.TypeAnnotations$1.run(TypeAnnotations.java:127)
20        at com.sun.tools.javac.comp.Annotate.flush(Annotate.java:152)
21        at com.sun.tools.javac.comp.Annotate.enterDone(Annotate.java:129)
22        at com.sun.tools.javac.comp.Enter.complete(Enter.java:512)
23        at com.sun.tools.javac.comp.Enter.main(Enter.java:471)
24        at com.sun.tools.javac.main.JavaCompiler.enterTrees(JavaCompiler.java:982)
25        at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:857)
26        at com.sun.tools.javac.main.Main.compile(Main.java:523)
27        at com.sun.tools.javac.api.JavacTaskImpl.doCall(JavacTaskImpl.java:129)
28        at com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:138)
29        at org.gradle.api.internal.tasks.compile.AnnotationProcessingCompileTask.call(AnnotationProcessingCompileTask.java:93)
30        at org.gradle.api.internal.tasks.compile.ResourceCleaningCompilationTask.call(ResourceCleaningCompilationTask.java:57)
31        at org.gradle.api.internal.tasks.compile.JdkJavaCompiler.execute(JdkJavaCompiler.java:54)
32        at org.gradle.api.internal.tasks.compile.JdkJavaCompiler.execute(JdkJavaCompiler.java:39)
33        at org.gradle.api.internal.tasks.compile.NormalizingJavaCompiler.delegateAndHandleErrors(NormalizingJavaCompiler.java:100)
34        at org.gradle.api.internal.tasks.compile.NormalizingJavaCompiler.execute(NormalizingJavaCompiler.java:52)
35        at org.gradle.api.internal.tasks.compile.NormalizingJavaCompiler.execute(NormalizingJavaCompiler.java:38)
36        at org.gradle.api.internal.tasks.compile.AnnotationProcessorDiscoveringCompiler.execute(AnnotationProcessorDiscoveringCompiler.java:51)
37        at org.gradle.api.internal.tasks.compile.AnnotationProcessorDiscoveringCompiler.execute(AnnotationProcessorDiscoveringCompiler.java:37)
38        at org.gradle.api.internal.tasks.compile.CleaningJavaCompilerSupport.execute(CleaningJavaCompilerSupport.java:39)
39        at org.gradle.api.internal.tasks.compile.incremental.IncrementalCompilerFactory$2.execute(IncrementalCompilerFactory.java:101)
40        at org.gradle.api.internal.tasks.compile.incremental.IncrementalCompilerFactory$2.execute(IncrementalCompilerFactory.java:97)
41        at org.gradle.api.internal.tasks.compile.incremental.IncrementalResultStoringCompiler.execute(IncrementalResultStoringCompiler.java:60)
42        at org.gradle.api.internal.tasks.compile.incremental.IncrementalResultStoringCompiler.execute(IncrementalResultStoringCompiler.java:44)
43        at org.gradle.api.internal.tasks.compile.CompileJavaBuildOperationReportingCompiler$2.call(CompileJavaBuildOperationReportingCompiler.java:59)
44        at org.gradle.api.internal.tasks.compile.CompileJavaBuildOperationReportingCompiler$2.call(CompileJavaBuildOperationReportingCompiler.java:51)
45        at org.gradle.internal.operations.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:416)
46        at org.gradle.internal.operations.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:406)
47        at org.gradle.internal.operations.DefaultBuildOperationExecutor$1.execute(DefaultBuildOperationExecutor.java:165)
48        at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:250)
49        at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:158)
50        at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:102)
51        at org.gradle.internal.operations.DelegatingBuildOperationExecutor.call(DelegatingBuildOperationExecutor.java:36)
52        at org.gradle.api.internal.tasks.compile.CompileJavaBuildOperationReportingCompiler.execute(CompileJavaBuildOperationReportingCompiler.java:51)
53        at org.gradle.api.tasks.compile.JavaCompile.performCompilation(JavaCompile.java:158)
54        at org.gradle.api.tasks.compile.JavaCompile.compile(JavaCompile.java:126)
55        at com.android.build.gradle.tasks.AndroidJavaCompile.compile(AndroidJavaCompile.kt:237)
56        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
57        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
58        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
59        at java.lang.reflect.Method.invoke(Method.java:498)
60        at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:103)
61        at org.gradle.api.internal.project.taskfactory.IncrementalTaskInputsTaskAction.doExecute(IncrementalTaskInputsTaskAction.java:47)
62        at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:42)
63        at org.gradle.api.internal.project.taskfactory.AbstractIncrementalTaskAction.execute(AbstractIncrementalTaskAction.java:25)
64        at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:28)
65        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$5.run(ExecuteActionsTaskExecuter.java:476)
66        at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:402)
67        at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:394)
68        at org.gradle.internal.operations.DefaultBuildOperationExecutor$1.execute(DefaultBuildOperationExecutor.java:165)
69        at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:250)
70        at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:158)
71        at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:92)
72        at org.gradle.internal.operations.DelegatingBuildOperationExecutor.run(DelegatingBuildOperationExecutor.java:31)
73        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:461)
74        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:444)
75        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.access$200(ExecuteActionsTaskExecuter.java:93)
76        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$TaskExecution.execute(ExecuteActionsTaskExecuter.java:237)
77        at org.gradle.internal.execution.steps.ExecuteStep.lambda$execute$0(ExecuteStep.java:32)
78        at java.util.Optional.map(Optional.java:215)
79        at org.gradle.internal.execution.steps.ExecuteStep.execute(ExecuteStep.java:32)
80        at org.gradle.internal.execution.steps.ExecuteStep.execute(ExecuteStep.java:26)
81        at org.gradle.internal.execution.steps.CleanupOutputsStep.execute(CleanupOutputsStep.java:58)
82        at org.gradle.internal.execution.steps.CleanupOutputsStep.execute(CleanupOutputsStep.java:35)
83        at org.gradle.internal.execution.steps.ResolveInputChangesStep.execute(ResolveInputChangesStep.java:48)
84        at org.gradle.internal.execution.steps.ResolveInputChangesStep.execute(ResolveInputChangesStep.java:33)
85        at org.gradle.internal.execution.steps.CancelExecutionStep.execute(CancelExecutionStep.java:39)
86        at org.gradle.internal.execution.steps.TimeoutStep.executeWithoutTimeout(TimeoutStep.java:73)
87        at org.gradle.internal.execution.steps.TimeoutStep.execute(TimeoutStep.java:54)
88        at org.gradle.internal.execution.steps.CatchExceptionStep.execute(CatchExceptionStep.java:35)
89        at org.gradle.internal.execution.steps.CreateOutputsStep.execute(CreateOutputsStep.java:51)
90        at org.gradle.internal.execution.steps.SnapshotOutputsStep.execute(SnapshotOutputsStep.java:45)
91        at org.gradle.internal.execution.steps.SnapshotOutputsStep.execute(SnapshotOutputsStep.java:31)
92        at org.gradle.internal.execution.steps.CacheStep.executeWithoutCache(CacheStep.java:208)
93        at org.gradle.internal.execution.steps.CacheStep.execute(CacheStep.java:70)
94        at org.gradle.internal.execution.steps.CacheStep.execute(CacheStep.java:45)
95        at org.gradle.internal.execution.steps.BroadcastChangingOutputsStep.execute(BroadcastChangingOutputsStep.java:49)
96        at org.gradle.internal.execution.steps.StoreSnapshotsStep.execute(StoreSnapshotsStep.java:43)
97        at org.gradle.internal.execution.steps.StoreSnapshotsStep.execute(StoreSnapshotsStep.java:32)
98        at org.gradle.internal.execution.steps.RecordOutputsStep.execute(RecordOutputsStep.java:38)
99        at org.gradle.internal.execution.steps.RecordOutputsStep.execute(RecordOutputsStep.java:24)
100        at org.gradle.internal.execution.steps.SkipUpToDateStep.executeBecause(SkipUpToDateStep.java:96)
101        at org.gradle.internal.execution.steps.SkipUpToDateStep.lambda$execute$0(SkipUpToDateStep.java:89)
102        at java.util.Optional.map(Optional.java:215)
103        at org.gradle.internal.execution.steps.SkipUpToDateStep.execute(SkipUpToDateStep.java:54)
104        at org.gradle.internal.execution.steps.SkipUpToDateStep.execute(SkipUpToDateStep.java:38)
105        at org.gradle.internal.execution.steps.ResolveChangesStep.execute(ResolveChangesStep.java:76)
106        at org.gradle.internal.execution.steps.ResolveChangesStep.execute(ResolveChangesStep.java:37)
107        at org.gradle.internal.execution.steps.legacy.MarkSnapshottingInputsFinishedStep.execute(MarkSnapshottingInputsFinishedStep.java:36)
108        at org.gradle.internal.execution.steps.legacy.MarkSnapshottingInputsFinishedStep.execute(MarkSnapshottingInputsFinishedStep.java:26)
109        at org.gradle.internal.execution.steps.ResolveCachingStateStep.execute(ResolveCachingStateStep.java:90)
110        at org.gradle.internal.execution.steps.ResolveCachingStateStep.execute(ResolveCachingStateStep.java:48)
111        at org.gradle.internal.execution.steps.CaptureStateBeforeExecutionStep.execute(CaptureStateBeforeExecutionStep.java:69)
112        at org.gradle.internal.execution.steps.CaptureStateBeforeExecutionStep.execute(CaptureStateBeforeExecutionStep.java:47)
113        at org.gradle.internal.execution.impl.DefaultWorkExecutor.execute(DefaultWorkExecutor.java:33)
114        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:140)
115        at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:62)
116        at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:108)
117        at org.gradle.api.internal.tasks.execution.ResolveBeforeExecutionOutputsTaskExecuter.execute(ResolveBeforeExecutionOutputsTaskExecuter.java:67)
118        at org.gradle.api.internal.tasks.execution.ResolveAfterPreviousExecutionStateTaskExecuter.execute(ResolveAfterPreviousExecutionStateTaskExecuter.java:46)
119        at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:94)
120        at org.gradle.api.internal.tasks.execution.FinalizePropertiesTaskExecuter.execute(FinalizePropertiesTaskExecuter.java:46)
121        at org.gradle.api.internal.tasks.execution.ResolveTaskExecutionModeExecuter.execute(ResolveTaskExecutionModeExecuter.java:95)
122        at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:57)
123        at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:56)
124        at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:36)
125        at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.executeTask(EventFiringTaskExecuter.java:77)
126        at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:55)
127        at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:52)
128        at org.gradle.internal.operations.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:416)
129        at org.gradle.internal.operations.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:406)
130        at org.gradle.internal.operations.DefaultBuildOperationExecutor$1.execute(DefaultBuildOperationExecutor.java:165)
131        at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:250)
132        at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:158)
133        at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:102)
134        at org.gradle.internal.operations.DelegatingBuildOperationExecutor.call(DelegatingBuildOperationExecutor.java:36)
135        at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter.execute(EventFiringTaskExecuter.java:52)
136        at org.gradle.execution.plan.LocalTaskNodeExecutor.execute(LocalTaskNodeExecutor.java:43)
137        at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:355)
138        at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:343)
139        at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:336)
140        at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:322)
141        at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker$1.execute(DefaultPlanExecutor.java:134)
142        at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker$1.execute(DefaultPlanExecutor.java:129)
143        at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.execute(DefaultPlanExecutor.java:202)
144        at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.executeNextNode(DefaultPlanExecutor.java:193)
145        at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.run(DefaultPlanExecutor.java:129)
146        at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)
147        at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:48)
148        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
149        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
150        at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:56)
151        at java.lang.Thread.run(Thread.java:748)
152
153FAILURE: Build failed with an exception.
154
155* What went wrong:
156Execution failed for task ':permission_handler:compileDebugJavaWithJavac'.
157> Compilation failed; see the compiler error output for details.
158
159* Try:
160Run 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.
161
162* Get more help at https://help.gradle.org
163
164BUILD FAILED in 3s
165Running Gradle task 'assembleDebug'...                              3.6s
166Exception: Gradle task assembleDebug failed with exit code 1
167

My flutter doctor is

1$ fvm flutter run
2Using hardware rendering with device sdk gphone x86. If you notice graphics artifacts, consider enabling software rendering with "--enable-software-rendering".
3Launching lib/main.dart on sdk gphone x86 in debug mode...
4Running Gradle task 'assembleDebug'...                          
5An exception has occurred in the compiler (1.8.0_242-release). Please file a bug against the Java compiler via the Java bug reporting page (http://bugreport.java.com) after checking the Bug Database (http://bugs.java.com) for duplicates. Include your program and the following diagnostic in your report. Thank you.
6java.lang.AssertionError: annotationType(): unrecognized Attribute name MODULE (class com.sun.tools.javac.util.UnsharedNameTable$NameImpl)
7        at com.sun.tools.javac.util.Assert.error(Assert.java:133)
8        at com.sun.tools.javac.code.TypeAnnotations.annotationType(TypeAnnotations.java:231)
9        at com.sun.tools.javac.code.TypeAnnotations$TypeAnnotationPositions.separateAnnotationsKinds(TypeAnnotations.java:294)
10        at com.sun.tools.javac.code.TypeAnnotations$TypeAnnotationPositions.visitVarDef(TypeAnnotations.java:1164)
11        at com.sun.tools.javac.tree.JCTree$JCVariableDecl.accept(JCTree.java:852)
12        at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
13        at com.sun.tools.javac.code.TypeAnnotations$TypeAnnotationPositions.scan(TypeAnnotations.java:275)
14        at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:57)
15        at com.sun.tools.javac.code.TypeAnnotations$TypeAnnotationPositions.visitClassDef(TypeAnnotations.java:1042)
16        at com.sun.tools.javac.tree.JCTree$JCClassDecl.accept(JCTree.java:693)
17        at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
18        at com.sun.tools.javac.code.TypeAnnotations$TypeAnnotationPositions.scan(TypeAnnotations.java:275)
19        at com.sun.tools.javac.code.TypeAnnotations$1.run(TypeAnnotations.java:127)
20        at com.sun.tools.javac.comp.Annotate.flush(Annotate.java:152)
21        at com.sun.tools.javac.comp.Annotate.enterDone(Annotate.java:129)
22        at com.sun.tools.javac.comp.Enter.complete(Enter.java:512)
23        at com.sun.tools.javac.comp.Enter.main(Enter.java:471)
24        at com.sun.tools.javac.main.JavaCompiler.enterTrees(JavaCompiler.java:982)
25        at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:857)
26        at com.sun.tools.javac.main.Main.compile(Main.java:523)
27        at com.sun.tools.javac.api.JavacTaskImpl.doCall(JavacTaskImpl.java:129)
28        at com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:138)
29        at org.gradle.api.internal.tasks.compile.AnnotationProcessingCompileTask.call(AnnotationProcessingCompileTask.java:93)
30        at org.gradle.api.internal.tasks.compile.ResourceCleaningCompilationTask.call(ResourceCleaningCompilationTask.java:57)
31        at org.gradle.api.internal.tasks.compile.JdkJavaCompiler.execute(JdkJavaCompiler.java:54)
32        at org.gradle.api.internal.tasks.compile.JdkJavaCompiler.execute(JdkJavaCompiler.java:39)
33        at org.gradle.api.internal.tasks.compile.NormalizingJavaCompiler.delegateAndHandleErrors(NormalizingJavaCompiler.java:100)
34        at org.gradle.api.internal.tasks.compile.NormalizingJavaCompiler.execute(NormalizingJavaCompiler.java:52)
35        at org.gradle.api.internal.tasks.compile.NormalizingJavaCompiler.execute(NormalizingJavaCompiler.java:38)
36        at org.gradle.api.internal.tasks.compile.AnnotationProcessorDiscoveringCompiler.execute(AnnotationProcessorDiscoveringCompiler.java:51)
37        at org.gradle.api.internal.tasks.compile.AnnotationProcessorDiscoveringCompiler.execute(AnnotationProcessorDiscoveringCompiler.java:37)
38        at org.gradle.api.internal.tasks.compile.CleaningJavaCompilerSupport.execute(CleaningJavaCompilerSupport.java:39)
39        at org.gradle.api.internal.tasks.compile.incremental.IncrementalCompilerFactory$2.execute(IncrementalCompilerFactory.java:101)
40        at org.gradle.api.internal.tasks.compile.incremental.IncrementalCompilerFactory$2.execute(IncrementalCompilerFactory.java:97)
41        at org.gradle.api.internal.tasks.compile.incremental.IncrementalResultStoringCompiler.execute(IncrementalResultStoringCompiler.java:60)
42        at org.gradle.api.internal.tasks.compile.incremental.IncrementalResultStoringCompiler.execute(IncrementalResultStoringCompiler.java:44)
43        at org.gradle.api.internal.tasks.compile.CompileJavaBuildOperationReportingCompiler$2.call(CompileJavaBuildOperationReportingCompiler.java:59)
44        at org.gradle.api.internal.tasks.compile.CompileJavaBuildOperationReportingCompiler$2.call(CompileJavaBuildOperationReportingCompiler.java:51)
45        at org.gradle.internal.operations.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:416)
46        at org.gradle.internal.operations.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:406)
47        at org.gradle.internal.operations.DefaultBuildOperationExecutor$1.execute(DefaultBuildOperationExecutor.java:165)
48        at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:250)
49        at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:158)
50        at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:102)
51        at org.gradle.internal.operations.DelegatingBuildOperationExecutor.call(DelegatingBuildOperationExecutor.java:36)
52        at org.gradle.api.internal.tasks.compile.CompileJavaBuildOperationReportingCompiler.execute(CompileJavaBuildOperationReportingCompiler.java:51)
53        at org.gradle.api.tasks.compile.JavaCompile.performCompilation(JavaCompile.java:158)
54        at org.gradle.api.tasks.compile.JavaCompile.compile(JavaCompile.java:126)
55        at com.android.build.gradle.tasks.AndroidJavaCompile.compile(AndroidJavaCompile.kt:237)
56        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
57        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
58        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
59        at java.lang.reflect.Method.invoke(Method.java:498)
60        at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:103)
61        at org.gradle.api.internal.project.taskfactory.IncrementalTaskInputsTaskAction.doExecute(IncrementalTaskInputsTaskAction.java:47)
62        at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:42)
63        at org.gradle.api.internal.project.taskfactory.AbstractIncrementalTaskAction.execute(AbstractIncrementalTaskAction.java:25)
64        at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:28)
65        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$5.run(ExecuteActionsTaskExecuter.java:476)
66        at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:402)
67        at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:394)
68        at org.gradle.internal.operations.DefaultBuildOperationExecutor$1.execute(DefaultBuildOperationExecutor.java:165)
69        at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:250)
70        at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:158)
71        at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:92)
72        at org.gradle.internal.operations.DelegatingBuildOperationExecutor.run(DelegatingBuildOperationExecutor.java:31)
73        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:461)
74        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:444)
75        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.access$200(ExecuteActionsTaskExecuter.java:93)
76        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$TaskExecution.execute(ExecuteActionsTaskExecuter.java:237)
77        at org.gradle.internal.execution.steps.ExecuteStep.lambda$execute$0(ExecuteStep.java:32)
78        at java.util.Optional.map(Optional.java:215)
79        at org.gradle.internal.execution.steps.ExecuteStep.execute(ExecuteStep.java:32)
80        at org.gradle.internal.execution.steps.ExecuteStep.execute(ExecuteStep.java:26)
81        at org.gradle.internal.execution.steps.CleanupOutputsStep.execute(CleanupOutputsStep.java:58)
82        at org.gradle.internal.execution.steps.CleanupOutputsStep.execute(CleanupOutputsStep.java:35)
83        at org.gradle.internal.execution.steps.ResolveInputChangesStep.execute(ResolveInputChangesStep.java:48)
84        at org.gradle.internal.execution.steps.ResolveInputChangesStep.execute(ResolveInputChangesStep.java:33)
85        at org.gradle.internal.execution.steps.CancelExecutionStep.execute(CancelExecutionStep.java:39)
86        at org.gradle.internal.execution.steps.TimeoutStep.executeWithoutTimeout(TimeoutStep.java:73)
87        at org.gradle.internal.execution.steps.TimeoutStep.execute(TimeoutStep.java:54)
88        at org.gradle.internal.execution.steps.CatchExceptionStep.execute(CatchExceptionStep.java:35)
89        at org.gradle.internal.execution.steps.CreateOutputsStep.execute(CreateOutputsStep.java:51)
90        at org.gradle.internal.execution.steps.SnapshotOutputsStep.execute(SnapshotOutputsStep.java:45)
91        at org.gradle.internal.execution.steps.SnapshotOutputsStep.execute(SnapshotOutputsStep.java:31)
92        at org.gradle.internal.execution.steps.CacheStep.executeWithoutCache(CacheStep.java:208)
93        at org.gradle.internal.execution.steps.CacheStep.execute(CacheStep.java:70)
94        at org.gradle.internal.execution.steps.CacheStep.execute(CacheStep.java:45)
95        at org.gradle.internal.execution.steps.BroadcastChangingOutputsStep.execute(BroadcastChangingOutputsStep.java:49)
96        at org.gradle.internal.execution.steps.StoreSnapshotsStep.execute(StoreSnapshotsStep.java:43)
97        at org.gradle.internal.execution.steps.StoreSnapshotsStep.execute(StoreSnapshotsStep.java:32)
98        at org.gradle.internal.execution.steps.RecordOutputsStep.execute(RecordOutputsStep.java:38)
99        at org.gradle.internal.execution.steps.RecordOutputsStep.execute(RecordOutputsStep.java:24)
100        at org.gradle.internal.execution.steps.SkipUpToDateStep.executeBecause(SkipUpToDateStep.java:96)
101        at org.gradle.internal.execution.steps.SkipUpToDateStep.lambda$execute$0(SkipUpToDateStep.java:89)
102        at java.util.Optional.map(Optional.java:215)
103        at org.gradle.internal.execution.steps.SkipUpToDateStep.execute(SkipUpToDateStep.java:54)
104        at org.gradle.internal.execution.steps.SkipUpToDateStep.execute(SkipUpToDateStep.java:38)
105        at org.gradle.internal.execution.steps.ResolveChangesStep.execute(ResolveChangesStep.java:76)
106        at org.gradle.internal.execution.steps.ResolveChangesStep.execute(ResolveChangesStep.java:37)
107        at org.gradle.internal.execution.steps.legacy.MarkSnapshottingInputsFinishedStep.execute(MarkSnapshottingInputsFinishedStep.java:36)
108        at org.gradle.internal.execution.steps.legacy.MarkSnapshottingInputsFinishedStep.execute(MarkSnapshottingInputsFinishedStep.java:26)
109        at org.gradle.internal.execution.steps.ResolveCachingStateStep.execute(ResolveCachingStateStep.java:90)
110        at org.gradle.internal.execution.steps.ResolveCachingStateStep.execute(ResolveCachingStateStep.java:48)
111        at org.gradle.internal.execution.steps.CaptureStateBeforeExecutionStep.execute(CaptureStateBeforeExecutionStep.java:69)
112        at org.gradle.internal.execution.steps.CaptureStateBeforeExecutionStep.execute(CaptureStateBeforeExecutionStep.java:47)
113        at org.gradle.internal.execution.impl.DefaultWorkExecutor.execute(DefaultWorkExecutor.java:33)
114        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:140)
115        at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:62)
116        at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:108)
117        at org.gradle.api.internal.tasks.execution.ResolveBeforeExecutionOutputsTaskExecuter.execute(ResolveBeforeExecutionOutputsTaskExecuter.java:67)
118        at org.gradle.api.internal.tasks.execution.ResolveAfterPreviousExecutionStateTaskExecuter.execute(ResolveAfterPreviousExecutionStateTaskExecuter.java:46)
119        at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:94)
120        at org.gradle.api.internal.tasks.execution.FinalizePropertiesTaskExecuter.execute(FinalizePropertiesTaskExecuter.java:46)
121        at org.gradle.api.internal.tasks.execution.ResolveTaskExecutionModeExecuter.execute(ResolveTaskExecutionModeExecuter.java:95)
122        at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:57)
123        at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:56)
124        at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:36)
125        at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.executeTask(EventFiringTaskExecuter.java:77)
126        at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:55)
127        at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:52)
128        at org.gradle.internal.operations.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:416)
129        at org.gradle.internal.operations.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:406)
130        at org.gradle.internal.operations.DefaultBuildOperationExecutor$1.execute(DefaultBuildOperationExecutor.java:165)
131        at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:250)
132        at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:158)
133        at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:102)
134        at org.gradle.internal.operations.DelegatingBuildOperationExecutor.call(DelegatingBuildOperationExecutor.java:36)
135        at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter.execute(EventFiringTaskExecuter.java:52)
136        at org.gradle.execution.plan.LocalTaskNodeExecutor.execute(LocalTaskNodeExecutor.java:43)
137        at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:355)
138        at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:343)
139        at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:336)
140        at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:322)
141        at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker$1.execute(DefaultPlanExecutor.java:134)
142        at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker$1.execute(DefaultPlanExecutor.java:129)
143        at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.execute(DefaultPlanExecutor.java:202)
144        at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.executeNextNode(DefaultPlanExecutor.java:193)
145        at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.run(DefaultPlanExecutor.java:129)
146        at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)
147        at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:48)
148        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
149        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
150        at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:56)
151        at java.lang.Thread.run(Thread.java:748)
152
153FAILURE: Build failed with an exception.
154
155* What went wrong:
156Execution failed for task ':permission_handler:compileDebugJavaWithJavac'.
157> Compilation failed; see the compiler error output for details.
158
159* Try:
160Run 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.
161
162* Get more help at https://help.gradle.org
163
164BUILD FAILED in 3s
165Running Gradle task 'assembleDebug'...                              3.6s
166Exception: Gradle task assembleDebug failed with exit code 1
167Doctor summary (to see all details, run flutter doctor -v):
168[✓] Flutter (Channel stable, 2.5.2, on Ubuntu 20.04.3 LTS 5.11.0-37-generic, locale en_US.UTF-8)
169[!] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
170    ✗ cmdline-tools component is missing
171      Run `path/to/sdkmanager --install "cmdline-tools;latest"`
172      See https://developer.android.com/studio/command-line for more details.
173    ✗ Android license status unknown.
174      Run `flutter doctor --android-licenses` to accept the SDK licenses.
175      See https://flutter.dev/docs/get-started/install/linux#android-setup for more details.
176[✓] Chrome - develop for the web
177[✓] Android Studio (version 4.1)
178[✓] VS Code (version 1.60.2)
179[✓] Connected device (2 available)
180
181! Doctor found issues in 1 category.
182

I am not sure how to get the java version that fvm is using to compile if this is relevant.

Please let me know any command or information needed and I will update the post.

Thank you.

ANSWER

Answered 2021-Nov-18 at 14:02

This arises from a combination of using compileSdkVersion 31 in android builds with JDK8.

The default android toolchains have moved to JDK11 now, you must use JDK11 when you change any of the android API target versions from 30 to 31.

Semi duplicate of unrecognized Attribute name MODULE (class com.sun.tools.javac.util.SharedNameTable$NameImpl)

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

QUESTION

android:exported needs to be explicitly specified for <activity>. 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:

1<?xml version="1.0" encoding="utf-8"?>
2<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3    xmlns:tools="http://schemas.android.com/tools"
4    package="eu.siacs.conversations">
5
6    <uses-sdk tools:overrideLibrary="net.ypresto.androidtranscoder" />
7
8    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
9    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
10    <uses-permission android:name="android.permission.READ_CONTACTS" />
11    <uses-permission android:name="android.permission.READ_PROFILE" />
12    <uses-permission
13        android:name="android.permission.READ_PHONE_STATE"
14        android:maxSdkVersion="22" />
15    <uses-permission android:name="android.permission.INTERNET" />
16    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
17    <uses-permission android:name="android.permission.WAKE_LOCK" />
18    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
19    <uses-permission android:name="android.permission.VIBRATE" />
20    <uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" />
21    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
22    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
23    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
24    <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
25    <uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
26
27    <uses-feature
28        android:name="android.hardware.location"
29        android:required="false" />
30    <uses-feature
31        android:name="android.hardware.location.gps"
32        android:required="false" />
33    <uses-feature
34        android:name="android.hardware.location.network"
35        android:required="false" />
36
37    <uses-permission android:name="android.permission.CAMERA" />
38    <uses-permission android:name="android.permission.RECORD_AUDIO" />
39    <uses-permission android:name="android.permission.BLUETOOTH" />
40    <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
41    <uses-permission android:name="android.permission.USE_FULL_SCREEN_INTENT" />
42    <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
43
44    <uses-feature
45        android:name="android.hardware.camera"
46        android:required="false" />
47    <uses-feature
48        android:name="android.hardware.camera.autofocus"
49        android:required="false" />
50    <uses-feature
51        android:name="android.hardware.microphone"
52        android:required="false" />
53
54    <application
55        android:name=".Application"
56        android:allowBackup="false"
57        android:allowClearUserData="true"
58        android:appCategory="social"
59        android:hardwareAccelerated="true"
60        android:icon="@mipmap/ic_app_launch"
61        android:label="@string/app_name"
62        android:largeHeap="true"
63        android:networkSecurityConfig="@xml/network_security_configuration"
64        android:requestLegacyExternalStorage="true"
65        android:roundIcon="@mipmap/ic_app_launch_round"
66        android:theme="@style/ConversationsTheme"
67        android:usesCleartextTraffic="true"
68        android:windowSoftInputMode="adjustPan|adjustResize"
69        tools:replace="android:label"
70        tools:targetApi="q">
71        <activity
72            android:name=".ui.search.GroupSearchActivity"
73            android:exported="true" />
74        <activity
75            android:name=".ui.profileUpdating.FavouritesActivity"
76            android:exported="true" />
77        <activity
78            android:name=".ui.profileUpdating.NameActivity"
79            android:exported="true" />
80        <activity
81            android:name=".ui.CompulsoryUpdateActivity"
82            android:exported="true" />
83        <activity android:name=".ui.payments.doPayment.DoPaymentActivity"
84            android:exported="true" />
85        <activity android:name=".ui.individualList.IndividualListActivity"
86            android:exported="true" />
87        <activity android:name=".ui.payments.setPayment.SetPaymentActivity"
88            android:exported="true" />
89        <activity android:name=".ui.login.otpActivity.OTPActivity"
90            android:exported="true" />
91        <activity android:name=".ui.login.loginActivity.LoginActivity"
92            android:exported="true" />
93
94        <service android:name=".services.XmppConnectionService" android:exported="true" />
95
96        <receiver android:name=".services.EventReceiver"
97            android:exported="true">
98            <intent-filter>
99                <action android:name="android.intent.action.BOOT_COMPLETED" />
100                <action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
101                <action android:name="android.intent.action.ACTION_SHUTDOWN" />
102                <action android:name="android.media.RINGER_MODE_CHANGED" />
103            </intent-filter>
104        </receiver>
105
106        <activity
107            android:name=".ui.ShareLocationActivity"
108            android:label="@string/title_activity_share_location"
109            android:exported="true"/>
110        <activity
111            android:name=".ui.SearchActivity"
112            android:label="@string/search_messages"
113            android:exported="true" />
114        <activity
115            android:name=".ui.RecordingActivity"
116            android:configChanges="orientation|screenSize"
117            android:theme="@style/ConversationsTheme.Dialog"
118            android:exported="true" />
119        <activity
120            android:name=".ui.ShowLocationActivity"
121            android:label="@string/title_activity_show_location"
122            android:exported="true" />
123        <activity
124            android:name=".ui.SplashActivity"
125            android:theme="@style/SplashTheme"
126            android:exported="true">
127            <intent-filter>
128                <action android:name="android.intent.action.MAIN" />
129
130                <category android:name="android.intent.category.LAUNCHER" />
131            </intent-filter>
132        </activity>
133        <activity
134            android:name=".ui.ConversationsActivity"
135            android:label="@string/app_name"
136            android:launchMode="singleTask"
137            android:minWidth="300dp"
138            android:minHeight="300dp"
139            android:exported="true"
140            android:windowSoftInputMode="stateHidden" />
141        <activity
142            android:name=".ui.ScanActivity"
143            android:screenOrientation="portrait"
144            android:exported="true"
145            android:theme="@style/ConversationsTheme.FullScreen"
146            android:windowSoftInputMode="stateAlwaysHidden" />
147        <activity
148            android:name=".ui.UriHandlerActivity"
149            android:label="@string/app_name"
150            android:exported="true">
151            <intent-filter>
152                <action android:name="android.intent.action.VIEW" />
153
154                <category android:name="android.intent.category.DEFAULT" />
155                <category android:name="android.intent.category.BROWSABLE" />
156
157                <data android:scheme="xmpp" />
158            </intent-filter>
159            <intent-filter android:autoVerify="true">
160                <action android:name="android.intent.action.VIEW" />
161
162                <category android:name="android.intent.category.DEFAULT" />
163                <category android:name="android.intent.category.BROWSABLE" />
164
165                <data android:scheme="https" />
166                <data android:host="im.app.in" />
167                <data android:pathPrefix="/i/" />
168                <data android:pathPrefix="/j/" />
169            </intent-filter>
170            <intent-filter>
171                <action android:name="android.intent.action.SENDTO" />
172
173                <category android:name="android.intent.category.DEFAULT" />
174
175                <data android:scheme="imto" />
176                <data android:host="jabber" />
177            </intent-filter>
178        </activity>
179        <activity
180            android:name=".ui.StartConversationActivity"
181            android:label="@string/title_activity_start_conversation"
182            android:launchMode="singleTop"
183            android:exported="true">
184            <intent-filter>
185                <action android:name="android.intent.action.VIEW" />
186            </intent-filter>
187        </activity>
188        <activity
189            android:name=".ui.SettingsActivity"
190            android:label="@string/title_activity_settings"
191            android:exported="true">
192            <intent-filter>
193                <action android:name="android.intent.action.MAIN" />
194
195                <category android:name="android.intent.category.NOTIFICATION_PREFERENCES" />
196            </intent-filter>
197        </activity>
198        <activity
199            android:name=".ui.ChooseContactActivity"
200            android:label="@string/title_activity_choose_contact"
201            android:exported="true" />
202        <activity
203            android:name=".ui.BlocklistActivity"
204            android:label="@string/title_activity_block_list"
205            android:exported="true"/>
206        <activity
207            android:name=".ui.ChangePasswordActivity"
208            android:label="@string/change_password_on_server"
209            android:exported="true"/>
210        <activity
211            android:name=".ui.ChooseAccountForProfilePictureActivity"
212            android:enabled="false"
213            android:label="@string/choose_account"
214            android:exported="true">
215            <intent-filter android:label="@string/set_profile_picture">
216                <action android:name="android.intent.action.ATTACH_DATA" />
217
218                <category android:name="android.intent.category.DEFAULT" />
219
220                <data android:mimeType="image/*" />
221            </intent-filter>
222        </activity>
223        <activity
224            android:name=".ui.ShareViaAccountActivity"
225            android:label="@string/title_activity_share_via_account"
226            android:launchMode="singleTop"
227            android:exported="true" />
228        <activity
229            android:name=".ui.EditAccountActivity"
230            android:launchMode="singleTop"
231            android:exported="true"
232            android:windowSoftInputMode="stateHidden|adjustResize" />
233        <activity
234            android:name=".ui.ConferenceDetailsActivity"
235            android:label="@string/action_muc_details"
236            android:exported="true"
237            android:windowSoftInputMode="stateHidden" />
238        <activity
239            android:name=".ui.ContactDetailsActivity"
240            android:exported="true"
241            android:windowSoftInputMode="stateHidden" />
242        <activity
243            android:name=".ui.PublishProfilePictureActivity"
244            android:label="@string/mgmt_account_publish_avatar"
245            android:exported="true"
246            android:windowSoftInputMode="stateHidden" />
247        <activity
248            android:name=".ui.PublishGroupChatProfilePictureActivity"
249            android:exported="true"
250            android:label="@string/group_chat_avatar" />
251        <activity
252            android:name=".ui.ShareWithActivity"
253            android:label="@string/app_name"
254            android:launchMode="singleTop"
255            android:exported="true">
256            <intent-filter>
257                <action android:name="android.intent.action.SEND" />
258                <action android:name="android.intent.action.SEND_MULTIPLE" />
259
260                <category android:name="android.intent.category.DEFAULT" />
261
262                <data android:mimeType="text/plain" />
263            </intent-filter>
264            <intent-filter>
265                <action android:name="android.intent.action.SEND" />
266                <action android:name="android.intent.action.SEND_MULTIPLE" />
267
268                <category android:name="android.intent.category.DEFAULT" />
269
270                <data android:mimeType="*/*" />
271            </intent-filter>
272
273            <!-- the value here needs to be the full class name; independent of the configured applicationId -->
274            <meta-data
275                android:name="android.service.chooser.chooser_target_service"
276                android:value="eu.siacs.conversations.services.ContactChooserTargetService" />
277        </activity>
278        <activity
279            android:name=".ui.TrustKeysActivity"
280            android:label="@string/trust_omemo_fingerprints"
281            android:exported="true"
282            android:windowSoftInputMode="stateAlwaysHidden" />
283        <activity
284            android:name="com.theartofdev.edmodo.cropper.CropImageActivity"
285            android:exported="true"
286            android:theme="@style/Base.Theme.AppCompat" />
287        <activity android:name=".ui.MemorizingActivity"
288            android:exported="true" />
289        <activity
290            android:name=".ui.MediaBrowserActivity"
291            android:exported="true"
292            android:label="@string/media_browser" />
293
294        <service android:name=".services.ExportBackupService" android:exported="true"/>
295        <service android:name=".services.ImportBackupService" android:exported="true"/>
296        <service
297            android:name=".services.ContactChooserTargetService"
298            android:permission="android.permission.BIND_CHOOSER_TARGET_SERVICE"
299            android:exported="true">
300            <intent-filter>
301                <action android:name="android.service.chooser.ChooserTargetService" />
302            </intent-filter>
303        </service>
304        <service android:name=".services.CompulsoryUpdateService" android:exported="true"/>
305
306        <provider
307            android:name="androidx.core.content.FileProvider"
308            android:authorities="${applicationId}.files"
309            android:exported="false"
310            android:grantUriPermissions="true">
311            <meta-data
312                android:name="android.support.FILE_PROVIDER_PATHS"
313                android:resource="@xml/file_paths" />
314        </provider>
315        <provider
316            android:name=".services.BarcodeProvider"
317            android:authorities="${applicationId}.barcodes"
318            android:exported="false"
319            android:grantUriPermissions="true" />
320
321        <activity
322            android:name=".ui.ShortcutActivity"
323            android:label="@string/contact"
324            android:exported="true">
325            <intent-filter>
326                <action android:name="android.intent.action.CREATE_SHORTCUT" />
327            </intent-filter>
328        </activity>
329        <activity
330            android:name=".ui.MucUsersActivity"
331            android:exported="true"
332            android:label="@string/group_chat_members" />
333        <activity
334            android:name=".ui.ChannelDiscoveryActivity"
335            android:exported="true"
336            android:label="@string/discover_channels" />
337        <activity
338            android:name=".ui.RtpSessionActivity"
339            android:autoRemoveFromRecents="true"
340            android:exported="true"
341            android:launchMode="singleInstance"
342            android:supportsPictureInPicture="true" />
343    </application>
344
345</manifest>
346

My second manifest file:

1<?xml version="1.0" encoding="utf-8"?>
2<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3    xmlns:tools="http://schemas.android.com/tools"
4    package="eu.siacs.conversations">
5
6    <uses-sdk tools:overrideLibrary="net.ypresto.androidtranscoder" />
7
8    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
9    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
10    <uses-permission android:name="android.permission.READ_CONTACTS" />
11    <uses-permission android:name="android.permission.READ_PROFILE" />
12    <uses-permission
13        android:name="android.permission.READ_PHONE_STATE"
14        android:maxSdkVersion="22" />
15    <uses-permission android:name="android.permission.INTERNET" />
16    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
17    <uses-permission android:name="android.permission.WAKE_LOCK" />
18    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
19    <uses-permission android:name="android.permission.VIBRATE" />
20    <uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" />
21    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
22    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
23    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
24    <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
25    <uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
26
27    <uses-feature
28        android:name="android.hardware.location"
29        android:required="false" />
30    <uses-feature
31        android:name="android.hardware.location.gps"
32        android:required="false" />
33    <uses-feature
34        android:name="android.hardware.location.network"
35        android:required="false" />
36
37    <uses-permission android:name="android.permission.CAMERA" />
38    <uses-permission android:name="android.permission.RECORD_AUDIO" />
39    <uses-permission android:name="android.permission.BLUETOOTH" />
40    <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
41    <uses-permission android:name="android.permission.USE_FULL_SCREEN_INTENT" />
42    <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
43
44    <uses-feature
45        android:name="android.hardware.camera"
46        android:required="false" />
47    <uses-feature
48        android:name="android.hardware.camera.autofocus"
49        android:required="false" />
50    <uses-feature
51        android:name="android.hardware.microphone"
52        android:required="false" />
53
54    <application
55        android:name=".Application"
56        android:allowBackup="false"
57        android:allowClearUserData="true"
58        android:appCategory="social"
59        android:hardwareAccelerated="true"
60        android:icon="@mipmap/ic_app_launch"
61        android:label="@string/app_name"
62        android:largeHeap="true"
63        android:networkSecurityConfig="@xml/network_security_configuration"
64        android:requestLegacyExternalStorage="true"
65        android:roundIcon="@mipmap/ic_app_launch_round"
66        android:theme="@style/ConversationsTheme"
67        android:usesCleartextTraffic="true"
68        android:windowSoftInputMode="adjustPan|adjustResize"
69        tools:replace="android:label"
70        tools:targetApi="q">
71        <activity
72            android:name=".ui.search.GroupSearchActivity"
73            android:exported="true" />
74        <activity
75            android:name=".ui.profileUpdating.FavouritesActivity"
76            android:exported="true" />
77        <activity
78            android:name=".ui.profileUpdating.NameActivity"
79            android:exported="true" />
80        <activity
81            android:name=".ui.CompulsoryUpdateActivity"
82            android:exported="true" />
83        <activity android:name=".ui.payments.doPayment.DoPaymentActivity"
84            android:exported="true" />
85        <activity android:name=".ui.individualList.IndividualListActivity"
86            android:exported="true" />
87        <activity android:name=".ui.payments.setPayment.SetPaymentActivity"
88            android:exported="true" />
89        <activity android:name=".ui.login.otpActivity.OTPActivity"
90            android:exported="true" />
91        <activity android:name=".ui.login.loginActivity.LoginActivity"
92            android:exported="true" />
93
94        <service android:name=".services.XmppConnectionService" android:exported="true" />
95
96        <receiver android:name=".services.EventReceiver"
97            android:exported="true">
98            <intent-filter>
99                <action android:name="android.intent.action.BOOT_COMPLETED" />
100                <action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
101                <action android:name="android.intent.action.ACTION_SHUTDOWN" />
102                <action android:name="android.media.RINGER_MODE_CHANGED" />
103            </intent-filter>
104        </receiver>
105
106        <activity
107            android:name=".ui.ShareLocationActivity"
108            android:label="@string/title_activity_share_location"
109            android:exported="true"/>
110        <activity
111            android:name=".ui.SearchActivity"
112            android:label="@string/search_messages"
113            android:exported="true" />
114        <activity
115            android:name=".ui.RecordingActivity"
116            android:configChanges="orientation|screenSize"
117            android:theme="@style/ConversationsTheme.Dialog"
118            android:exported="true" />
119        <activity
120            android:name=".ui.ShowLocationActivity"
121            android:label="@string/title_activity_show_location"
122            android:exported="true" />
123        <activity
124            android:name=".ui.SplashActivity"
125            android:theme="@style/SplashTheme"
126            android:exported="true">
127            <intent-filter>
128                <action android:name="android.intent.action.MAIN" />
129
130                <category android:name="android.intent.category.LAUNCHER" />
131            </intent-filter>
132        </activity>
133        <activity
134            android:name=".ui.ConversationsActivity"
135            android:label="@string/app_name"
136            android:launchMode="singleTask"
137            android:minWidth="300dp"
138            android:minHeight="300dp"
139            android:exported="true"
140            android:windowSoftInputMode="stateHidden" />
141        <activity
142            android:name=".ui.ScanActivity"
143            android:screenOrientation="portrait"
144            android:exported="true"
145            android:theme="@style/ConversationsTheme.FullScreen"
146            android:windowSoftInputMode="stateAlwaysHidden" />
147        <activity
148            android:name=".ui.UriHandlerActivity"
149            android:label="@string/app_name"
150            android:exported="true">
151            <intent-filter>
152                <action android:name="android.intent.action.VIEW" />
153
154                <category android:name="android.intent.category.DEFAULT" />
155                <category android:name="android.intent.category.BROWSABLE" />
156
157                <data android:scheme="xmpp" />
158            </intent-filter>
159            <intent-filter android:autoVerify="true">
160                <action android:name="android.intent.action.VIEW" />
161
162                <category android:name="android.intent.category.DEFAULT" />
163                <category android:name="android.intent.category.BROWSABLE" />
164
165                <data android:scheme="https" />
166                <data android:host="im.app.in" />
167                <data android:pathPrefix="/i/" />
168                <data android:pathPrefix="/j/" />
169            </intent-filter>
170            <intent-filter>
171                <action android:name="android.intent.action.SENDTO" />
172
173                <category android:name="android.intent.category.DEFAULT" />
174
175                <data android:scheme="imto" />
176                <data android:host="jabber" />
177            </intent-filter>
178        </activity>
179        <activity
180            android:name=".ui.StartConversationActivity"
181            android:label="@string/title_activity_start_conversation"
182            android:launchMode="singleTop"
183            android:exported="true">
184            <intent-filter>
185                <action android:name="android.intent.action.VIEW" />
186            </intent-filter>
187        </activity>
188        <activity
189            android:name=".ui.SettingsActivity"
190            android:label="@string/title_activity_settings"
191            android:exported="true">
192            <intent-filter>
193                <action android:name="android.intent.action.MAIN" />
194
195                <category android:name="android.intent.category.NOTIFICATION_PREFERENCES" />
196            </intent-filter>
197        </activity>
198        <activity
199            android:name=".ui.ChooseContactActivity"
200            android:label="@string/title_activity_choose_contact"
201            android:exported="true" />
202        <activity
203            android:name=".ui.BlocklistActivity"
204            android:label="@string/title_activity_block_list"
205            android:exported="true"/>
206        <activity
207            android:name=".ui.ChangePasswordActivity"
208            android:label="@string/change_password_on_server"
209            android:exported="true"/>
210        <activity
211            android:name=".ui.ChooseAccountForProfilePictureActivity"
212            android:enabled="false"
213            android:label="@string/choose_account"
214            android:exported="true">
215            <intent-filter android:label="@string/set_profile_picture">
216                <action android:name="android.intent.action.ATTACH_DATA" />
217
218                <category android:name="android.intent.category.DEFAULT" />
219
220                <data android:mimeType="image/*" />
221            </intent-filter>
222        </activity>
223        <activity
224            android:name=".ui.ShareViaAccountActivity"
225            android:label="@string/title_activity_share_via_account"
226            android:launchMode="singleTop"
227            android:exported="true" />
228        <activity
229            android:name=".ui.EditAccountActivity"
230            android:launchMode="singleTop"
231            android:exported="true"
232            android:windowSoftInputMode="stateHidden|adjustResize" />
233        <activity
234            android:name=".ui.ConferenceDetailsActivity"
235            android:label="@string/action_muc_details"
236            android:exported="true"
237            android:windowSoftInputMode="stateHidden" />
238        <activity
239            android:name=".ui.ContactDetailsActivity"
240            android:exported="true"
241            android:windowSoftInputMode="stateHidden" />
242        <activity
243            android:name=".ui.PublishProfilePictureActivity"
244            android:label="@string/mgmt_account_publish_avatar"
245            android:exported="true"
246            android:windowSoftInputMode="stateHidden" />
247        <activity
248            android:name=".ui.PublishGroupChatProfilePictureActivity"
249            android:exported="true"
250            android:label="@string/group_chat_avatar" />
251        <activity
252            android:name=".ui.ShareWithActivity"
253            android:label="@string/app_name"
254            android:launchMode="singleTop"
255            android:exported="true">
256            <intent-filter>
257                <action android:name="android.intent.action.SEND" />
258                <action android:name="android.intent.action.SEND_MULTIPLE" />
259
260                <category android:name="android.intent.category.DEFAULT" />
261
262                <data android:mimeType="text/plain" />
263            </intent-filter>
264            <intent-filter>
265                <action android:name="android.intent.action.SEND" />
266                <action android:name="android.intent.action.SEND_MULTIPLE" />
267
268                <category android:name="android.intent.category.DEFAULT" />
269
270                <data android:mimeType="*/*" />
271            </intent-filter>
272
273            <!-- the value here needs to be the full class name; independent of the configured applicationId -->
274            <meta-data
275                android:name="android.service.chooser.chooser_target_service"
276                android:value="eu.siacs.conversations.services.ContactChooserTargetService" />
277        </activity>
278        <activity
279            android:name=".ui.TrustKeysActivity"
280            android:label="@string/trust_omemo_fingerprints"
281            android:exported="true"
282            android:windowSoftInputMode="stateAlwaysHidden" />
283        <activity
284            android:name="com.theartofdev.edmodo.cropper.CropImageActivity"
285            android:exported="true"
286            android:theme="@style/Base.Theme.AppCompat" />
287        <activity android:name=".ui.MemorizingActivity"
288            android:exported="true" />
289        <activity
290            android:name=".ui.MediaBrowserActivity"
291            android:exported="true"
292            android:label="@string/media_browser" />
293
294        <service android:name=".services.ExportBackupService" android:exported="true"/>
295        <service android:name=".services.ImportBackupService" android:exported="true"/>
296        <service
297            android:name=".services.ContactChooserTargetService"
298            android:permission="android.permission.BIND_CHOOSER_TARGET_SERVICE"
299            android:exported="true">
300            <intent-filter>
301                <action android:name="android.service.chooser.ChooserTargetService" />
302            </intent-filter>
303        </service>
304        <service android:name=".services.CompulsoryUpdateService" android:exported="true"/>
305
306        <provider
307            android:name="androidx.core.content.FileProvider"
308            android:authorities="${applicationId}.files"
309            android:exported="false"
310            android:grantUriPermissions="true">
311            <meta-data
312                android:name="android.support.FILE_PROVIDER_PATHS"
313                android:resource="@xml/file_paths" />
314        </provider>
315        <provider
316            android:name=".services.BarcodeProvider"
317            android:authorities="${applicationId}.barcodes"
318            android:exported="false"
319            android:grantUriPermissions="true" />
320
321        <activity
322            android:name=".ui.ShortcutActivity"
323            android:label="@string/contact"
324            android:exported="true">
325            <intent-filter>
326                <action android:name="android.intent.action.CREATE_SHORTCUT" />
327            </intent-filter>
328        </activity>
329        <activity
330            android:name=".ui.MucUsersActivity"
331            android:exported="true"
332            android:label="@string/group_chat_members" />
333        <activity
334            android:name=".ui.ChannelDiscoveryActivity"
335            android:exported="true"
336            android:label="@string/discover_channels" />
337        <activity
338            android:name=".ui.RtpSessionActivity"
339            android:autoRemoveFromRecents="true"
340            android:exported="true"
341            android:launchMode="singleInstance"
342            android:supportsPictureInPicture="true" />
343    </application>
344
345</manifest>
346<?xml version="1.0" encoding="utf-8"?>
347<manifest xmlns:android="http://schemas.android.com/apk/res/android"
348    xmlns:tools="http://schemas.android.com/tools"
349    package="eu.siacs.conversations">
350
351    <application tools:ignore="GoogleAppIndexingWarning">
352        <activity
353            android:name=".ui.ManageAccountActivity"
354            android:label="@string/title_activity_manage_accounts"
355            android:launchMode="singleTask"
356            android:exported="true"/>
357        <activity
358            android:name=".ui.MagicCreateActivity"
359            android:label="@string/create_new_account"
360            android:launchMode="singleTask"
361            android:exported="true"/>
362        <activity
363            android:name=".ui.EasyOnboardingInviteActivity"
364            android:label="@string/invite_to_app"
365            android:launchMode="singleTask" />
366        <activity
367            android:name=".ui.ImportBackupActivity"
368            android:label="@string/restore_backup"
369            android:launchMode="singleTask"
370            android:exported="true">
371            <intent-filter>
372                <action android:name="android.intent.action.VIEW" />
373                <category android:name="android.intent.category.DEFAULT" />
374
375                <data android:mimeType="application/vnd.conversations.backup" />
376                <data android:scheme="content" />
377            </intent-filter>
378            <intent-filter>
379                <action android:name="android.intent.action.VIEW" />
380                <category android:name="android.intent.category.DEFAULT" />
381
382                <data android:mimeType="application/vnd.conversations.backup" />
383                <data android:scheme="file" />
384            </intent-filter>
385            <intent-filter>
386                <action android:name="android.intent.action.VIEW" />
387
388                <category android:name="android.intent.category.DEFAULT" />
389                <category android:name="android.intent.category.BROWSABLE" />
390
391                <data android:scheme="content" />
392                <data android:host="*" />
393                <data android:mimeType="*/*" />
394                <data android:pathPattern=".*\\.ceb" />
395                <data android:pathPattern=".*\\..*\\.ceb" />
396                <data android:pathPattern=".*\\..*\\..*\\.ceb" />
397                <data android:pathPattern=".*\\..*\\..*\\..*\\.ceb" />
398                <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\.ceb" />
399                <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\.ceb" />
400                <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\.ceb" />
401            </intent-filter>
402            <intent-filter>
403                <action android:name="android.intent.action.VIEW" />
404
405                <category android:name="android.intent.category.DEFAULT" />
406                <category android:name="android.intent.category.BROWSABLE" />
407
408                <data android:scheme="file" />
409                <data android:host="*" />
410                <data android:mimeType="*/*" />
411                <data android:pathPattern=".*\\.ceb" />
412                <data android:pathPattern=".*\\..*\\.ceb" />
413                <data android:pathPattern=".*\\..*\\..*\\.ceb" />
414                <data android:pathPattern=".*\\..*\\..*\\..*\\.ceb" />
415                <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\.ceb" />
416                <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\.ceb" />
417                <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\.ceb" />
418            </intent-filter>
419        </activity>
420    </application>
421</manifest>
422
423

My gradle file:

1<?xml version="1.0" encoding="utf-8"?>
2<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3    xmlns:tools="http://schemas.android.com/tools"
4    package="eu.siacs.conversations">
5
6    <uses-sdk tools:overrideLibrary="net.ypresto.androidtranscoder" />
7
8    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
9    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
10    <uses-permission android:name="android.permission.READ_CONTACTS" />
11    <uses-permission android:name="android.permission.READ_PROFILE" />
12    <uses-permission
13        android:name="android.permission.READ_PHONE_STATE"
14        android:maxSdkVersion="22" />
15    <uses-permission android:name="android.permission.INTERNET" />
16    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
17    <uses-permission android:name="android.permission.WAKE_LOCK" />
18    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
19    <uses-permission android:name="android.permission.VIBRATE" />
20    <uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" />
21    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
22    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
23    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
24    <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
25    <uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
26
27    <uses-feature
28        android:name="android.hardware.location"
29        android:required="false" />
30    <uses-feature
31        android:name="android.hardware.location.gps"
32        android:required="false" />
33    <uses-feature
34        android:name="android.hardware.location.network"
35        android:required="false" />
36
37    <uses-permission android:name="android.permission.CAMERA" />
38    <uses-permission android:name="android.permission.RECORD_AUDIO" />
39    <uses-permission android:name="android.permission.BLUETOOTH" />
40    <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
41    <uses-permission android:name="android.permission.USE_FULL_SCREEN_INTENT" />
42    <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
43
44    <uses-feature
45        android:name="android.hardware.camera"
46        android:required="false" />
47    <uses-feature
48        android:name="android.hardware.camera.autofocus"
49        android:required="false" />
50    <uses-feature
51        android:name="android.hardware.microphone"
52        android:required="false" />
53
54    <application
55        android:name=".Application"
56        android:allowBackup="false"
57        android:allowClearUserData="true"
58        android:appCategory="social"
59        android:hardwareAccelerated="true"
60        android:icon="@mipmap/ic_app_launch"
61        android:label="@string/app_name"
62        android:largeHeap="true"
63        android:networkSecurityConfig="@xml/network_security_configuration"
64        android:requestLegacyExternalStorage="true"
65        android:roundIcon="@mipmap/ic_app_launch_round"
66        android:theme="@style/ConversationsTheme"
67        android:usesCleartextTraffic="true"
68        android:windowSoftInputMode="adjustPan|adjustResize"
69        tools:replace="android:label"
70        tools:targetApi="q">
71        <activity
72            android:name=".ui.search.GroupSearchActivity"
73            android:exported="true" />
74        <activity
75            android:name=".ui.profileUpdating.FavouritesActivity"
76            android:exported="true" />
77        <activity
78            android:name=".ui.profileUpdating.NameActivity"
79            android:exported="true" />
80        <activity
81            android:name=".ui.CompulsoryUpdateActivity"
82            android:exported="true" />
83        <activity android:name=".ui.payments.doPayment.DoPaymentActivity"
84            android:exported="true" />
85        <activity android:name=".ui.individualList.IndividualListActivity"
86            android:exported="true" />
87        <activity android:name=".ui.payments.setPayment.SetPaymentActivity"
88            android:exported="true" />
89        <activity android:name=".ui.login.otpActivity.OTPActivity"
90            android:exported="true" />
91        <activity android:name=".ui.login.loginActivity.LoginActivity"
92            android:exported="true" />
93
94        <service android:name=".services.XmppConnectionService" android:exported="true" />
95
96        <receiver android:name=".services.EventReceiver"
97            android:exported="true">
98            <intent-filter>
99                <action android:name="android.intent.action.BOOT_COMPLETED" />
100                <action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
101                <action android:name="android.intent.action.ACTION_SHUTDOWN" />
102                <action android:name="android.media.RINGER_MODE_CHANGED" />
103            </intent-filter>
104        </receiver>
105
106        <activity
107            android:name=".ui.ShareLocationActivity"
108            android:label="@string/title_activity_share_location"
109            android:exported="true"/>
110        <activity
111            android:name=".ui.SearchActivity"
112            android:label="@string/search_messages"
113            android:exported="true" />
114        <activity
115            android:name=".ui.RecordingActivity"
116            android:configChanges="orientation|screenSize"
117            android:theme="@style/ConversationsTheme.Dialog"
118            android:exported="true" />
119        <activity
120            android:name=".ui.ShowLocationActivity"
121            android:label="@string/title_activity_show_location"
122            android:exported="true" />
123        <activity
124            android:name=".ui.SplashActivity"
125            android:theme="@style/SplashTheme"
126            android:exported="true">
127            <intent-filter>
128                <action android:name="android.intent.action.MAIN" />
129
130                <category android:name="android.intent.category.LAUNCHER" />
131            </intent-filter>
132        </activity>
133        <activity
134            android:name=".ui.ConversationsActivity"
135            android:label="@string/app_name"
136            android:launchMode="singleTask"
137            android:minWidth="300dp"
138            android:minHeight="300dp"
139            android:exported="true"
140            android:windowSoftInputMode="stateHidden" />
141        <activity
142            android:name=".ui.ScanActivity"
143            android:screenOrientation="portrait"
144            android:exported="true"
145            android:theme="@style/ConversationsTheme.FullScreen"
146            android:windowSoftInputMode="stateAlwaysHidden" />
147        <activity
148            android:name=".ui.UriHandlerActivity"
149            android:label="@string/app_name"
150            android:exported="true">
151            <intent-filter>
152                <action android:name="android.intent.action.VIEW" />
153
154                <category android:name="android.intent.category.DEFAULT" />
155                <category android:name="android.intent.category.BROWSABLE" />
156
157                <data android:scheme="xmpp" />
158            </intent-filter>
159            <intent-filter android:autoVerify="true">
160                <action android:name="android.intent.action.VIEW" />
161
162                <category android:name="android.intent.category.DEFAULT" />
163                <category android:name="android.intent.category.BROWSABLE" />
164
165                <data android:scheme="https" />
166                <data android:host="im.app.in" />
167                <data android:pathPrefix="/i/" />
168                <data android:pathPrefix="/j/" />
169            </intent-filter>
170            <intent-filter>
171                <action android:name="android.intent.action.SENDTO" />
172
173                <category android:name="android.intent.category.DEFAULT" />
174
175                <data android:scheme="imto" />
176                <data android:host="jabber" />
177            </intent-filter>
178        </activity>
179        <activity
180            android:name=".ui.StartConversationActivity"
181            android:label="@string/title_activity_start_conversation"
182            android:launchMode="singleTop"
183            android:exported="true">
184            <intent-filter>
185                <action android:name="android.intent.action.VIEW" />
186            </intent-filter>
187        </activity>
188        <activity
189            android:name=".ui.SettingsActivity"
190            android:label="@string/title_activity_settings"
191            android:exported="true">
192            <intent-filter>
193                <action android:name="android.intent.action.MAIN" />
194
195                <category android:name="android.intent.category.NOTIFICATION_PREFERENCES" />
196            </intent-filter>
197        </activity>
198        <activity
199            android:name=".ui.ChooseContactActivity"
200            android:label="@string/title_activity_choose_contact"
201            android:exported="true" />
202        <activity
203            android:name=".ui.BlocklistActivity"
204            android:label="@string/title_activity_block_list"
205            android:exported="true"/>
206        <activity
207            android:name=".ui.ChangePasswordActivity"
208            android:label="@string/change_password_on_server"
209            android:exported="true"/>
210        <activity
211            android:name=".ui.ChooseAccountForProfilePictureActivity"
212            android:enabled="false"
213            android:label="@string/choose_account"
214            android:exported="true">
215            <intent-filter android:label="@string/set_profile_picture">
216                <action android:name="android.intent.action.ATTACH_DATA" />
217
218                <category android:name="android.intent.category.DEFAULT" />
219
220                <data android:mimeType="image/*" />
221            </intent-filter>
222        </activity>
223        <activity
224            android:name=".ui.ShareViaAccountActivity"
225            android:label="@string/title_activity_share_via_account"
226            android:launchMode="singleTop"
227            android:exported="true" />
228        <activity
229            android:name=".ui.EditAccountActivity"
230            android:launchMode="singleTop"
231            android:exported="true"
232            android:windowSoftInputMode="stateHidden|adjustResize" />
233        <activity
234            android:name=".ui.ConferenceDetailsActivity"
235            android:label="@string/action_muc_details"
236            android:exported="true"
237            android:windowSoftInputMode="stateHidden" />
238        <activity
239            android:name=".ui.ContactDetailsActivity"
240            android:exported="true"
241            android:windowSoftInputMode="stateHidden" />
242        <activity
243            android:name=".ui.PublishProfilePictureActivity"
244            android:label="@string/mgmt_account_publish_avatar"
245            android:exported="true"
246            android:windowSoftInputMode="stateHidden" />
247        <activity
248            android:name=".ui.PublishGroupChatProfilePictureActivity"
249            android:exported="true"
250            android:label="@string/group_chat_avatar" />
251        <activity
252            android:name=".ui.ShareWithActivity"
253            android:label="@string/app_name"
254            android:launchMode="singleTop"
255            android:exported="true">
256            <intent-filter>
257                <action android:name="android.intent.action.SEND" />
258                <action android:name="android.intent.action.SEND_MULTIPLE" />
259
260                <category android:name="android.intent.category.DEFAULT" />
261
262                <data android:mimeType="text/plain" />
263            </intent-filter>
264            <intent-filter>
265                <action android:name="android.intent.action.SEND" />
266                <action android:name="android.intent.action.SEND_MULTIPLE" />
267
268                <category android:name="android.intent.category.DEFAULT" />
269
270                <data android:mimeType="*/*" />
271            </intent-filter>
272
273            <!-- the value here needs to be the full class name; independent of the configured applicationId -->
274            <meta-data
275                android:name="android.service.chooser.chooser_target_service"
276                android:value="eu.siacs.conversations.services.ContactChooserTargetService" />
277        </activity>
278        <activity
279            android:name=".ui.TrustKeysActivity"
280            android:label="@string/trust_omemo_fingerprints"
281            android:exported="true"
282            android:windowSoftInputMode="stateAlwaysHidden" />
283        <activity
284            android:name="com.theartofdev.edmodo.cropper.CropImageActivity"
285            android:exported="true"
286            android:theme="@style/Base.Theme.AppCompat" />
287        <activity android:name=".ui.MemorizingActivity"
288            android:exported="true" />
289        <activity
290            android:name=".ui.MediaBrowserActivity"
291            android:exported="true"
292            android:label="@string/media_browser" />
293
294        <service android:name=".services.ExportBackupService" android:exported="true"/>
295        <service android:name=".services.ImportBackupService" android:exported="true"/>
296        <service
297            android:name=".services.ContactChooserTargetService"
298            android:permission="android.permission.BIND_CHOOSER_TARGET_SERVICE"
299            android:exported="true">
300            <intent-filter>
301                <action android:name="android.service.chooser.ChooserTargetService" />
302            </intent-filter>
303        </service>
304        <service android:name=".services.CompulsoryUpdateService" android:exported="true"/>
305
306        <provider
307            android:name="androidx.core.content.FileProvider"
308            android:authorities="${applicationId}.files"
309            android:exported="false"
310            android:grantUriPermissions="true">
311            <meta-data
312                android:name="android.support.FILE_PROVIDER_PATHS"
313                android:resource="@xml/file_paths" />
314        </provider>
315        <provider
316            android:name=".services.BarcodeProvider"
317            android:authorities="${applicationId}.barcodes"
318            android:exported="false"
319            android:grantUriPermissions="true" />
320
321        <activity
322            android:name=".ui.ShortcutActivity"
323            android:label="@string/contact"
324            android:exported="true">
325            <intent-filter>
326                <action android:name="android.intent.action.CREATE_SHORTCUT" />
327            </intent-filter>
328        </activity>
329        <activity
330            android:name=".ui.MucUsersActivity"
331            android:exported="true"
332            android:label="@string/group_chat_members" />
333        <activity
334            android:name=".ui.ChannelDiscoveryActivity"
335            android:exported="true"
336            android:label="@string/discover_channels" />
337        <activity
338            android:name=".ui.RtpSessionActivity"
339            android:autoRemoveFromRecents="true"
340            android:exported="true"
341            android:launchMode="singleInstance"
342            android:supportsPictureInPicture="true" />
343    </application>
344
345</manifest>
346<?xml version="1.0" encoding="utf-8"?>
347<manifest xmlns:android="http://schemas.android.com/apk/res/android"
348    xmlns:tools="http://schemas.android.com/tools"
349    package="eu.siacs.conversations">
350
351    <application tools:ignore="GoogleAppIndexingWarning">
352        <activity
353            android:name=".ui.ManageAccountActivity"
354            android:label="@string/title_activity_manage_accounts"
355            android:launchMode="singleTask"
356            android:exported="true"/>
357        <activity
358            android:name=".ui.MagicCreateActivity"
359            android:label="@string/create_new_account"
360            android:launchMode="singleTask"
361            android:exported="true"/>
362        <activity
363            android:name=".ui.EasyOnboardingInviteActivity"
364            android:label="@string/invite_to_app"
365            android:launchMode="singleTask" />
366        <activity
367            android:name=".ui.ImportBackupActivity"
368            android:label="@string/restore_backup"
369            android:launchMode="singleTask"
370            android:exported="true">
371            <intent-filter>
372                <action android:name="android.intent.action.VIEW" />
373                <category android:name="android.intent.category.DEFAULT" />
374
375                <data android:mimeType="application/vnd.conversations.backup" />
376                <data android:scheme="content" />
377            </intent-filter>
378            <intent-filter>
379                <action android:name="android.intent.action.VIEW" />
380                <category android:name="android.intent.category.DEFAULT" />
381
382                <data android:mimeType="application/vnd.conversations.backup" />
383                <data android:scheme="file" />
384            </intent-filter>
385            <intent-filter>
386                <action android:name="android.intent.action.VIEW" />
387
388                <category android:name="android.intent.category.DEFAULT" />
389                <category android:name="android.intent.category.BROWSABLE" />
390
391                <data android:scheme="content" />
392                <data android:host="*" />
393                <data android:mimeType="*/*" />
394                <data android:pathPattern=".*\\.ceb" />
395                <data android:pathPattern=".*\\..*\\.ceb" />
396                <data android:pathPattern=".*\\..*\\..*\\.ceb" />
397                <data android:pathPattern=".*\\..*\\..*\\..*\\.ceb" />
398                <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\.ceb" />
399                <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\.ceb" />
400                <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\.ceb" />
401            </intent-filter>
402            <intent-filter>
403                <action android:name="android.intent.action.VIEW" />
404
405                <category android:name="android.intent.category.DEFAULT" />
406                <category android:name="android.intent.category.BROWSABLE" />
407
408                <data android:scheme="file" />
409                <data android:host="*" />
410                <data android:mimeType="*/*" />
411                <data android:pathPattern=".*\\.ceb" />
412                <data android:pathPattern=".*\\..*\\.ceb" />
413                <data android:pathPattern=".*\\..*\\..*\\.ceb" />
414                <data android:pathPattern=".*\\..*\\..*\\..*\\.ceb" />
415                <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\.ceb" />
416                <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\.ceb" />
417                <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\.ceb" />
418            </intent-filter>
419        </activity>
420    </application>
421</manifest>
422
423import com.android.build.OutputFile
424
425// Top-level build file where you can add configuration options common to all
426// sub-projects/modules.
427buildscript {
428    ext.kotlin_version = "1.5.21"
429    repositories {
430        google()
431        mavenCentral()
432        maven { url 'https://jitpack.io' }
433        gradlePluginPortal()
434    }
435    dependencies {
436        classpath 'com.android.tools.build:gradle:4.2.2'
437        classpath 'com.google.gms:google-services:4.3.8'
438        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
439    }
440}
441
442apply plugin: 'com.android.application'
443apply plugin: 'kotlin-android'
444apply plugin: 'kotlin-kapt'
445apply plugin: 'com.google.gms.google-services'
446
447repositories {
448    google()
449    mavenCentral()
450    jcenter()
451    maven { url 'https://jitpack.io' }
452}
453
454configurations {
455    conversationsFreeCompatImplementation
456}
457
458dependencies {
459    implementation 'androidx.viewpager:viewpager:1.0.0'
460    implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
461
462    implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
463
464    implementation 'org.sufficientlysecure:openpgp-api:10.0'
465    implementation 'com.theartofdev.edmodo:android-image-cropper:2.8.0'
466    implementation 'androidx.appcompat:appcompat:1.3.1'
467    implementation 'androidx.exifinterface:exifinterface:1.3.2'
468    implementation 'androidx.cardview:cardview:1.0.0'
469    implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
470    implementation 'androidx.emoji:emoji:1.1.0'
471    implementation 'com.google.android.material:material:1.4.0'
472    conversationsFreeCompatImplementation 'androidx.emoji:emoji-bundled:1.1.0'
473    implementation 'org.bouncycastle:bcmail-jdk15on:1.64'
474    //zxing stopped supporting Java 7 so we have to stick with 3.3.3
475    //https://github.com/zxing/zxing/issues/1170
476    implementation 'com.google.zxing:core:3.4.1'
477    implementation 'de.measite.minidns:minidns-hla:0.2.4'
478    implementation 'me.leolin:ShortcutBadger:1.1.22@aar'
479    implementation 'org.whispersystems:signal-protocol-java:2.8.1'
480    implementation 'com.makeramen:roundedimageview:2.3.0'
481    implementation "com.wefika:flowlayout:0.4.1"
482    implementation 'net.ypresto.androidtranscoder:android-transcoder:0.3.0'
483    implementation 'org.jxmpp:jxmpp-jid:1.0.1'
484    implementation 'org.osmdroid:osmdroid-android:6.1.10'
485    implementation 'org.hsluv:hsluv:0.2'
486    implementation 'org.conscrypt:conscrypt-android:2.5.2'
487    implementation 'me.drakeet.support:toastcompat:1.1.0'
488    implementation "com.leinardi.android:speed-dial:3.2.0"
489
490    implementation "com.squareup.retrofit2:retrofit:2.9.0"
491    implementation "com.squareup.retrofit2:converter-gson:2.9.0"
492    implementation "com.squareup.okhttp3:okhttp:5.0.0-alpha.2"
493    implementation 'com.squareup.okhttp3:logging-interceptor:5.0.0-alpha.2'
494
495    implementation 'com.google.guava:guava:30.1.1-android'
496    implementation 'org.webrtc:google-webrtc:1.0.32006'
497
498    // Lifecycle Helper
499    implementation "androidx.activity:activity-ktx:1.3.0-rc02"
500    implementation "androidx.fragment:fragment-ktx:1.3.6"
501
502    //Navigation
503    implementation 'androidx.navigation:navigation-fragment-ktx:2.3.5'
504    implementation 'androidx.navigation:navigation-ui-ktx:2.3.5'
505
506    //CardView
507    implementation "androidx.cardview:cardview:1.0.0"
508
509    //Country Code Picker
510    implementation 'com.hbb20:ccp:2.5.3'
511
512    //Firebase
513    implementation 'com.google.firebase:firebase-bom:28.3.0'
514    implementation 'com.google.firebase:firebase-auth-ktx:21.0.1'
515    implementation 'androidx.browser:browser:1.3.0'
516
517    //OTP view
518    implementation 'com.github.mukeshsolanki:android-otpview-pinview:2.1.2'
519
520    //Retrofit
521    implementation 'com.squareup.retrofit2:retrofit:2.9.0'
522    implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
523
524    //Gson
525    implementation 'com.google.code.gson:gson:2.8.7'
526
527    //Multidex
528    implementation 'androidx.multidex:multidex:2.0.1'
529
530    //Round Image
531    implementation 'de.hdodenhof:circleimageview:3.1.0'
532
533    // Button with image and text
534    implementation 'com.github.Omega-R:OmegaCenterIconButton:0.0.4@aar'
535
536    //Razor pay
537    implementation 'com.razorpay:checkout:1.6.10'
538
539    //Mixpanel Tracking
540    implementation 'com.mixpanel.android:mixpanel-android:5.9.1'
541
542    //Loading screen
543    implementation 'com.wang.avi:library:2.1.3'
544
545    //Loading
546    implementation 'com.wang.avi:library:2.1.3'
547
548    //Form
549    implementation 'com.quickbirdstudios:surveykit:1.1.0'
550}
551
552ext {
553    travisBuild = System.getenv("TRAVIS") == "true"
554    preDexEnabled = System.getProperty("pre-dex", "true")
555    abiCodes = ['armeabi-v7a': 1, 'x86': 2, 'x86_64': 3, 'arm64-v8a': 4]
556}
557
558android {
559    compileSdkVersion 31
560
561    defaultConfig {
562        minSdkVersion 24
563        targetSdkVersion 31
564        versionCode 44
565        versionName "2.0.4"
566        multiDexEnabled = true
567        archivesBaseName += "-$versionName"
568        applicationId "com.app.app"
569        resValue "string", "applicationId", applicationId
570        def appName = "app"
571        resValue "string", "app_name", appName
572        buildConfigField "String", "APP_NAME", "\"$appName\""
573    }
574
575    splits {
576        abi {
577            universalApk true
578            enable true
579        }
580    }
581
582    configurations {
583        compile.exclude group: 'org.jetbrains' , module:'annotations'
584    }
585
586    dataBinding {
587        enabled true
588    }
589
590    dexOptions {
591        // Skip pre-dexing when running on Travis CI or when disabled via -Dpre-dex=false.
592        preDexLibraries = preDexEnabled && !travisBuild
593        jumboMode true
594    }
595
596    compileOptions {
597        sourceCompatibility JavaVersion.VERSION_1_8
598        targetCompatibility JavaVersion.VERSION_1_8
599    }
600
601    flavorDimensions("mode", "distribution", "emoji")
602
603    productFlavors {
604
605        conversations {
606            dimension "mode"
607        }
608        free {
609            dimension "distribution"
610            versionNameSuffix "+f"
611        }
612        compat {
613            dimension "emoji"
614            versionNameSuffix "c"
615        }
616    }
617
618    sourceSets {
619        conversationsFreeCompat {
620            java {
621                srcDir 'src/freeCompat/java'
622                srcDir 'src/conversationsFree/java'
623            }
624        }
625    }
626
627    buildTypes {
628        release {
629            shrinkResources true
630            minifyEnabled true
631            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
632            versionNameSuffix "r"
633        }
634        debug {
635            shrinkResources true
636            minifyEnabled true
637            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
638            versionNameSuffix "d"
639        }
640    }
641
642
643    if (new File("signing.properties").exists()) {
644        Properties props = new Properties()
645        props.load(new FileInputStream(file("signing.properties")))
646
647        signingConfigs {
648            release {
649                storeFile file(props['keystore'])
650                storePassword props['keystore.password']
651                keyAlias props['keystore.alias']
652                keyPassword props['keystore.password']
653            }
654        }
655        buildTypes.release.signingConfig = signingConfigs.release
656    }
657
658    lintOptions {
659        disable 'MissingTranslation', 'InvalidPackage','AppCompatResource'
660    }
661
662    subprojects {
663
664        afterEvaluate {
665            if (getPlugins().hasPlugin('android') ||
666                    getPlugins().hasPlugin('android-library')) {
667
668                configure(android.lintOptions) {
669                    disable 'AndroidGradlePluginVersion', 'MissingTranslation'
670                }
671            }
672
673        }
674    }
675
676    packagingOptions {
677        exclude 'META-INF/BCKEY.DSA'
678        exclude 'META-INF/BCKEY.SF'
679    }
680
681    android.applicationVariants.all { variant ->
682        variant.outputs.each { output ->
683            def baseAbiVersionCode = project.ext.abiCodes.get(output.getFilter(OutputFile.ABI))
684            if (baseAbiVersionCode != null) {
685                output.versionCodeOverride = (100 * variant.versionCode) + baseAbiVersionCode
686            }
687        }
688
689    }
690}
691

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

QUESTION

Is if(A | B) always faster than if(A || B)?

Asked 2022-Feb-11 at 05:03

I am reading this book by Fedor Pikus and he has some very very interesting examples which for me were a surprise.
Particularly this benchmark caught me, where the only difference is that in one of them we use || in if and in another we use |.

1void BM_misspredict(benchmark::State& state)
2{
3
4    std::srand(1);
5    const unsigned int N = 10000;;
6    std::vector<unsigned long> v1(N), v2(N);
7    std::vector<int> c1(N), c2(N);
8
9    for (int i = 0; i < N; ++i) 
10    {
11        v1[i] = rand();
12        v2[i] = rand();
13        c1[i] = rand() & 0x1;
14        c2[i] = !c1[i];
15    }
16
17    unsigned long* p1 = v1.data();
18    unsigned long* p2 = v2.data();
19    int* b1 = c1.data();
20    int* b2 = c2.data();
21
22    for (auto _ : state)
23    {
24        unsigned long a1 = 0, a2 = 0;
25        for (size_t i = 0; i < N; ++i) 
26        {
27            if (b1[i] || b2[i])  // Only difference
28            {
29                a1 += p1[i];
30            }
31            else 
32            {
33                a2 *= p2[i];
34            }
35        }
36        benchmark::DoNotOptimize(a1);
37        benchmark::DoNotOptimize(a2);
38        benchmark::ClobberMemory();
39
40    }
41    state.SetItemsProcessed(state.iterations());
42}
43
44void BM_predict(benchmark::State& state)
45{
46
47    std::srand(1);
48    const unsigned int N = 10000;;
49    std::vector<unsigned long> v1(N), v2(N);
50    std::vector<int> c1(N), c2(N);
51
52    for (int i = 0; i < N; ++i)
53    {
54        v1[i] = rand();
55        v2[i] = rand();
56        c1[i] = rand() & 0x1;
57        c2[i] = !c1[i];
58    }
59
60    unsigned long* p1 = v1.data();
61    unsigned long* p2 = v2.data();
62    int* b1 = c1.data();
63    int* b2 = c2.data();
64
65    for (auto _ : state)
66    {
67        unsigned long a1 = 0, a2 = 0;
68        for (size_t i = 0; i < N; ++i)
69        {
70            if (b1[i] | b2[i]) // Only difference
71            {
72                a1 += p1[i];
73            }
74            else
75            {
76                a2 *= p2[i];
77            }
78        }
79        benchmark::DoNotOptimize(a1);
80        benchmark::DoNotOptimize(a2);
81        benchmark::ClobberMemory();
82
83    }
84    state.SetItemsProcessed(state.iterations());
85}
86

I will not go in all the details explained in the book why the latter is faster, but the idea is that hardware branch predictor is given 2 chances to misspredict in slower version and in the | (bitwise or) version. See the benchmark results below.

enter image description here

So the question is why don't we always use | instead of || in branches?

ANSWER

Answered 2022-Feb-08 at 19:57

Code readability, short-circuiting and it is not guaranteed that Ord will always outperform a || operand. Computer systems are more complicated than expected, even though they are man-made.

There was a case where a for loop with a much more complicated condition ran faster on an IBM. The CPU didn't cool and thus instructions were executed faster, that was a possible reason. What I am trying to say, focus on other areas to improve code than fighting small-cases which will differ depending on the CPU and the boolean evaluation (compiler optimizations).

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

QUESTION

Android emulator on apple silicon (arm64) could be run only using sudo mode

Asked 2022-Feb-03 at 21:53

I'm trying to start android emulator on apple silicon mac and I'm always getting the same results:

  1. Running emulator directly through Android Studio (the latest stable version, Arctic Fox 2020.3.1 Patch 4) causes a problem, when the process qemu-system-arch64 stucks and uses 99% CPU (there is no emulator's screen or something like than). Such behavior produces some logs:

internal-error-msg.txt says:

1emuglConfig_init: blacklisted=0 has_guest_renderer=0, mode: auto, option: (null)
2
3emuglConfig_init: auto-selected swiftshader_indirect based on conditions and UI preference 3
4
5emuglConfig_init: GPU emulation enabled using 'swiftshader_indirect' mode
6
7Deciding if GLDirectMem/Vulkan should be enabled. Selected renderer: 8 API level: 32 host GPU blacklisted? 0
8
9Swiftshader selected, enabling Vulkan.
10
11Enabling GLDirectMem
12Enabling Vulkan
13Adding to the library search path: /Users/xset/Library/Android/sdk/emulator/lib64/gles_swiftshader
14

opengl_log.txt says:

1emuglConfig_init: blacklisted=0 has_guest_renderer=0, mode: auto, option: (null)
2
3emuglConfig_init: auto-selected swiftshader_indirect based on conditions and UI preference 3
4
5emuglConfig_init: GPU emulation enabled using 'swiftshader_indirect' mode
6
7Deciding if GLDirectMem/Vulkan should be enabled. Selected renderer: 8 API level: 32 host GPU blacklisted? 0
8
9Swiftshader selected, enabling Vulkan.
10
11Enabling GLDirectMem
12Enabling Vulkan
13Adding to the library search path: /Users/xset/Library/Android/sdk/emulator/lib64/gles_swiftshader
14Initializing hardware OpenGLES emulation support
15android_startOpenglesRenderer: gpu info
16
17RenderWindow: CMD_INITIALIZE w=1080 h=2280
18FrameBuffer::initialize
19SharedLibrary::open for [/Users/xset/Library/Android/sdk/emulator/qemu/darwin-aarch64/lib64/vulkan/libvulkan.dylib]
20
21SharedLibrary::open for [/Users/xset/Library/Android/sdk/emulator/qemu/darwin-aarch64/lib64/vulkan/libvulkan.dylib]: not found in map, open for the first time
22
23SharedLibrary::open for [/Users/xset/Library/Android/sdk/emulator/qemu/darwin-aarch64/lib64/vulkan/libvulkan.dylib] (posix): begin
24
25SharedLibrary::open for [/Users/xset/Library/Android/sdk/emulator/qemu/darwin-aarch64/lib64/vulkan/libvulkan.dylib] (posix,darwin): call dlopen
26
27SharedLibrary::open for [/Users/xset/Library/Android/sdk/emulator/qemu/darwin-aarch64/lib64/vulkan/libvulkan.dylib] (posix,darwin): failed, try again with [/Users/xset/Library/Android/sdk/emulator/qemu/darwin-aarch64/lib64/vulkan/libvulkan.dylib]
28
29SharedLibrary::open for [/Users/xset/Library/Android/sdk/emulator/qemu/darwin-aarch64/lib64/vulkan/libvulkan.dylib] failed (posix). dlerror: []
30
31SharedLibrary::open for [/Users/xset/Library/Android/sdk/emulator/lib64/vulkan/libvulkan.dylib]
32
33SharedLibrary::open for [/Users/xset/Library/Android/sdk/emulator/lib64/vulkan/libvulkan.dylib]: not found in map, open for the first time
34
35SharedLibrary::open for [/Users/xset/Library/Android/sdk/emulator/lib64/vulkan/libvulkan.dylib] (posix): begin
36
37SharedLibrary::open for [/Users/xset/Library/Android/sdk/emulator/lib64/vulkan/libvulkan.dylib] (posix,darwin): call dlopen
38
39SharedLibrary::open for [/Users/xset/Library/Android/sdk/emulator/lib64/vulkan/libvulkan.dylib] (posix,darwin): failed, try again with [/Users/xset/Library/Android/sdk/emulator/lib64/vulkan/libvulkan.dylib]
40
41SharedLibrary::open for [/Users/xset/Library/Android/sdk/emulator/lib64/vulkan/libvulkan.dylib] failed (posix). dlerror: []
42
43SharedLibrary::open for [libGLESv2.dylib]: not found in map, open for the first time
44
45SharedLibrary::open for [libGLESv2.dylib] (posix): begin
46
47SharedLibrary::open for [libGLESv2.dylib] (posix,darwin): call dlopen
48
49SharedLibrary::open for [libGLESv2.dylib] (posix,darwin): failed, try again with [libGLESv2.dylib]
50
51SharedLibrary::open for [libGLESv2.dylib] failed (posix). dlerror: [dlopen(libGLESv2.dylib, 0x0002): tried: '/Users/xset/Library/Android/sdk/emulator/lib64/qt/lib/libGLESv2.dylib' (no such file), '/Users/xset/Library/Android/sdk/emulator/lib64/gles_swiftshader/libGLESv2.dylib' (code signature in <B48F2D27-E9C4-30EF-A948-C]
52
53SharedLibrary::open for [libEGL.dylib]: not found in map, open for the first time
54
55SharedLibrary::open for [libEGL.dylib] (posix): begin
56
57SharedLibrary::open for [libEGL.dylib] (posix,darwin): call dlopen
58
59SharedLibrary::open for [libEGL.dylib] (posix,darwin): failed, try again with [libEGL.dylib]
60
61SharedLibrary::open for [libEGL.dylib] failed (posix). dlerror: [dlopen(libEGL.dylib, 0x0002): tried: '/Users/xset/Library/Android/sdk/emulator/lib64/qt/lib/libEGL.dylib' (no such file), '/Users/xset/Library/Android/sdk/emulator/lib64/gles_swiftshader/libEGL.dylib' (code signature in <5C3ABCC5-722A-3AEA-AF5B-6CEEFF8D10]
62

opengl_cxt_log.txt says nothing

  1. Running emulator through terminal (/Users/xset/Library/Android/sdk/emulator/emulator @Pixel_4_API_32) causes such output:
1emuglConfig_init: blacklisted=0 has_guest_renderer=0, mode: auto, option: (null)
2
3emuglConfig_init: auto-selected swiftshader_indirect based on conditions and UI preference 3
4
5emuglConfig_init: GPU emulation enabled using 'swiftshader_indirect' mode
6
7Deciding if GLDirectMem/Vulkan should be enabled. Selected renderer: 8 API level: 32 host GPU blacklisted? 0
8
9Swiftshader selected, enabling Vulkan.
10
11Enabling GLDirectMem
12Enabling Vulkan
13Adding to the library search path: /Users/xset/Library/Android/sdk/emulator/lib64/gles_swiftshader
14Initializing hardware OpenGLES emulation support
15android_startOpenglesRenderer: gpu info
16
17RenderWindow: CMD_INITIALIZE w=1080 h=2280
18FrameBuffer::initialize
19SharedLibrary::open for [/Users/xset/Library/Android/sdk/emulator/qemu/darwin-aarch64/lib64/vulkan/libvulkan.dylib]
20
21SharedLibrary::open for [/Users/xset/Library/Android/sdk/emulator/qemu/darwin-aarch64/lib64/vulkan/libvulkan.dylib]: not found in map, open for the first time
22
23SharedLibrary::open for [/Users/xset/Library/Android/sdk/emulator/qemu/darwin-aarch64/lib64/vulkan/libvulkan.dylib] (posix): begin
24
25SharedLibrary::open for [/Users/xset/Library/Android/sdk/emulator/qemu/darwin-aarch64/lib64/vulkan/libvulkan.dylib] (posix,darwin): call dlopen
26
27SharedLibrary::open for [/Users/xset/Library/Android/sdk/emulator/qemu/darwin-aarch64/lib64/vulkan/libvulkan.dylib] (posix,darwin): failed, try again with [/Users/xset/Library/Android/sdk/emulator/qemu/darwin-aarch64/lib64/vulkan/libvulkan.dylib]
28
29SharedLibrary::open for [/Users/xset/Library/Android/sdk/emulator/qemu/darwin-aarch64/lib64/vulkan/libvulkan.dylib] failed (posix). dlerror: []
30
31SharedLibrary::open for [/Users/xset/Library/Android/sdk/emulator/lib64/vulkan/libvulkan.dylib]
32
33SharedLibrary::open for [/Users/xset/Library/Android/sdk/emulator/lib64/vulkan/libvulkan.dylib]: not found in map, open for the first time
34
35SharedLibrary::open for [/Users/xset/Library/Android/sdk/emulator/lib64/vulkan/libvulkan.dylib] (posix): begin
36
37SharedLibrary::open for [/Users/xset/Library/Android/sdk/emulator/lib64/vulkan/libvulkan.dylib] (posix,darwin): call dlopen
38
39SharedLibrary::open for [/Users/xset/Library/Android/sdk/emulator/lib64/vulkan/libvulkan.dylib] (posix,darwin): failed, try again with [/Users/xset/Library/Android/sdk/emulator/lib64/vulkan/libvulkan.dylib]
40
41SharedLibrary::open for [/Users/xset/Library/Android/sdk/emulator/lib64/vulkan/libvulkan.dylib] failed (posix). dlerror: []
42
43SharedLibrary::open for [libGLESv2.dylib]: not found in map, open for the first time
44
45SharedLibrary::open for [libGLESv2.dylib] (posix): begin
46
47SharedLibrary::open for [libGLESv2.dylib] (posix,darwin): call dlopen
48
49SharedLibrary::open for [libGLESv2.dylib] (posix,darwin): failed, try again with [libGLESv2.dylib]
50
51SharedLibrary::open for [libGLESv2.dylib] failed (posix). dlerror: [dlopen(libGLESv2.dylib, 0x0002): tried: '/Users/xset/Library/Android/sdk/emulator/lib64/qt/lib/libGLESv2.dylib' (no such file), '/Users/xset/Library/Android/sdk/emulator/lib64/gles_swiftshader/libGLESv2.dylib' (code signature in <B48F2D27-E9C4-30EF-A948-C]
52
53SharedLibrary::open for [libEGL.dylib]: not found in map, open for the first time
54
55SharedLibrary::open for [libEGL.dylib] (posix): begin
56
57SharedLibrary::open for [libEGL.dylib] (posix,darwin): call dlopen
58
59SharedLibrary::open for [libEGL.dylib] (posix,darwin): failed, try again with [libEGL.dylib]
60
61SharedLibrary::open for [libEGL.dylib] failed (posix). dlerror: [dlopen(libEGL.dylib, 0x0002): tried: '/Users/xset/Library/Android/sdk/emulator/lib64/qt/lib/libEGL.dylib' (no such file), '/Users/xset/Library/Android/sdk/emulator/lib64/gles_swiftshader/libEGL.dylib' (code signature in <5C3ABCC5-722A-3AEA-AF5B-6CEEFF8D10]
62INFO    | Android emulator version 30.9.4.0 (build_id 7759208) (CL:N/A)
63WARNING | unexpected system image feature string, emulator might not function correctly, please try updating the emulator.
64WARNING | cannot add library /Users/xset/Library/Android/sdk/emulator/qemu/darwin-aarch64/lib64/vulkan/libvulkan.dylib: failed
65WARNING | cannot add library /Users/xset/Library/Android/sdk/emulator/lib64/vulkan/libvulkan.dylib: failed
66ERROR   | EglOsGlLibrary: Could not open GL library libGLESv2.dylib [dlopen(libGLESv2.dylib, 0x0002): tried: '/Users/xset/Library/Android/sdk/emulator/lib64/qt/lib/libGLESv2.dylib' (no such file), '/Users/xset/Library/Android/sdk/emulator/lib64/gles_swiftshader/libGLESv2.dylib' (code signature in <B48F2D27-E9C4-30EF-A948-C]
67
68ERROR   | EglOsEglDispatcher: Could not open EGL library libEGL.dylib [dlopen(libEGL.dylib, 0x0002): tried: '/Users/xset/Library/Android/sdk/emulator/lib64/qt/lib/libEGL.dylib' (no such file), '/Users/xset/Library/Android/sdk/emulator/lib64/gles_swiftshader/libEGL.dylib' (code signature in <5C3ABCC5-722A-3AEA-AF5B-6CEEFF8D10]
69
  1. Running the same command in terminal, but with SUDO works well sudo /Users/xset/Library/Android/sdk/emulator/emulator @Pixel_4_API_32. It runs emulator in "apple-native" mode and everything works fine. It also produces some INFO logs:
1emuglConfig_init: blacklisted=0 has_guest_renderer=0, mode: auto, option: (null)
2
3emuglConfig_init: auto-selected swiftshader_indirect based on conditions and UI preference 3
4
5emuglConfig_init: GPU emulation enabled using 'swiftshader_indirect' mode
6
7Deciding if GLDirectMem/Vulkan should be enabled. Selected renderer: 8 API level: 32 host GPU blacklisted? 0
8
9Swiftshader selected, enabling Vulkan.
10
11Enabling GLDirectMem
12Enabling Vulkan
13Adding to the library search path: /Users/xset/Library/Android/sdk/emulator/lib64/gles_swiftshader
14Initializing hardware OpenGLES emulation support
15android_startOpenglesRenderer: gpu info
16
17RenderWindow: CMD_INITIALIZE w=1080 h=2280
18FrameBuffer::initialize
19SharedLibrary::open for [/Users/xset/Library/Android/sdk/emulator/qemu/darwin-aarch64/lib64/vulkan/libvulkan.dylib]
20
21SharedLibrary::open for [/Users/xset/Library/Android/sdk/emulator/qemu/darwin-aarch64/lib64/vulkan/libvulkan.dylib]: not found in map, open for the first time
22
23SharedLibrary::open for [/Users/xset/Library/Android/sdk/emulator/qemu/darwin-aarch64/lib64/vulkan/libvulkan.dylib] (posix): begin
24
25SharedLibrary::open for [/Users/xset/Library/Android/sdk/emulator/qemu/darwin-aarch64/lib64/vulkan/libvulkan.dylib] (posix,darwin): call dlopen
26
27SharedLibrary::open for [/Users/xset/Library/Android/sdk/emulator/qemu/darwin-aarch64/lib64/vulkan/libvulkan.dylib] (posix,darwin): failed, try again with [/Users/xset/Library/Android/sdk/emulator/qemu/darwin-aarch64/lib64/vulkan/libvulkan.dylib]
28
29SharedLibrary::open for [/Users/xset/Library/Android/sdk/emulator/qemu/darwin-aarch64/lib64/vulkan/libvulkan.dylib] failed (posix). dlerror: []
30
31SharedLibrary::open for [/Users/xset/Library/Android/sdk/emulator/lib64/vulkan/libvulkan.dylib]
32
33SharedLibrary::open for [/Users/xset/Library/Android/sdk/emulator/lib64/vulkan/libvulkan.dylib]: not found in map, open for the first time
34
35SharedLibrary::open for [/Users/xset/Library/Android/sdk/emulator/lib64/vulkan/libvulkan.dylib] (posix): begin
36
37SharedLibrary::open for [/Users/xset/Library/Android/sdk/emulator/lib64/vulkan/libvulkan.dylib] (posix,darwin): call dlopen
38
39SharedLibrary::open for [/Users/xset/Library/Android/sdk/emulator/lib64/vulkan/libvulkan.dylib] (posix,darwin): failed, try again with [/Users/xset/Library/Android/sdk/emulator/lib64/vulkan/libvulkan.dylib]
40
41SharedLibrary::open for [/Users/xset/Library/Android/sdk/emulator/lib64/vulkan/libvulkan.dylib] failed (posix). dlerror: []
42
43SharedLibrary::open for [libGLESv2.dylib]: not found in map, open for the first time
44
45SharedLibrary::open for [libGLESv2.dylib] (posix): begin
46
47SharedLibrary::open for [libGLESv2.dylib] (posix,darwin): call dlopen
48
49SharedLibrary::open for [libGLESv2.dylib] (posix,darwin): failed, try again with [libGLESv2.dylib]
50
51SharedLibrary::open for [libGLESv2.dylib] failed (posix). dlerror: [dlopen(libGLESv2.dylib, 0x0002): tried: '/Users/xset/Library/Android/sdk/emulator/lib64/qt/lib/libGLESv2.dylib' (no such file), '/Users/xset/Library/Android/sdk/emulator/lib64/gles_swiftshader/libGLESv2.dylib' (code signature in <B48F2D27-E9C4-30EF-A948-C]
52
53SharedLibrary::open for [libEGL.dylib]: not found in map, open for the first time
54
55SharedLibrary::open for [libEGL.dylib] (posix): begin
56
57SharedLibrary::open for [libEGL.dylib] (posix,darwin): call dlopen
58
59SharedLibrary::open for [libEGL.dylib] (posix,darwin): failed, try again with [libEGL.dylib]
60
61SharedLibrary::open for [libEGL.dylib] failed (posix). dlerror: [dlopen(libEGL.dylib, 0x0002): tried: '/Users/xset/Library/Android/sdk/emulator/lib64/qt/lib/libEGL.dylib' (no such file), '/Users/xset/Library/Android/sdk/emulator/lib64/gles_swiftshader/libEGL.dylib' (code signature in <5C3ABCC5-722A-3AEA-AF5B-6CEEFF8D10]
62INFO    | Android emulator version 30.9.4.0 (build_id 7759208) (CL:N/A)
63WARNING | unexpected system image feature string, emulator might not function correctly, please try updating the emulator.
64WARNING | cannot add library /Users/xset/Library/Android/sdk/emulator/qemu/darwin-aarch64/lib64/vulkan/libvulkan.dylib: failed
65WARNING | cannot add library /Users/xset/Library/Android/sdk/emulator/lib64/vulkan/libvulkan.dylib: failed
66ERROR   | EglOsGlLibrary: Could not open GL library libGLESv2.dylib [dlopen(libGLESv2.dylib, 0x0002): tried: '/Users/xset/Library/Android/sdk/emulator/lib64/qt/lib/libGLESv2.dylib' (no such file), '/Users/xset/Library/Android/sdk/emulator/lib64/gles_swiftshader/libGLESv2.dylib' (code signature in <B48F2D27-E9C4-30EF-A948-C]
67
68ERROR   | EglOsEglDispatcher: Could not open EGL library libEGL.dylib [dlopen(libEGL.dylib, 0x0002): tried: '/Users/xset/Library/Android/sdk/emulator/lib64/qt/lib/libEGL.dylib' (no such file), '/Users/xset/Library/Android/sdk/emulator/lib64/gles_swiftshader/libEGL.dylib' (code signature in <5C3ABCC5-722A-3AEA-AF5B-6CEEFF8D10]
69INFO    | Android emulator version 30.9.4.0 (build_id 7759208) (CL:N/A)
70WARNING | unexpected system image feature string, emulator might not function correctly, please try updating the emulator.
71WARNING | cannot add library /Users/xset/Library/Android/sdk/emulator/qemu/darwin-aarch64/lib64/vulkan/libvulkan.dylib: failed
72WARNING | cannot add library /Users/xset/Library/Android/sdk/emulator/lib64/vulkan/libvulkan.dylib: failed
73WARNING | cannot add library /Users/xset/Library/Android/sdk/emulator/qemu/darwin-aarch64/lib64/vulkan/libMoltenVK.dylib: failed
74INFO    | added library /Users/xset/Library/Android/sdk/emulator/lib64/vulkan/libMoltenVK.dylib
75createOrGetGlobalVkEmulation: warning: instance doesn't support external memory capabilities, picking first physical device
76INFO    | configAndStartRenderer: setting vsync to 60 hz
77INFO    | Sending adb public key [QAAAAIcNyIfJ1ydnXV4qz3eCWfMwRr0FlqitJHt/0ZHGRTLW4zOVPWMsHNRgO7u0DwRAyNnNa0iQI1Dptp6FvE1PLAr6/eAmYBPwM3/ZqDQKjuglikfnLLugTDa3K8CjUwBe4OkprODSUqv5dcdgPBgpG0vqFJnRQSWA2I/n5dh6QEbsJE8oDOz0ol/PMs9X3j9J1bl6wEhB0pClsH19byXNG4mB9peZ+MoygLE6WeFH1KXN1tQSPUIGd7ePnhtBU5JI86QudZ2SDvd354LM3VGsqfzOGf0SmzPZUOm1T5vBcijtBAm0f+s85K3j5LoQoZu+xgGGDPNTuN+21bQ8NMEC7+z1lqCWhgD8IPbtqypivOFHGbp2CFTjCeH5il84ATs0+O3ejwU4foc7GCWpw71WbqD09+++LIdJvCB7O+GkNebgaJvGjaHqQ7eaj0q3Lf6u6wf/3kSH8fi3QFEyzO0GsAZxAK5J5F7xeXKDznWSgS6fTwDsroU26tcT8B/WHWh7qcNhZeNJziLCyHh8dRbsn1MXUKqleJJwvpGrewUQhmfk1Kb/QlVEBjn1RODon1aWsLZ7ta8vSr2EVk4K4mj4hsXaV5XT3nEP1/ur3kZgydoantUohAuqPlQyoDeBjviGVxg9Guk2p4FZqzuuOVtgV+JZs2PWEt7NdF//mgsSmP/fl6CtawEAAQA= root@unknown]
78INFO    | Rootcanal has **NOT** been activated.
79INFO    | Started GRPC server at 127.0.0.1:8554, security: Local
80INFO    | Advertising in: /Users/xset/Library/Caches/TemporaryItems/avd/running/pid_12298.ini
81

So what should I do to made it run natively through Android Studio without sudo-mode?

ANSWER

Answered 2022-Feb-03 at 21:53

Issue was successfully fixed in Android Emulator revision 31.2.7. Just go to Android SDK Manager and update it!

According to android emulator release notes:

1emuglConfig_init: blacklisted=0 has_guest_renderer=0, mode: auto, option: (null)
2
3emuglConfig_init: auto-selected swiftshader_indirect based on conditions and UI preference 3
4
5emuglConfig_init: GPU emulation enabled using 'swiftshader_indirect' mode
6
7Deciding if GLDirectMem/Vulkan should be enabled. Selected renderer: 8 API level: 32 host GPU blacklisted? 0
8
9Swiftshader selected, enabling Vulkan.
10
11Enabling GLDirectMem
12Enabling Vulkan
13Adding to the library search path: /Users/xset/Library/Android/sdk/emulator/lib64/gles_swiftshader
14Initializing hardware OpenGLES emulation support
15android_startOpenglesRenderer: gpu info
16
17RenderWindow: CMD_INITIALIZE w=1080 h=2280
18FrameBuffer::initialize
19SharedLibrary::open for [/Users/xset/Library/Android/sdk/emulator/qemu/darwin-aarch64/lib64/vulkan/libvulkan.dylib]
20
21SharedLibrary::open for [/Users/xset/Library/Android/sdk/emulator/qemu/darwin-aarch64/lib64/vulkan/libvulkan.dylib]: not found in map, open for the first time
22
23SharedLibrary::open for [/Users/xset/Library/Android/sdk/emulator/qemu/darwin-aarch64/lib64/vulkan/libvulkan.dylib] (posix): begin
24
25SharedLibrary::open for [/Users/xset/Library/Android/sdk/emulator/qemu/darwin-aarch64/lib64/vulkan/libvulkan.dylib] (posix,darwin): call dlopen
26
27SharedLibrary::open for [/Users/xset/Library/Android/sdk/emulator/qemu/darwin-aarch64/lib64/vulkan/libvulkan.dylib] (posix,darwin): failed, try again with [/Users/xset/Library/Android/sdk/emulator/qemu/darwin-aarch64/lib64/vulkan/libvulkan.dylib]
28
29SharedLibrary::open for [/Users/xset/Library/Android/sdk/emulator/qemu/darwin-aarch64/lib64/vulkan/libvulkan.dylib] failed (posix). dlerror: []
30
31SharedLibrary::open for [/Users/xset/Library/Android/sdk/emulator/lib64/vulkan/libvulkan.dylib]
32
33SharedLibrary::open for [/Users/xset/Library/Android/sdk/emulator/lib64/vulkan/libvulkan.dylib]: not found in map, open for the first time
34
35SharedLibrary::open for [/Users/xset/Library/Android/sdk/emulator/lib64/vulkan/libvulkan.dylib] (posix): begin
36
37SharedLibrary::open for [/Users/xset/Library/Android/sdk/emulator/lib64/vulkan/libvulkan.dylib] (posix,darwin): call dlopen
38
39SharedLibrary::open for [/Users/xset/Library/Android/sdk/emulator/lib64/vulkan/libvulkan.dylib] (posix,darwin): failed, try again with [/Users/xset/Library/Android/sdk/emulator/lib64/vulkan/libvulkan.dylib]
40
41SharedLibrary::open for [/Users/xset/Library/Android/sdk/emulator/lib64/vulkan/libvulkan.dylib] failed (posix). dlerror: []
42
43SharedLibrary::open for [libGLESv2.dylib]: not found in map, open for the first time
44
45SharedLibrary::open for [libGLESv2.dylib] (posix): begin
46
47SharedLibrary::open for [libGLESv2.dylib] (posix,darwin): call dlopen
48
49SharedLibrary::open for [libGLESv2.dylib] (posix,darwin): failed, try again with [libGLESv2.dylib]
50
51SharedLibrary::open for [libGLESv2.dylib] failed (posix). dlerror: [dlopen(libGLESv2.dylib, 0x0002): tried: '/Users/xset/Library/Android/sdk/emulator/lib64/qt/lib/libGLESv2.dylib' (no such file), '/Users/xset/Library/Android/sdk/emulator/lib64/gles_swiftshader/libGLESv2.dylib' (code signature in <B48F2D27-E9C4-30EF-A948-C]
52
53SharedLibrary::open for [libEGL.dylib]: not found in map, open for the first time
54
55SharedLibrary::open for [libEGL.dylib] (posix): begin
56
57SharedLibrary::open for [libEGL.dylib] (posix,darwin): call dlopen
58
59SharedLibrary::open for [libEGL.dylib] (posix,darwin): failed, try again with [libEGL.dylib]
60
61SharedLibrary::open for [libEGL.dylib] failed (posix). dlerror: [dlopen(libEGL.dylib, 0x0002): tried: '/Users/xset/Library/Android/sdk/emulator/lib64/qt/lib/libEGL.dylib' (no such file), '/Users/xset/Library/Android/sdk/emulator/lib64/gles_swiftshader/libEGL.dylib' (code signature in <5C3ABCC5-722A-3AEA-AF5B-6CEEFF8D10]
62INFO    | Android emulator version 30.9.4.0 (build_id 7759208) (CL:N/A)
63WARNING | unexpected system image feature string, emulator might not function correctly, please try updating the emulator.
64WARNING | cannot add library /Users/xset/Library/Android/sdk/emulator/qemu/darwin-aarch64/lib64/vulkan/libvulkan.dylib: failed
65WARNING | cannot add library /Users/xset/Library/Android/sdk/emulator/lib64/vulkan/libvulkan.dylib: failed
66ERROR   | EglOsGlLibrary: Could not open GL library libGLESv2.dylib [dlopen(libGLESv2.dylib, 0x0002): tried: '/Users/xset/Library/Android/sdk/emulator/lib64/qt/lib/libGLESv2.dylib' (no such file), '/Users/xset/Library/Android/sdk/emulator/lib64/gles_swiftshader/libGLESv2.dylib' (code signature in <B48F2D27-E9C4-30EF-A948-C]
67
68ERROR   | EglOsEglDispatcher: Could not open EGL library libEGL.dylib [dlopen(libEGL.dylib, 0x0002): tried: '/Users/xset/Library/Android/sdk/emulator/lib64/qt/lib/libEGL.dylib' (no such file), '/Users/xset/Library/Android/sdk/emulator/lib64/gles_swiftshader/libEGL.dylib' (code signature in <5C3ABCC5-722A-3AEA-AF5B-6CEEFF8D10]
69INFO    | Android emulator version 30.9.4.0 (build_id 7759208) (CL:N/A)
70WARNING | unexpected system image feature string, emulator might not function correctly, please try updating the emulator.
71WARNING | cannot add library /Users/xset/Library/Android/sdk/emulator/qemu/darwin-aarch64/lib64/vulkan/libvulkan.dylib: failed
72WARNING | cannot add library /Users/xset/Library/Android/sdk/emulator/lib64/vulkan/libvulkan.dylib: failed
73WARNING | cannot add library /Users/xset/Library/Android/sdk/emulator/qemu/darwin-aarch64/lib64/vulkan/libMoltenVK.dylib: failed
74INFO    | added library /Users/xset/Library/Android/sdk/emulator/lib64/vulkan/libMoltenVK.dylib
75createOrGetGlobalVkEmulation: warning: instance doesn't support external memory capabilities, picking first physical device
76INFO    | configAndStartRenderer: setting vsync to 60 hz
77INFO    | Sending adb public key [QAAAAIcNyIfJ1ydnXV4qz3eCWfMwRr0FlqitJHt/0ZHGRTLW4zOVPWMsHNRgO7u0DwRAyNnNa0iQI1Dptp6FvE1PLAr6/eAmYBPwM3/ZqDQKjuglikfnLLugTDa3K8CjUwBe4OkprODSUqv5dcdgPBgpG0vqFJnRQSWA2I/n5dh6QEbsJE8oDOz0ol/PMs9X3j9J1bl6wEhB0pClsH19byXNG4mB9peZ+MoygLE6WeFH1KXN1tQSPUIGd7ePnhtBU5JI86QudZ2SDvd354LM3VGsqfzOGf0SmzPZUOm1T5vBcijtBAm0f+s85K3j5LoQoZu+xgGGDPNTuN+21bQ8NMEC7+z1lqCWhgD8IPbtqypivOFHGbp2CFTjCeH5il84ATs0+O3ejwU4foc7GCWpw71WbqD09+++LIdJvCB7O+GkNebgaJvGjaHqQ7eaj0q3Lf6u6wf/3kSH8fi3QFEyzO0GsAZxAK5J5F7xeXKDznWSgS6fTwDsroU26tcT8B/WHWh7qcNhZeNJziLCyHh8dRbsn1MXUKqleJJwvpGrewUQhmfk1Kb/QlVEBjn1RODon1aWsLZ7ta8vSr2EVk4K4mj4hsXaV5XT3nEP1/ur3kZgydoantUohAuqPlQyoDeBjviGVxg9Guk2p4FZqzuuOVtgV+JZs2PWEt7NdF//mgsSmP/fl6CtawEAAQA= root@unknown]
78INFO    | Rootcanal has **NOT** been activated.
79INFO    | Started GRPC server at 127.0.0.1:8554, security: Local
80INFO    | Advertising in: /Users/xset/Library/Caches/TemporaryItems/avd/running/pid_12298.ini
8131.2.7 (February 1, 2022)
82
83[Bug fix] Emulator hanging error on M1 machines.
84

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

QUESTION

uploaded an APK which has an activity,activity alias,service or broadcast receiver with intentfilter, but without 'android : exported' property set

Asked 2022-Feb-03 at 10:56

I'm having an issue when i'm uploading app bundle to the play console that You uploaded an APK or Android App Bundle which has an activity, activity alias, service or broadcast receiver with intent filter, but without 'android:exported' property set. This file can't be installed on Android 12 or higher. but my manifest file includes the property.

Manifest file

1    <?xml version="1.0" encoding="utf-8"?>
2    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
3        package="**********">
4        <!-- io.flutter.app.FlutterApplication is an android.app.Application that
5             calls FlutterMain.startInitialization(this); in its onCreate method.
6             In most cases you can leave this as-is, but you if you want to provide
7             additional functionality it is fine to subclass or reimplement
8             FlutterApplication and put your custom class here. -->
9        <uses-permission android:name="android.permission.INTERNET" />
10        <uses-permission android:name="android.permission.CAMERA" />
11        <uses-feature android:name="android.hardware.camera" />
12        <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
13        <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
14        <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
15        <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
16        <uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
17        <uses-permission android:name="android.permission.WAKE_LOCK"/>
18        <uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
19        <uses-permission android:name="android.permission.VIBRATE" />
20        <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
21        <uses-permission android:name="android.permission.WAKE_LOCK" />
22        <uses-permission android:name="android.permission.ACTIVITY_RECOGNITION" />
23        <uses-permission android:name="com.google.android.gms.permission.ACTIVITY_RECOGNITION" />
24    
25    
26        <application
27            android:name="io.flutter.app.FlutterApplication"
28            android:label="*****"
29            android:requestLegacyExternalStorage="true"
30            android:usesCleartextTraffic="true"
31            android:icon="@mipmap/ic_launcher">
32    
33    
34            <meta-data
35              android:name="com.google.firebase.messaging.default_notification_icon"
36              android:resource="@drawable/ic_stat_artboard_1" />
37    
38            <meta-data android:name="com.google.android.geo.API_KEY"
39                android:value="Z*********"/>
40    
41            <provider
42                android:name="vn.hunghd.flutterdownloader.DownloadedFileProvider"
43                android:authorities="im.mingguang.mingguang_app.flutter_downloader.provider"
44                android:grantUriPermissions="true"
45                android:requestLegacyExternalStorage="true">
46                <meta-data
47                    android:name="android.support.FILE_PROVIDER_PATHS"
48                    android:resource="@xml/provider_paths"/>
49            </provider>
50    
51            <provider
52        android:name="androidx.core.content.FileProvider"
53        android:authorities="${applicationId}.provider"
54        android:grantUriPermissions="true">
55        <meta-data
56            android:name="android.support.FILE_PROVIDER_PATHS"
57            android:resource="@xml/provider_paths"/>
58    </provider>
59            <activity
60                android:name=".MainActivity"
61                android:launchMode="singleTop"
62                android:theme="@style/LaunchTheme"
63                android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
64                android:hardwareAccelerated="true"
65                android:exported="true"
66                android:windowSoftInputMode="adjustResize">
67                <intent-filter>
68                    <action android:name="android.intent.action.MAIN"/>
69                    <category android:name="android.intent.category.DEFAULT"/>
70                    <category android:name="android.intent.category.LAUNCHER"/>
71                </intent-filter>
72                <intent-filter>
73                    <action android:name="FLUTTER_NOTIFICATION_CLICK" />
74                    <category android:name="android.intent.category.DEFAULT"/>
75                </intent-filter>
76            </activity>
77            <!-- Don't delete the meta-data below.
78                 This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
79            <meta-data
80                android:name="flutterEmbedding"
81                android:value="2" />
82        </application>
83    </manifest>
84

Play Console Error

enter image description here

ANSWER

Answered 2022-Jan-12 at 23:56

I face the same Issue but i solved by writing android:exported="true" in activity bellow the android:name=".MainActivity" image shown

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

QUESTION

How to handle different implementations in SysML/UML?

Asked 2022-Jan-26 at 14:08

Imagine that we are building a Library system. Our use cases might be

  • Borrow book
  • Look up book
  • Manage membership

Imagine that we can fulfill these use cases by a librarian person or a machine. We need to realize these use cases.

  1. Should we draw different use case realizations for different flows? If not, it is very different to borrow a book from a machine and a person. How can we handle it?
  2. Moreover, what if we have updated version of library machines some day? (e.g. one with keyboard and the other is with touch screen) What should we do then? The flow stays the same, however the hardware and the software eventually be different.
  3. What would you use to realize use cases and why?

It might be a basic question, but I failed to find concrete examples on the subject to understand what is right. Thank you all in advance.

ANSWER

Answered 2022-Jan-25 at 17:35

UML is method-agnostic. Even when there are no choices to make, there are different approaches to modeling, fo example:

  • Have one model and refine it succesfully getting it through the stages requirements, analysis (domain model of the problem), design (abstraction to be implemented), implementation (classes that are really in the code).
  • Have different models for different stage and keep them all up to date
  • Have successive models, without updating the previous stages.
  • keep only a high level design model to get the big picture, but without implementation details that could be found in the code.

Likewise, for your question, you could consider having different alternative models, or one model with different alternatives grouped in different packages (to avoid naming conflicts). Personally, I’d go for the latter, because the different alternatives should NOT be detailed too much. But ultimately, it’s a question of cost and benefits in your context.

By the way, Ivar Jacobson’s book, the Object advantage applies OO modeling techniques to business process design. So UML is perfectly suitable for a human solution. It’s just that the system under consideration is no longer an IT system, but a broader organisational system, in which IT represents some components among others.

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

QUESTION

Criteria for default garbage collector Hotspot JVM 11/17

Asked 2022-Jan-11 at 10:26

I found a source describing that the default gc used changes depending on the available resources. It seems that the jvm uses either g1gc or serial gc dependnig on hardware and os.

The serial collector is selected by default on certain hardware and operating system configurations

Can someone point out a more detailed source on what the specific criteria is and how that would apply in a dockerized/kubernetes enivronment. In other words:

Could setting resource requests of the pod in k8s to eg. 1500 mCpu make the jvm use serial gc and changing to 2 Cpu change the default gc to g1gc? Do the limits on when which gc is used change depending on jvm version (11 vs 17)?

ANSWER

Answered 2022-Jan-11 at 10:24

In JDK 11 and 17 Serial collector is used when there is only one CPU available. Otherwise G1 is selected

If you limit the number of CPUS available to your container, JVM selects Serial instead of the defaultG1

JDK11 1 CPU
1docker run --cpus=1 --rm -it eclipse-temurin:11 java -Xlog:gc* -version
2[0.004s][info][gc] Using **Serial**
3

It uses Serial

More than one CPU
1docker run --cpus=1 --rm -it eclipse-temurin:11 java -Xlog:gc* -version
2[0.004s][info][gc] Using **Serial**
3docker run --cpus=2 --rm -it eclipse-temurin:11 java -Xlog:gc* -version
4[0.008s][info][gc     ] Using G1
5

It uses G1

JDK17 1 CPU
1docker run --cpus=1 --rm -it eclipse-temurin:11 java -Xlog:gc* -version
2[0.004s][info][gc] Using **Serial**
3docker run --cpus=2 --rm -it eclipse-temurin:11 java -Xlog:gc* -version
4[0.008s][info][gc     ] Using G1
5docker run --cpus=1 --rm -it eclipse-temurin:17 java -Xlog:gc* -version
6[0.004s][info][gc] Using Serial
7

It uses Serial

More than one CPU
1docker run --cpus=1 --rm -it eclipse-temurin:11 java -Xlog:gc* -version
2[0.004s][info][gc] Using **Serial**
3docker run --cpus=2 --rm -it eclipse-temurin:11 java -Xlog:gc* -version
4[0.008s][info][gc     ] Using G1
5docker run --cpus=1 --rm -it eclipse-temurin:17 java -Xlog:gc* -version
6[0.004s][info][gc] Using Serial
7docker run --cpus=2 --rm -it eclipse-temurin:17 java -Xlog:gc* -version
8[0.007s][info][gc] Using G1
9

It uses G1

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

QUESTION

Video_player Crashes Android Emulator in Flutter

Asked 2022-Jan-11 at 08:53

I am trying to use the video_player, but I am getting the below error. I have also added an MRE (minimum reproducible example).

I have used an emulated Pixel 4, an emulated Pixel 4 XL, and an emulator Pixel 5 with the Android Studio Beta, but none of them worked.

The below error was when I was using a Pixel 4 XL, but the error was the same with all of them.

Error:

1~\OneDrive\Documents\Coding\Flutter\video_player_not_working> flutter run
2Using hardware rendering with device sdk gphone x86 64 arm64. If you notice graphics artifacts, consider enabling software
3rendering with "--enable-software-rendering".
4Launching lib\main.dart on sdk gphone x86 64 arm64 in debug mode...
5Checking the license for package Android SDK Platform 31 in C:\Users\ketha\AppData\Local\Android\Sdk\licenses
6License for package Android SDK Platform 31 accepted.
7Preparing "Install Android SDK Platform 31 (revision: 1)".
8"Install Android SDK Platform 31 (revision: 1)" ready.
9Installing Android SDK Platform 31 in C:\Users\ketha\AppData\Local\Android\Sdk\platforms\android-31
10"Install Android SDK Platform 31 (revision: 1)" complete.
11"Install Android SDK Platform 31 (revision: 1)" finished.
12Running Gradle task 'assembleDebug'...                            153.4s
13√  Built build\app\outputs\flutter-apk\app-debug.apk.
14Installing build\app\outputs\flutter-apk\app.apk...              2,093ms
15Syncing files to device sdk gphone x86 64 arm64...                 292ms
16
17Flutter run key commands.
18r Hot reload.
19R Hot restart.
20h List all available interactive commands.
21d Detach (terminate "flutter run" but leave application running).
22c Clear the screen
23q Quit (terminate the application on the device).
24
25 Running with sound null safety 
26
27An Observatory debugger and profiler on sdk gphone x86 64 arm64 is available at: http://127.0.0.1:51217/xDqrRJJJEMY=/
28W/yer_not_workin( 5318): Accessing hidden method Landroid/media/AudioTrack;->getLatency()I (greylist, reflection, allowed)
29I/ExoPlayerImpl( 5318): Init d52da73 [ExoPlayerLib/2.14.1] [generic_x86_64_arm64, sdk_gphone_x86_64_arm64, Google, 30]
30I/Choreographer( 5318): Skipped 47 frames!  The application may be doing too much work on its main thread.
31I/TetheringManager( 5318): registerTetheringEventCallback:com.example.video_player_not_working
32I/VideoCapabilities( 5318): Unsupported profile 4 for video/mp4v-es
33I/OMXClient( 5318): IOmx service obtained
34The Flutter DevTools debugger and profiler on sdk gphone x86 64 arm64 is available at:
35http://127.0.0.1:9102?uri=http://127.0.0.1:51217/xDqrRJJJEMY=/
36D/SurfaceUtils( 5318): connecting to surface 0x70fcbf3cba60, reason connectToSurface
37I/MediaCodec( 5318): [OMX.android.goldfish.h264.decoder] setting surface generation to 5445633
38D/SurfaceUtils( 5318): disconnecting from surface 0x70fcbf3cba60, reason connectToSurface(reconnect)
39D/SurfaceUtils( 5318): connecting to surface 0x70fcbf3cba60, reason connectToSurface(reconnect)
40E/ACodec  ( 5318): [OMX.android.goldfish.h264.decoder] setPortMode on output to DynamicANWBuffer failed w/ err -1010
41I/ACodec  ( 5318): codec does not support config priority (err -1010)
42D/SurfaceUtils( 5318): disconnecting from surface 0x70fcbf3cba60, reason setNativeWindowSizeFormatAndUsage
43D/SurfaceUtils( 5318): connecting to surface 0x70fcbf3cba60, reason setNativeWindowSizeFormatAndUsage
44D/SurfaceUtils( 5318): set up nativeWindow 0x70fcbf3cba60 for 1280x720, color 0x13, rotation 0, usage 0x1002900
45W/Gralloc4( 5318): allocator 3.x is not supported
46D/CCodec  ( 5318): allocate(c2.android.aac.decoder)
47Lost connection to device.
48

main.dart:

1~\OneDrive\Documents\Coding\Flutter\video_player_not_working> flutter run
2Using hardware rendering with device sdk gphone x86 64 arm64. If you notice graphics artifacts, consider enabling software
3rendering with "--enable-software-rendering".
4Launching lib\main.dart on sdk gphone x86 64 arm64 in debug mode...
5Checking the license for package Android SDK Platform 31 in C:\Users\ketha\AppData\Local\Android\Sdk\licenses
6License for package Android SDK Platform 31 accepted.
7Preparing "Install Android SDK Platform 31 (revision: 1)".
8"Install Android SDK Platform 31 (revision: 1)" ready.
9Installing Android SDK Platform 31 in C:\Users\ketha\AppData\Local\Android\Sdk\platforms\android-31
10"Install Android SDK Platform 31 (revision: 1)" complete.
11"Install Android SDK Platform 31 (revision: 1)" finished.
12Running Gradle task 'assembleDebug'...                            153.4s
13√  Built build\app\outputs\flutter-apk\app-debug.apk.
14Installing build\app\outputs\flutter-apk\app.apk...              2,093ms
15Syncing files to device sdk gphone x86 64 arm64...                 292ms
16
17Flutter run key commands.
18r Hot reload.
19R Hot restart.
20h List all available interactive commands.
21d Detach (terminate "flutter run" but leave application running).
22c Clear the screen
23q Quit (terminate the application on the device).
24
25 Running with sound null safety 
26
27An Observatory debugger and profiler on sdk gphone x86 64 arm64 is available at: http://127.0.0.1:51217/xDqrRJJJEMY=/
28W/yer_not_workin( 5318): Accessing hidden method Landroid/media/AudioTrack;->getLatency()I (greylist, reflection, allowed)
29I/ExoPlayerImpl( 5318): Init d52da73 [ExoPlayerLib/2.14.1] [generic_x86_64_arm64, sdk_gphone_x86_64_arm64, Google, 30]
30I/Choreographer( 5318): Skipped 47 frames!  The application may be doing too much work on its main thread.
31I/TetheringManager( 5318): registerTetheringEventCallback:com.example.video_player_not_working
32I/VideoCapabilities( 5318): Unsupported profile 4 for video/mp4v-es
33I/OMXClient( 5318): IOmx service obtained
34The Flutter DevTools debugger and profiler on sdk gphone x86 64 arm64 is available at:
35http://127.0.0.1:9102?uri=http://127.0.0.1:51217/xDqrRJJJEMY=/
36D/SurfaceUtils( 5318): connecting to surface 0x70fcbf3cba60, reason connectToSurface
37I/MediaCodec( 5318): [OMX.android.goldfish.h264.decoder] setting surface generation to 5445633
38D/SurfaceUtils( 5318): disconnecting from surface 0x70fcbf3cba60, reason connectToSurface(reconnect)
39D/SurfaceUtils( 5318): connecting to surface 0x70fcbf3cba60, reason connectToSurface(reconnect)
40E/ACodec  ( 5318): [OMX.android.goldfish.h264.decoder] setPortMode on output to DynamicANWBuffer failed w/ err -1010
41I/ACodec  ( 5318): codec does not support config priority (err -1010)
42D/SurfaceUtils( 5318): disconnecting from surface 0x70fcbf3cba60, reason setNativeWindowSizeFormatAndUsage
43D/SurfaceUtils( 5318): connecting to surface 0x70fcbf3cba60, reason setNativeWindowSizeFormatAndUsage
44D/SurfaceUtils( 5318): set up nativeWindow 0x70fcbf3cba60 for 1280x720, color 0x13, rotation 0, usage 0x1002900
45W/Gralloc4( 5318): allocator 3.x is not supported
46D/CCodec  ( 5318): allocate(c2.android.aac.decoder)
47Lost connection to device.
48import 'dart:async';
49
50import 'package:flutter/material.dart';
51import 'package:video_player/video_player.dart';
52
53void main() => runApp(const VideoPlayerApp());
54
55class VideoPlayerApp extends StatelessWidget {
56  const VideoPlayerApp({Key? key}) : super(key: key);
57
58  @override
59  Widget build(BuildContext context) {
60    return const MaterialApp(
61      title: 'Video Player Demo',
62      home: VideoPlayerScreen(),
63    );
64  }
65}
66
67class VideoPlayerScreen extends StatefulWidget {
68  const VideoPlayerScreen({Key? key}) : super(key: key);
69
70  @override
71  _VideoPlayerScreenState createState() => _VideoPlayerScreenState();
72}
73
74class _VideoPlayerScreenState extends State<VideoPlayerScreen> {
75  late VideoPlayerController _controller;
76  late Future<void> _initializeVideoPlayerFuture;
77
78  @override
79  void initState() {
80    // Create and store the VideoPlayerController. The VideoPlayerController
81    // offers several different constructors to play videos from assets, files,
82    // or the internet.
83    _controller = VideoPlayerController.network(
84      'https://flutter.github.io/assets-for-api-docs/assets/videos/butterfly.mp4',
85    );
86
87    // Initialize the controller and store the Future for later use.
88    _initializeVideoPlayerFuture = _controller.initialize();
89
90    // Use the controller to loop the video.
91    _controller.setLooping(true);
92
93    super.initState();
94  }
95
96  @override
97  void dispose() {
98    // Ensure disposing of the VideoPlayerController to free up resources.
99    _controller.dispose();
100
101    super.dispose();
102  }
103
104  @override
105  Widget build(BuildContext context) {
106    return Scaffold(
107      appBar: AppBar(
108        title: const Text('Butterfly Video'),
109      ),
110      // Use a FutureBuilder to display a loading spinner while waiting for the
111      // VideoPlayerController to finish initializing.
112      body: FutureBuilder(
113        future: _initializeVideoPlayerFuture,
114        builder: (context, snapshot) {
115          if (snapshot.connectionState == ConnectionState.done) {
116            // If the VideoPlayerController has finished initialization, use
117            // the data it provides to limit the aspect ratio of the video.
118            return AspectRatio(
119              aspectRatio: _controller.value.aspectRatio,
120              // Use the VideoPlayer widget to display the video.
121              child: VideoPlayer(_controller),
122            );
123          } else {
124            // If the VideoPlayerController is still initializing, show a
125            // loading spinner.
126            return const Center(
127              child: CircularProgressIndicator(),
128            );
129          }
130        },
131      ),
132      floatingActionButton: FloatingActionButton(
133        onPressed: () {
134          // Wrap the play or pause in a call to `setState`. This ensures the
135          // correct icon is shown.
136          setState(() {
137            // If the video is playing, pause it.
138            if (_controller.value.isPlaying) {
139              _controller.pause();
140            } else {
141              // If the video is paused, play it.
142              _controller.play();
143            }
144          });
145        },
146        // Display the correct icon depending on the state of the player.
147        child: Icon(
148          _controller.value.isPlaying ? Icons.pause : Icons.play_arrow,
149        ),
150      ),
151    );
152  }
153}
154

pubspec.yaml

1~\OneDrive\Documents\Coding\Flutter\video_player_not_working> flutter run
2Using hardware rendering with device sdk gphone x86 64 arm64. If you notice graphics artifacts, consider enabling software
3rendering with "--enable-software-rendering".
4Launching lib\main.dart on sdk gphone x86 64 arm64 in debug mode...
5Checking the license for package Android SDK Platform 31 in C:\Users\ketha\AppData\Local\Android\Sdk\licenses
6License for package Android SDK Platform 31 accepted.
7Preparing "Install Android SDK Platform 31 (revision: 1)".
8"Install Android SDK Platform 31 (revision: 1)" ready.
9Installing Android SDK Platform 31 in C:\Users\ketha\AppData\Local\Android\Sdk\platforms\android-31
10"Install Android SDK Platform 31 (revision: 1)" complete.
11"Install Android SDK Platform 31 (revision: 1)" finished.
12Running Gradle task 'assembleDebug'...                            153.4s
13√  Built build\app\outputs\flutter-apk\app-debug.apk.
14Installing build\app\outputs\flutter-apk\app.apk...              2,093ms
15Syncing files to device sdk gphone x86 64 arm64...                 292ms
16
17Flutter run key commands.
18r Hot reload.
19R Hot restart.
20h List all available interactive commands.
21d Detach (terminate "flutter run" but leave application running).
22c Clear the screen
23q Quit (terminate the application on the device).
24
25 Running with sound null safety 
26
27An Observatory debugger and profiler on sdk gphone x86 64 arm64 is available at: http://127.0.0.1:51217/xDqrRJJJEMY=/
28W/yer_not_workin( 5318): Accessing hidden method Landroid/media/AudioTrack;->getLatency()I (greylist, reflection, allowed)
29I/ExoPlayerImpl( 5318): Init d52da73 [ExoPlayerLib/2.14.1] [generic_x86_64_arm64, sdk_gphone_x86_64_arm64, Google, 30]
30I/Choreographer( 5318): Skipped 47 frames!  The application may be doing too much work on its main thread.
31I/TetheringManager( 5318): registerTetheringEventCallback:com.example.video_player_not_working
32I/VideoCapabilities( 5318): Unsupported profile 4 for video/mp4v-es
33I/OMXClient( 5318): IOmx service obtained
34The Flutter DevTools debugger and profiler on sdk gphone x86 64 arm64 is available at:
35http://127.0.0.1:9102?uri=http://127.0.0.1:51217/xDqrRJJJEMY=/
36D/SurfaceUtils( 5318): connecting to surface 0x70fcbf3cba60, reason connectToSurface
37I/MediaCodec( 5318): [OMX.android.goldfish.h264.decoder] setting surface generation to 5445633
38D/SurfaceUtils( 5318): disconnecting from surface 0x70fcbf3cba60, reason connectToSurface(reconnect)
39D/SurfaceUtils( 5318): connecting to surface 0x70fcbf3cba60, reason connectToSurface(reconnect)
40E/ACodec  ( 5318): [OMX.android.goldfish.h264.decoder] setPortMode on output to DynamicANWBuffer failed w/ err -1010
41I/ACodec  ( 5318): codec does not support config priority (err -1010)
42D/SurfaceUtils( 5318): disconnecting from surface 0x70fcbf3cba60, reason setNativeWindowSizeFormatAndUsage
43D/SurfaceUtils( 5318): connecting to surface 0x70fcbf3cba60, reason setNativeWindowSizeFormatAndUsage
44D/SurfaceUtils( 5318): set up nativeWindow 0x70fcbf3cba60 for 1280x720, color 0x13, rotation 0, usage 0x1002900
45W/Gralloc4( 5318): allocator 3.x is not supported
46D/CCodec  ( 5318): allocate(c2.android.aac.decoder)
47Lost connection to device.
48import 'dart:async';
49
50import 'package:flutter/material.dart';
51import 'package:video_player/video_player.dart';
52
53void main() => runApp(const VideoPlayerApp());
54
55class VideoPlayerApp extends StatelessWidget {
56  const VideoPlayerApp({Key? key}) : super(key: key);
57
58  @override
59  Widget build(BuildContext context) {
60    return const MaterialApp(
61      title: 'Video Player Demo',
62      home: VideoPlayerScreen(),
63    );
64  }
65}
66
67class VideoPlayerScreen extends StatefulWidget {
68  const VideoPlayerScreen({Key? key}) : super(key: key);
69
70  @override
71  _VideoPlayerScreenState createState() => _VideoPlayerScreenState();
72}
73
74class _VideoPlayerScreenState extends State<VideoPlayerScreen> {
75  late VideoPlayerController _controller;
76  late Future<void> _initializeVideoPlayerFuture;
77
78  @override
79  void initState() {
80    // Create and store the VideoPlayerController. The VideoPlayerController
81    // offers several different constructors to play videos from assets, files,
82    // or the internet.
83    _controller = VideoPlayerController.network(
84      'https://flutter.github.io/assets-for-api-docs/assets/videos/butterfly.mp4',
85    );
86
87    // Initialize the controller and store the Future for later use.
88    _initializeVideoPlayerFuture = _controller.initialize();
89
90    // Use the controller to loop the video.
91    _controller.setLooping(true);
92
93    super.initState();
94  }
95
96  @override
97  void dispose() {
98    // Ensure disposing of the VideoPlayerController to free up resources.
99    _controller.dispose();
100
101    super.dispose();
102  }
103
104  @override
105  Widget build(BuildContext context) {
106    return Scaffold(
107      appBar: AppBar(
108        title: const Text('Butterfly Video'),
109      ),
110      // Use a FutureBuilder to display a loading spinner while waiting for the
111      // VideoPlayerController to finish initializing.
112      body: FutureBuilder(
113        future: _initializeVideoPlayerFuture,
114        builder: (context, snapshot) {
115          if (snapshot.connectionState == ConnectionState.done) {
116            // If the VideoPlayerController has finished initialization, use
117            // the data it provides to limit the aspect ratio of the video.
118            return AspectRatio(
119              aspectRatio: _controller.value.aspectRatio,
120              // Use the VideoPlayer widget to display the video.
121              child: VideoPlayer(_controller),
122            );
123          } else {
124            // If the VideoPlayerController is still initializing, show a
125            // loading spinner.
126            return const Center(
127              child: CircularProgressIndicator(),
128            );
129          }
130        },
131      ),
132      floatingActionButton: FloatingActionButton(
133        onPressed: () {
134          // Wrap the play or pause in a call to `setState`. This ensures the
135          // correct icon is shown.
136          setState(() {
137            // If the video is playing, pause it.
138            if (_controller.value.isPlaying) {
139              _controller.pause();
140            } else {
141              // If the video is paused, play it.
142              _controller.play();
143            }
144          });
145        },
146        // Display the correct icon depending on the state of the player.
147        child: Icon(
148          _controller.value.isPlaying ? Icons.pause : Icons.play_arrow,
149        ),
150      ),
151    );
152  }
153}
154name: video_player_not_working
155description: A new Flutter project.
156
157# The following line prevents the package from being accidentally published to
158# pub.dev using `flutter pub publish`. This is preferred for private packages.
159publish_to: 'none' # Remove this line if you wish to publish to pub.dev
160
161# The following defines the version and build number for your application.
162# A version number is three numbers separated by dots, like 1.2.43
163# followed by an optional build number separated by a +.
164# Both the version and the builder number may be overridden in flutter
165# build by specifying --build-name and --build-number, respectively.
166# In Android, build-name is used as versionName while build-number used as versionCode.
167# Read more about Android versioning at https://developer.android.com/studio/publish/versioning
168# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
169# Read more about iOS versioning at
170# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
171version: 1.0.0+1
172
173environment:
174  sdk: ">=2.15.1 <3.0.0"
175
176# Dependencies specify other packages that your package needs in order to work.
177# To automatically upgrade your package dependencies to the latest versions
178# consider running `flutter pub upgrade --major-versions`. Alternatively,
179# dependencies can be manually updated by changing the version numbers below to
180# the latest version available on pub.dev. To see which dependencies have newer
181# versions available, run `flutter pub outdated`.
182dependencies:
183  flutter:
184    sdk: flutter
185
186
187  # The following adds the Cupertino Icons font to your application.
188  # Use with the CupertinoIcons class for iOS style icons.
189  cupertino_icons: ^1.0.2
190  video_player: ^2.2.10
191
192dev_dependencies:
193  flutter_test:
194    sdk: flutter
195
196  # The "flutter_lints" package below contains a set of recommended lints to
197  # encourage good coding practices. The lint set provided by the package is
198  # activated in the `analysis_options.yaml` file located at the root of your
199  # package. See that file for information about deactivating specific lint
200  # rules and activating additional ones.
201  flutter_lints: ^1.0.0
202
203# For information on the generic Dart part of this file, see the
204# following page: https://dart.dev/tools/pub/pubspec
205
206# The following section is specific to Flutter.
207flutter:
208
209  # The following line ensures that the Material Icons font is
210  # included with your application, so that you can use the icons in
211  # the material Icons class.
212  uses-material-design: true
213
214  # To add assets to your application, add an assets section, like this:
215  # assets:
216  #   - images/a_dot_burr.jpeg
217  #   - images/a_dot_ham.jpeg
218
219  # An image asset can refer to one or more resolution-specific "variants", see
220  # https://flutter.dev/assets-and-images/#resolution-aware.
221
222  # For details regarding adding assets from package dependencies, see
223  # https://flutter.dev/assets-and-images/#from-packages
224
225  # To add custom fonts to your application, add a fonts section here,
226  # in this "flutter" section. Each entry in this list should have a
227  # "family" key with the font family name, and a "fonts" key with a
228  # list giving the asset and other descriptors for the font. For
229  # example:
230  # fonts:
231  #   - family: Schyler
232  #     fonts:
233  #       - asset: fonts/Schyler-Regular.ttf
234  #       - asset: fonts/Schyler-Italic.ttf
235  #         style: italic
236  #   - family: Trajan Pro
237  #     fonts:
238  #       - asset: fonts/TrajanPro.ttf
239  #       - asset: fonts/TrajanPro_Bold.ttf
240  #         weight: 700
241  #
242  # For details regarding fonts from package dependencies,
243  # see https://flutter.dev/custom-fonts/#from-packages
244

AndroidManifest.xml

1~\OneDrive\Documents\Coding\Flutter\video_player_not_working> flutter run
2Using hardware rendering with device sdk gphone x86 64 arm64. If you notice graphics artifacts, consider enabling software
3rendering with "--enable-software-rendering".
4Launching lib\main.dart on sdk gphone x86 64 arm64 in debug mode...
5Checking the license for package Android SDK Platform 31 in C:\Users\ketha\AppData\Local\Android\Sdk\licenses
6License for package Android SDK Platform 31 accepted.
7Preparing "Install Android SDK Platform 31 (revision: 1)".
8"Install Android SDK Platform 31 (revision: 1)" ready.
9Installing Android SDK Platform 31 in C:\Users\ketha\AppData\Local\Android\Sdk\platforms\android-31
10"Install Android SDK Platform 31 (revision: 1)" complete.
11"Install Android SDK Platform 31 (revision: 1)" finished.
12Running Gradle task 'assembleDebug'...                            153.4s
13√  Built build\app\outputs\flutter-apk\app-debug.apk.
14Installing build\app\outputs\flutter-apk\app.apk...              2,093ms
15Syncing files to device sdk gphone x86 64 arm64...                 292ms
16
17Flutter run key commands.
18r Hot reload.
19R Hot restart.
20h List all available interactive commands.
21d Detach (terminate "flutter run" but leave application running).
22c Clear the screen
23q Quit (terminate the application on the device).
24
25 Running with sound null safety 
26
27An Observatory debugger and profiler on sdk gphone x86 64 arm64 is available at: http://127.0.0.1:51217/xDqrRJJJEMY=/
28W/yer_not_workin( 5318): Accessing hidden method Landroid/media/AudioTrack;->getLatency()I (greylist, reflection, allowed)
29I/ExoPlayerImpl( 5318): Init d52da73 [ExoPlayerLib/2.14.1] [generic_x86_64_arm64, sdk_gphone_x86_64_arm64, Google, 30]
30I/Choreographer( 5318): Skipped 47 frames!  The application may be doing too much work on its main thread.
31I/TetheringManager( 5318): registerTetheringEventCallback:com.example.video_player_not_working
32I/VideoCapabilities( 5318): Unsupported profile 4 for video/mp4v-es
33I/OMXClient( 5318): IOmx service obtained
34The Flutter DevTools debugger and profiler on sdk gphone x86 64 arm64 is available at:
35http://127.0.0.1:9102?uri=http://127.0.0.1:51217/xDqrRJJJEMY=/
36D/SurfaceUtils( 5318): connecting to surface 0x70fcbf3cba60, reason connectToSurface
37I/MediaCodec( 5318): [OMX.android.goldfish.h264.decoder] setting surface generation to 5445633
38D/SurfaceUtils( 5318): disconnecting from surface 0x70fcbf3cba60, reason connectToSurface(reconnect)
39D/SurfaceUtils( 5318): connecting to surface 0x70fcbf3cba60, reason connectToSurface(reconnect)
40E/ACodec  ( 5318): [OMX.android.goldfish.h264.decoder] setPortMode on output to DynamicANWBuffer failed w/ err -1010
41I/ACodec  ( 5318): codec does not support config priority (err -1010)
42D/SurfaceUtils( 5318): disconnecting from surface 0x70fcbf3cba60, reason setNativeWindowSizeFormatAndUsage
43D/SurfaceUtils( 5318): connecting to surface 0x70fcbf3cba60, reason setNativeWindowSizeFormatAndUsage
44D/SurfaceUtils( 5318): set up nativeWindow 0x70fcbf3cba60 for 1280x720, color 0x13, rotation 0, usage 0x1002900
45W/Gralloc4( 5318): allocator 3.x is not supported
46D/CCodec  ( 5318): allocate(c2.android.aac.decoder)
47Lost connection to device.
48import 'dart:async';
49
50import 'package:flutter/material.dart';
51import 'package:video_player/video_player.dart';
52
53void main() => runApp(const VideoPlayerApp());
54
55class VideoPlayerApp extends StatelessWidget {
56  const VideoPlayerApp({Key? key}) : super(key: key);
57
58  @override
59  Widget build(BuildContext context) {
60    return const MaterialApp(
61      title: 'Video Player Demo',
62      home: VideoPlayerScreen(),
63    );
64  }
65}
66
67class VideoPlayerScreen extends StatefulWidget {
68  const VideoPlayerScreen({Key? key}) : super(key: key);
69
70  @override
71  _VideoPlayerScreenState createState() => _VideoPlayerScreenState();
72}
73
74class _VideoPlayerScreenState extends State<VideoPlayerScreen> {
75  late VideoPlayerController _controller;
76  late Future<void> _initializeVideoPlayerFuture;
77
78  @override
79  void initState() {
80    // Create and store the VideoPlayerController. The VideoPlayerController
81    // offers several different constructors to play videos from assets, files,
82    // or the internet.
83    _controller = VideoPlayerController.network(
84      'https://flutter.github.io/assets-for-api-docs/assets/videos/butterfly.mp4',
85    );
86
87    // Initialize the controller and store the Future for later use.
88    _initializeVideoPlayerFuture = _controller.initialize();
89
90    // Use the controller to loop the video.
91    _controller.setLooping(true);
92
93    super.initState();
94  }
95
96  @override
97  void dispose() {
98    // Ensure disposing of the VideoPlayerController to free up resources.
99    _controller.dispose();
100
101    super.dispose();
102  }
103
104  @override
105  Widget build(BuildContext context) {
106    return Scaffold(
107      appBar: AppBar(
108        title: const Text('Butterfly Video'),
109      ),
110      // Use a FutureBuilder to display a loading spinner while waiting for the
111      // VideoPlayerController to finish initializing.
112      body: FutureBuilder(
113        future: _initializeVideoPlayerFuture,
114        builder: (context, snapshot) {
115          if (snapshot.connectionState == ConnectionState.done) {
116            // If the VideoPlayerController has finished initialization, use
117            // the data it provides to limit the aspect ratio of the video.
118            return AspectRatio(
119              aspectRatio: _controller.value.aspectRatio,
120              // Use the VideoPlayer widget to display the video.
121              child: VideoPlayer(_controller),
122            );
123          } else {
124            // If the VideoPlayerController is still initializing, show a
125            // loading spinner.
126            return const Center(
127              child: CircularProgressIndicator(),
128            );
129          }
130        },
131      ),
132      floatingActionButton: FloatingActionButton(
133        onPressed: () {
134          // Wrap the play or pause in a call to `setState`. This ensures the
135          // correct icon is shown.
136          setState(() {
137            // If the video is playing, pause it.
138            if (_controller.value.isPlaying) {
139              _controller.pause();
140            } else {
141              // If the video is paused, play it.
142              _controller.play();
143            }
144          });
145        },
146        // Display the correct icon depending on the state of the player.
147        child: Icon(
148          _controller.value.isPlaying ? Icons.pause : Icons.play_arrow,
149        ),
150      ),
151    );
152  }
153}
154name: video_player_not_working
155description: A new Flutter project.
156
157# The following line prevents the package from being accidentally published to
158# pub.dev using `flutter pub publish`. This is preferred for private packages.
159publish_to: 'none' # Remove this line if you wish to publish to pub.dev
160
161# The following defines the version and build number for your application.
162# A version number is three numbers separated by dots, like 1.2.43
163# followed by an optional build number separated by a +.
164# Both the version and the builder number may be overridden in flutter
165# build by specifying --build-name and --build-number, respectively.
166# In Android, build-name is used as versionName while build-number used as versionCode.
167# Read more about Android versioning at https://developer.android.com/studio/publish/versioning
168# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
169# Read more about iOS versioning at
170# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
171version: 1.0.0+1
172
173environment:
174  sdk: ">=2.15.1 <3.0.0"
175
176# Dependencies specify other packages that your package needs in order to work.
177# To automatically upgrade your package dependencies to the latest versions
178# consider running `flutter pub upgrade --major-versions`. Alternatively,
179# dependencies can be manually updated by changing the version numbers below to
180# the latest version available on pub.dev. To see which dependencies have newer
181# versions available, run `flutter pub outdated`.
182dependencies:
183  flutter:
184    sdk: flutter
185
186
187  # The following adds the Cupertino Icons font to your application.
188  # Use with the CupertinoIcons class for iOS style icons.
189  cupertino_icons: ^1.0.2
190  video_player: ^2.2.10
191
192dev_dependencies:
193  flutter_test:
194    sdk: flutter
195
196  # The "flutter_lints" package below contains a set of recommended lints to
197  # encourage good coding practices. The lint set provided by the package is
198  # activated in the `analysis_options.yaml` file located at the root of your
199  # package. See that file for information about deactivating specific lint
200  # rules and activating additional ones.
201  flutter_lints: ^1.0.0
202
203# For information on the generic Dart part of this file, see the
204# following page: https://dart.dev/tools/pub/pubspec
205
206# The following section is specific to Flutter.
207flutter:
208
209  # The following line ensures that the Material Icons font is
210  # included with your application, so that you can use the icons in
211  # the material Icons class.
212  uses-material-design: true
213
214  # To add assets to your application, add an assets section, like this:
215  # assets:
216  #   - images/a_dot_burr.jpeg
217  #   - images/a_dot_ham.jpeg
218
219  # An image asset can refer to one or more resolution-specific "variants", see
220  # https://flutter.dev/assets-and-images/#resolution-aware.
221
222  # For details regarding adding assets from package dependencies, see
223  # https://flutter.dev/assets-and-images/#from-packages
224
225  # To add custom fonts to your application, add a fonts section here,
226  # in this "flutter" section. Each entry in this list should have a
227  # "family" key with the font family name, and a "fonts" key with a
228  # list giving the asset and other descriptors for the font. For
229  # example:
230  # fonts:
231  #   - family: Schyler
232  #     fonts:
233  #       - asset: fonts/Schyler-Regular.ttf
234  #       - asset: fonts/Schyler-Italic.ttf
235  #         style: italic
236  #   - family: Trajan Pro
237  #     fonts:
238  #       - asset: fonts/TrajanPro.ttf
239  #       - asset: fonts/TrajanPro_Bold.ttf
240  #         weight: 700
241  #
242  # For details regarding fonts from package dependencies,
243  # see https://flutter.dev/custom-fonts/#from-packages
244<manifest xmlns:android="http://schemas.android.com/apk/res/android"
245    package="com.example.video_player_not_working">
246   <application
247        android:label="video_player_not_working"
248        android:name="${applicationName}"
249        android:icon="@mipmap/ic_launcher">
250        <activity
251            android:name=".MainActivity"
252            android:exported="true"
253            android:launchMode="singleTop"
254            android:theme="@style/LaunchTheme"
255            android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
256            android:hardwareAccelerated="true"
257            android:windowSoftInputMode="adjustResize">
258            <!-- Specifies an Android theme to apply to this Activity as soon as
259                 the Android process has started. This theme is visible to the user
260                 while the Flutter UI initializes. After that, this theme continues
261                 to determine the Window background behind the Flutter UI. -->
262            <meta-data
263              android:name="io.flutter.embedding.android.NormalTheme"
264              android:resource="@style/NormalTheme"
265              />
266            <intent-filter>
267                <action android:name="android.intent.action.MAIN"/>
268                <category android:name="android.intent.category.LAUNCHER"/>
269            </intent-filter>
270        </activity>
271        <!-- Don't delete the meta-data below.
272             This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
273        <meta-data
274            android:name="flutterEmbedding"
275            android:value="2" />
276    </application>
277    <uses-permission android:name="android.permission.INTERNET"/>
278</manifest>
279

Output of flutter doctor -v:

1~\OneDrive\Documents\Coding\Flutter\video_player_not_working> flutter run
2Using hardware rendering with device sdk gphone x86 64 arm64. If you notice graphics artifacts, consider enabling software
3rendering with "--enable-software-rendering".
4Launching lib\main.dart on sdk gphone x86 64 arm64 in debug mode...
5Checking the license for package Android SDK Platform 31 in C:\Users\ketha\AppData\Local\Android\Sdk\licenses
6License for package Android SDK Platform 31 accepted.
7Preparing "Install Android SDK Platform 31 (revision: 1)".
8"Install Android SDK Platform 31 (revision: 1)" ready.
9Installing Android SDK Platform 31 in C:\Users\ketha\AppData\Local\Android\Sdk\platforms\android-31
10"Install Android SDK Platform 31 (revision: 1)" complete.
11"Install Android SDK Platform 31 (revision: 1)" finished.
12Running Gradle task 'assembleDebug'...                            153.4s
13√  Built build\app\outputs\flutter-apk\app-debug.apk.
14Installing build\app\outputs\flutter-apk\app.apk...              2,093ms
15Syncing files to device sdk gphone x86 64 arm64...                 292ms
16
17Flutter run key commands.
18r Hot reload.
19R Hot restart.
20h List all available interactive commands.
21d Detach (terminate "flutter run" but leave application running).
22c Clear the screen
23q Quit (terminate the application on the device).
24
25 Running with sound null safety 
26
27An Observatory debugger and profiler on sdk gphone x86 64 arm64 is available at: http://127.0.0.1:51217/xDqrRJJJEMY=/
28W/yer_not_workin( 5318): Accessing hidden method Landroid/media/AudioTrack;->getLatency()I (greylist, reflection, allowed)
29I/ExoPlayerImpl( 5318): Init d52da73 [ExoPlayerLib/2.14.1] [generic_x86_64_arm64, sdk_gphone_x86_64_arm64, Google, 30]
30I/Choreographer( 5318): Skipped 47 frames!  The application may be doing too much work on its main thread.
31I/TetheringManager( 5318): registerTetheringEventCallback:com.example.video_player_not_working
32I/VideoCapabilities( 5318): Unsupported profile 4 for video/mp4v-es
33I/OMXClient( 5318): IOmx service obtained
34The Flutter DevTools debugger and profiler on sdk gphone x86 64 arm64 is available at:
35http://127.0.0.1:9102?uri=http://127.0.0.1:51217/xDqrRJJJEMY=/
36D/SurfaceUtils( 5318): connecting to surface 0x70fcbf3cba60, reason connectToSurface
37I/MediaCodec( 5318): [OMX.android.goldfish.h264.decoder] setting surface generation to 5445633
38D/SurfaceUtils( 5318): disconnecting from surface 0x70fcbf3cba60, reason connectToSurface(reconnect)
39D/SurfaceUtils( 5318): connecting to surface 0x70fcbf3cba60, reason connectToSurface(reconnect)
40E/ACodec  ( 5318): [OMX.android.goldfish.h264.decoder] setPortMode on output to DynamicANWBuffer failed w/ err -1010
41I/ACodec  ( 5318): codec does not support config priority (err -1010)
42D/SurfaceUtils( 5318): disconnecting from surface 0x70fcbf3cba60, reason setNativeWindowSizeFormatAndUsage
43D/SurfaceUtils( 5318): connecting to surface 0x70fcbf3cba60, reason setNativeWindowSizeFormatAndUsage
44D/SurfaceUtils( 5318): set up nativeWindow 0x70fcbf3cba60 for 1280x720, color 0x13, rotation 0, usage 0x1002900
45W/Gralloc4( 5318): allocator 3.x is not supported
46D/CCodec  ( 5318): allocate(c2.android.aac.decoder)
47Lost connection to device.
48import 'dart:async';
49
50import 'package:flutter/material.dart';
51import 'package:video_player/video_player.dart';
52
53void main() => runApp(const VideoPlayerApp());
54
55class VideoPlayerApp extends StatelessWidget {
56  const VideoPlayerApp({Key? key}) : super(key: key);
57
58  @override
59  Widget build(BuildContext context) {
60    return const MaterialApp(
61      title: 'Video Player Demo',
62      home: VideoPlayerScreen(),
63    );
64  }
65}
66
67class VideoPlayerScreen extends StatefulWidget {
68  const VideoPlayerScreen({Key? key}) : super(key: key);
69
70  @override
71  _VideoPlayerScreenState createState() => _VideoPlayerScreenState();
72}
73
74class _VideoPlayerScreenState extends State<VideoPlayerScreen> {
75  late VideoPlayerController _controller;
76  late Future<void> _initializeVideoPlayerFuture;
77
78  @override
79  void initState() {
80    // Create and store the VideoPlayerController. The VideoPlayerController
81    // offers several different constructors to play videos from assets, files,
82    // or the internet.
83    _controller = VideoPlayerController.network(
84      'https://flutter.github.io/assets-for-api-docs/assets/videos/butterfly.mp4',
85    );
86
87    // Initialize the controller and store the Future for later use.
88    _initializeVideoPlayerFuture = _controller.initialize();
89
90    // Use the controller to loop the video.
91    _controller.setLooping(true);
92
93    super.initState();
94  }
95
96  @override
97  void dispose() {
98    // Ensure disposing of the VideoPlayerController to free up resources.
99    _controller.dispose();
100
101    super.dispose();
102  }
103
104  @override
105  Widget build(BuildContext context) {
106    return Scaffold(
107      appBar: AppBar(
108        title: const Text('Butterfly Video'),
109      ),
110      // Use a FutureBuilder to display a loading spinner while waiting for the
111      // VideoPlayerController to finish initializing.
112      body: FutureBuilder(
113        future: _initializeVideoPlayerFuture,
114        builder: (context, snapshot) {
115          if (snapshot.connectionState == ConnectionState.done) {
116            // If the VideoPlayerController has finished initialization, use
117            // the data it provides to limit the aspect ratio of the video.
118            return AspectRatio(
119              aspectRatio: _controller.value.aspectRatio,
120              // Use the VideoPlayer widget to display the video.
121              child: VideoPlayer(_controller),
122            );
123          } else {
124            // If the VideoPlayerController is still initializing, show a
125            // loading spinner.
126            return const Center(
127              child: CircularProgressIndicator(),
128            );
129          }
130        },
131      ),
132      floatingActionButton: FloatingActionButton(
133        onPressed: () {
134          // Wrap the play or pause in a call to `setState`. This ensures the
135          // correct icon is shown.
136          setState(() {
137            // If the video is playing, pause it.
138            if (_controller.value.isPlaying) {
139              _controller.pause();
140            } else {
141              // If the video is paused, play it.
142              _controller.play();
143            }
144          });
145        },
146        // Display the correct icon depending on the state of the player.
147        child: Icon(
148          _controller.value.isPlaying ? Icons.pause : Icons.play_arrow,
149        ),
150      ),
151    );
152  }
153}
154name: video_player_not_working
155description: A new Flutter project.
156
157# The following line prevents the package from being accidentally published to
158# pub.dev using `flutter pub publish`. This is preferred for private packages.
159publish_to: 'none' # Remove this line if you wish to publish to pub.dev
160
161# The following defines the version and build number for your application.
162# A version number is three numbers separated by dots, like 1.2.43
163# followed by an optional build number separated by a +.
164# Both the version and the builder number may be overridden in flutter
165# build by specifying --build-name and --build-number, respectively.
166# In Android, build-name is used as versionName while build-number used as versionCode.
167# Read more about Android versioning at https://developer.android.com/studio/publish/versioning
168# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
169# Read more about iOS versioning at
170# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
171version: 1.0.0+1
172
173environment:
174  sdk: ">=2.15.1 <3.0.0"
175
176# Dependencies specify other packages that your package needs in order to work.
177# To automatically upgrade your package dependencies to the latest versions
178# consider running `flutter pub upgrade --major-versions`. Alternatively,
179# dependencies can be manually updated by changing the version numbers below to
180# the latest version available on pub.dev. To see which dependencies have newer
181# versions available, run `flutter pub outdated`.
182dependencies:
183  flutter:
184    sdk: flutter
185
186
187  # The following adds the Cupertino Icons font to your application.
188  # Use with the CupertinoIcons class for iOS style icons.
189  cupertino_icons: ^1.0.2
190  video_player: ^2.2.10
191
192dev_dependencies:
193  flutter_test:
194    sdk: flutter
195
196  # The "flutter_lints" package below contains a set of recommended lints to
197  # encourage good coding practices. The lint set provided by the package is
198  # activated in the `analysis_options.yaml` file located at the root of your
199  # package. See that file for information about deactivating specific lint
200  # rules and activating additional ones.
201  flutter_lints: ^1.0.0
202
203# For information on the generic Dart part of this file, see the
204# following page: https://dart.dev/tools/pub/pubspec
205
206# The following section is specific to Flutter.
207flutter:
208
209  # The following line ensures that the Material Icons font is
210  # included with your application, so that you can use the icons in
211  # the material Icons class.
212  uses-material-design: true
213
214  # To add assets to your application, add an assets section, like this:
215  # assets:
216  #   - images/a_dot_burr.jpeg
217  #   - images/a_dot_ham.jpeg
218
219  # An image asset can refer to one or more resolution-specific "variants", see
220  # https://flutter.dev/assets-and-images/#resolution-aware.
221
222  # For details regarding adding assets from package dependencies, see
223  # https://flutter.dev/assets-and-images/#from-packages
224
225  # To add custom fonts to your application, add a fonts section here,
226  # in this "flutter" section. Each entry in this list should have a
227  # "family" key with the font family name, and a "fonts" key with a
228  # list giving the asset and other descriptors for the font. For
229  # example:
230  # fonts:
231  #   - family: Schyler
232  #     fonts:
233  #       - asset: fonts/Schyler-Regular.ttf
234  #       - asset: fonts/Schyler-Italic.ttf
235  #         style: italic
236  #   - family: Trajan Pro
237  #     fonts:
238  #       - asset: fonts/TrajanPro.ttf
239  #       - asset: fonts/TrajanPro_Bold.ttf
240  #         weight: 700
241  #
242  # For details regarding fonts from package dependencies,
243  # see https://flutter.dev/custom-fonts/#from-packages
244<manifest xmlns:android="http://schemas.android.com/apk/res/android"
245    package="com.example.video_player_not_working">
246   <application
247        android:label="video_player_not_working"
248        android:name="${applicationName}"
249        android:icon="@mipmap/ic_launcher">
250        <activity
251            android:name=".MainActivity"
252            android:exported="true"
253            android:launchMode="singleTop"
254            android:theme="@style/LaunchTheme"
255            android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
256            android:hardwareAccelerated="true"
257            android:windowSoftInputMode="adjustResize">
258            <!-- Specifies an Android theme to apply to this Activity as soon as
259                 the Android process has started. This theme is visible to the user
260                 while the Flutter UI initializes. After that, this theme continues
261                 to determine the Window background behind the Flutter UI. -->
262            <meta-data
263              android:name="io.flutter.embedding.android.NormalTheme"
264              android:resource="@style/NormalTheme"
265              />
266            <intent-filter>
267                <action android:name="android.intent.action.MAIN"/>
268                <category android:name="android.intent.category.LAUNCHER"/>
269            </intent-filter>
270        </activity>
271        <!-- Don't delete the meta-data below.
272             This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
273        <meta-data
274            android:name="flutterEmbedding"
275            android:value="2" />
276    </application>
277    <uses-permission android:name="android.permission.INTERNET"/>
278</manifest>
279~\OneDrive\Documents\Coding\Flutter\video_player_not_working> flutter doctor -v
280[√] Flutter (Channel stable, 2.8.1, on Microsoft Windows [Version 10.0.22000.376], locale en-US)
281    • Flutter version 2.8.1 at C:\tools\flutter
282    • Upstream repository https://github.com/flutter/flutter.git
283    • Framework revision 77d935af4d (2 weeks ago), 2021-12-16 08:37:33 -0800
284    • Engine revision 890a5fca2e
285    • Dart version 2.15.1
286
287[√] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
288    • Android SDK at C:\Users\ketha\AppData\Local\Android\Sdk
289    • Platform android-31, build-tools 30.0.3
290    • ANDROID_HOME = C:\Users\ketha\AppData\Local\Android\Sdk
291    • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
292    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
293    • All Android licenses accepted.
294
295[√] Chrome - develop for the web
296    • Chrome at C:\Program Files (x86)\Google\Chrome\Application\chrome.exe
297
298[√] Android Studio (version 4.1)
299    • Android Studio at C:\Program Files\Android\Android Studio
300    • Flutter plugin can be installed from:
301       https://plugins.jetbrains.com/plugin/9212-flutter
302    • Dart plugin can be installed from:
303       https://plugins.jetbrains.com/plugin/6351-dart
304    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
305
306[√] VS Code (version 1.63.2)
307    • VS Code at C:\Users\ketha\AppData\Local\Programs\Microsoft VS Code
308    • Flutter extension version 3.29.0
309
310[√] Connected device (3 available)
311    • sdk gphone x86 64 arm64 (mobile) • emulator-5554 • android-x64    • Android 11 (API 30) (emulator)
312    • Chrome (web)                     • chrome        • web-javascript • Google Chrome 96.0.4664.110
313    • Edge (web)                       • edge          • web-javascript • Microsoft Edge 96.0.1054.62
314
315• No issues found!
316

ANSWER

Answered 2022-Jan-11 at 08:53

It can be a bug of that Flutter package, indeed. Have you tried to create an issue in GitHub of that package?

Secondly, during my development, I see several times when emulators just fail and real devices always work. The solution I used is - simply to do not test them on simulators. Real users never use simulators, aren't they?

It can be a bug of the library when running on x86 arch (the arch simulators use). Then, nobody with a real device (arm arch) will ever see the bug.

Thirdly, what about trying to use "cloud real devices" to test whether they work on real Pixel devices that you are worried about. There are many platforms that host some real devices and you can connect to them via a webpage and test your app.

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

QUESTION

Avoid volatile bit-field assignment expression reading or writing memory several times

Asked 2022-Jan-06 at 12:52

I want to use volatile bit-field struct to set hardware register like following code

1union foo {
2    uint32_t value;
3    struct {
4        uint32_t x : 1;
5        uint32_t y : 3;
6        uint32_t z : 28;
7    };
8};
9union foo f = {0};
10int main()
11{
12    volatile union foo *f_ptr = &f;
13    //union foo tmp;
14    *f_ptr =  (union foo) {
15        .x = 1,
16        .y = 7,
17        .z = 10,
18    };
19    //*f_ptr = tmp;
20    return 0;
21}
22

However, the compiler will make it to STR, LDR HW register several times. It is a terrible things that it will trigger hardware to work at once when the register is writed.

1union foo {
2    uint32_t value;
3    struct {
4        uint32_t x : 1;
5        uint32_t y : 3;
6        uint32_t z : 28;
7    };
8};
9union foo f = {0};
10int main()
11{
12    volatile union foo *f_ptr = &f;
13    //union foo tmp;
14    *f_ptr =  (union foo) {
15        .x = 1,
16        .y = 7,
17        .z = 10,
18    };
19    //*f_ptr = tmp;
20    return 0;
21}
22main:
23    @ args = 0, pretend = 0, frame = 0
24    @ frame_needed = 0, uses_anonymous_args = 0
25    @ link register save eliminated.
26    movw    r3, #:lower16:.LANCHOR0
27    movs    r0, #0
28    movt    r3, #:upper16:.LANCHOR0
29    ldr r2, [r3]
30    orr r2, r2, #1
31    str r2, [r3]
32    ldr r2, [r3]
33    orr r2, r2, #14
34    str r2, [r3]
35    ldr r2, [r3]
36    and r2, r2, #15
37    orr r2, r2, #160
38    str r2, [r3]
39    bx  lr
40    .size   main, .-main
41    .global f
42    .bss
43    .align  2
44

My gcc version is : arm-linux-gnueabi-gcc (Linaro GCC 4.9-2017.01) 4.9.4 and build with -O2 optimation


I have tried to use the local variable to resolve this problem

1union foo {
2    uint32_t value;
3    struct {
4        uint32_t x : 1;
5        uint32_t y : 3;
6        uint32_t z : 28;
7    };
8};
9union foo f = {0};
10int main()
11{
12    volatile union foo *f_ptr = &f;
13    //union foo tmp;
14    *f_ptr =  (union foo) {
15        .x = 1,
16        .y = 7,
17        .z = 10,
18    };
19    //*f_ptr = tmp;
20    return 0;
21}
22main:
23    @ args = 0, pretend = 0, frame = 0
24    @ frame_needed = 0, uses_anonymous_args = 0
25    @ link register save eliminated.
26    movw    r3, #:lower16:.LANCHOR0
27    movs    r0, #0
28    movt    r3, #:upper16:.LANCHOR0
29    ldr r2, [r3]
30    orr r2, r2, #1
31    str r2, [r3]
32    ldr r2, [r3]
33    orr r2, r2, #14
34    str r2, [r3]
35    ldr r2, [r3]
36    and r2, r2, #15
37    orr r2, r2, #160
38    str r2, [r3]
39    bx  lr
40    .size   main, .-main
41    .global f
42    .bss
43    .align  2
44union foo {
45    uint32_t value;
46    struct {
47        uint32_t x : 1;
48        uint32_t y : 3;
49        uint32_t z : 28;
50    };
51};
52union foo f = {0};
53int main()
54{
55    volatile union foo *f_ptr = &f;
56    union foo tmp;
57    tmp =  (union foo) {
58        .x = 1,
59        .y = 7,
60        .z = 10,
61    };
62    *f_ptr = tmp;
63    return 0;
64}
65

Well, it will not STR to HW register several times

1union foo {
2    uint32_t value;
3    struct {
4        uint32_t x : 1;
5        uint32_t y : 3;
6        uint32_t z : 28;
7    };
8};
9union foo f = {0};
10int main()
11{
12    volatile union foo *f_ptr = &f;
13    //union foo tmp;
14    *f_ptr =  (union foo) {
15        .x = 1,
16        .y = 7,
17        .z = 10,
18    };
19    //*f_ptr = tmp;
20    return 0;
21}
22main:
23    @ args = 0, pretend = 0, frame = 0
24    @ frame_needed = 0, uses_anonymous_args = 0
25    @ link register save eliminated.
26    movw    r3, #:lower16:.LANCHOR0
27    movs    r0, #0
28    movt    r3, #:upper16:.LANCHOR0
29    ldr r2, [r3]
30    orr r2, r2, #1
31    str r2, [r3]
32    ldr r2, [r3]
33    orr r2, r2, #14
34    str r2, [r3]
35    ldr r2, [r3]
36    and r2, r2, #15
37    orr r2, r2, #160
38    str r2, [r3]
39    bx  lr
40    .size   main, .-main
41    .global f
42    .bss
43    .align  2
44union foo {
45    uint32_t value;
46    struct {
47        uint32_t x : 1;
48        uint32_t y : 3;
49        uint32_t z : 28;
50    };
51};
52union foo f = {0};
53int main()
54{
55    volatile union foo *f_ptr = &f;
56    union foo tmp;
57    tmp =  (union foo) {
58        .x = 1,
59        .y = 7,
60        .z = 10,
61    };
62    *f_ptr = tmp;
63    return 0;
64}
65main:
66    @ args = 0, pretend = 0, frame = 0
67    @ frame_needed = 0, uses_anonymous_args = 0
68    @ link register save eliminated.
69    movs    r1, #10
70    movs    r2, #15
71    movw    r3, #:lower16:.LANCHOR0
72    bfi r2, r1, #4, #28
73    movt    r3, #:upper16:.LANCHOR0
74    movs    r0, #0
75    str r2, [r3]
76    bx  lr
77    .size   main, .-main
78    .global f
79    .bss
80    .align  2
81

I think it is still not a good idea to use local variable, considering the limitation of binary size for embedded system.

Is there any way to handle this problem without using local variable?


ANSWER

Answered 2022-Jan-06 at 11:46

There seems to be no need for bitfields in your program: using uint16_t types should make it simpler and generate better code:

1union foo {
2    uint32_t value;
3    struct {
4        uint32_t x : 1;
5        uint32_t y : 3;
6        uint32_t z : 28;
7    };
8};
9union foo f = {0};
10int main()
11{
12    volatile union foo *f_ptr = &f;
13    //union foo tmp;
14    *f_ptr =  (union foo) {
15        .x = 1,
16        .y = 7,
17        .z = 10,
18    };
19    //*f_ptr = tmp;
20    return 0;
21}
22main:
23    @ args = 0, pretend = 0, frame = 0
24    @ frame_needed = 0, uses_anonymous_args = 0
25    @ link register save eliminated.
26    movw    r3, #:lower16:.LANCHOR0
27    movs    r0, #0
28    movt    r3, #:upper16:.LANCHOR0
29    ldr r2, [r3]
30    orr r2, r2, #1
31    str r2, [r3]
32    ldr r2, [r3]
33    orr r2, r2, #14
34    str r2, [r3]
35    ldr r2, [r3]
36    and r2, r2, #15
37    orr r2, r2, #160
38    str r2, [r3]
39    bx  lr
40    .size   main, .-main
41    .global f
42    .bss
43    .align  2
44union foo {
45    uint32_t value;
46    struct {
47        uint32_t x : 1;
48        uint32_t y : 3;
49        uint32_t z : 28;
50    };
51};
52union foo f = {0};
53int main()
54{
55    volatile union foo *f_ptr = &f;
56    union foo tmp;
57    tmp =  (union foo) {
58        .x = 1,
59        .y = 7,
60        .z = 10,
61    };
62    *f_ptr = tmp;
63    return 0;
64}
65main:
66    @ args = 0, pretend = 0, frame = 0
67    @ frame_needed = 0, uses_anonymous_args = 0
68    @ link register save eliminated.
69    movs    r1, #10
70    movs    r2, #15
71    movw    r3, #:lower16:.LANCHOR0
72    bfi r2, r1, #4, #28
73    movt    r3, #:upper16:.LANCHOR0
74    movs    r0, #0
75    str r2, [r3]
76    bx  lr
77    .size   main, .-main
78    .global f
79    .bss
80    .align  2
81#include <stdint.h>
82
83union foo {
84    uint32_t value;
85    struct {
86        uint16_t x;
87        uint16_t y;
88    };
89};
90extern union foo f;
91
92int main() {
93    volatile union foo *f_ptr = &f;
94    *f_ptr = (union foo) {
95        .x = 10,
96        .y = 20,
97    };
98    return 0;
99}
100

Code generated by arm gcc 4.6.4 linux, as produced by Godbolt Compiler Explorer:

1union foo {
2    uint32_t value;
3    struct {
4        uint32_t x : 1;
5        uint32_t y : 3;
6        uint32_t z : 28;
7    };
8};
9union foo f = {0};
10int main()
11{
12    volatile union foo *f_ptr = &f;
13    //union foo tmp;
14    *f_ptr =  (union foo) {
15        .x = 1,
16        .y = 7,
17        .z = 10,
18    };
19    //*f_ptr = tmp;
20    return 0;
21}
22main:
23    @ args = 0, pretend = 0, frame = 0
24    @ frame_needed = 0, uses_anonymous_args = 0
25    @ link register save eliminated.
26    movw    r3, #:lower16:.LANCHOR0
27    movs    r0, #0
28    movt    r3, #:upper16:.LANCHOR0
29    ldr r2, [r3]
30    orr r2, r2, #1
31    str r2, [r3]
32    ldr r2, [r3]
33    orr r2, r2, #14
34    str r2, [r3]
35    ldr r2, [r3]
36    and r2, r2, #15
37    orr r2, r2, #160
38    str r2, [r3]
39    bx  lr
40    .size   main, .-main
41    .global f
42    .bss
43    .align  2
44union foo {
45    uint32_t value;
46    struct {
47        uint32_t x : 1;
48        uint32_t y : 3;
49        uint32_t z : 28;
50    };
51};
52union foo f = {0};
53int main()
54{
55    volatile union foo *f_ptr = &f;
56    union foo tmp;
57    tmp =  (union foo) {
58        .x = 1,
59        .y = 7,
60        .z = 10,
61    };
62    *f_ptr = tmp;
63    return 0;
64}
65main:
66    @ args = 0, pretend = 0, frame = 0
67    @ frame_needed = 0, uses_anonymous_args = 0
68    @ link register save eliminated.
69    movs    r1, #10
70    movs    r2, #15
71    movw    r3, #:lower16:.LANCHOR0
72    bfi r2, r1, #4, #28
73    movt    r3, #:upper16:.LANCHOR0
74    movs    r0, #0
75    str r2, [r3]
76    bx  lr
77    .size   main, .-main
78    .global f
79    .bss
80    .align  2
81#include <stdint.h>
82
83union foo {
84    uint32_t value;
85    struct {
86        uint16_t x;
87        uint16_t y;
88    };
89};
90extern union foo f;
91
92int main() {
93    volatile union foo *f_ptr = &f;
94    *f_ptr = (union foo) {
95        .x = 10,
96        .y = 20,
97    };
98    return 0;
99}
100main:
101        ldr     r3, .L2
102        mov     r0, #0
103        mov     r2, #10
104        str     r0, [r3, #0]
105        strh    r2, [r3, #0]    @ movhi
106        mov     r2, #20
107        strh    r2, [r3, #2]    @ movhi
108        bx      lr
109.L2:
110        .word   f
111

The code is much simpler but still performs a redundant store for the 32-bit value: str r0, [r3, #0] when storing the union in one shot.

Investigating this, I tried different approaches and got surprising results: using struct or union assignment generates code potentially inappropriate for memory mapped hardware register, storing the fields element-wise seems required to generate the proper code:

1union foo {
2    uint32_t value;
3    struct {
4        uint32_t x : 1;
5        uint32_t y : 3;
6        uint32_t z : 28;
7    };
8};
9union foo f = {0};
10int main()
11{
12    volatile union foo *f_ptr = &f;
13    //union foo tmp;
14    *f_ptr =  (union foo) {
15        .x = 1,
16        .y = 7,
17        .z = 10,
18    };
19    //*f_ptr = tmp;
20    return 0;
21}
22main:
23    @ args = 0, pretend = 0, frame = 0
24    @ frame_needed = 0, uses_anonymous_args = 0
25    @ link register save eliminated.
26    movw    r3, #:lower16:.LANCHOR0
27    movs    r0, #0
28    movt    r3, #:upper16:.LANCHOR0
29    ldr r2, [r3]
30    orr r2, r2, #1
31    str r2, [r3]
32    ldr r2, [r3]
33    orr r2, r2, #14
34    str r2, [r3]
35    ldr r2, [r3]
36    and r2, r2, #15
37    orr r2, r2, #160
38    str r2, [r3]
39    bx  lr
40    .size   main, .-main
41    .global f
42    .bss
43    .align  2
44union foo {
45    uint32_t value;
46    struct {
47        uint32_t x : 1;
48        uint32_t y : 3;
49        uint32_t z : 28;
50    };
51};
52union foo f = {0};
53int main()
54{
55    volatile union foo *f_ptr = &f;
56    union foo tmp;
57    tmp =  (union foo) {
58        .x = 1,
59        .y = 7,
60        .z = 10,
61    };
62    *f_ptr = tmp;
63    return 0;
64}
65main:
66    @ args = 0, pretend = 0, frame = 0
67    @ frame_needed = 0, uses_anonymous_args = 0
68    @ link register save eliminated.
69    movs    r1, #10
70    movs    r2, #15
71    movw    r3, #:lower16:.LANCHOR0
72    bfi r2, r1, #4, #28
73    movt    r3, #:upper16:.LANCHOR0
74    movs    r0, #0
75    str r2, [r3]
76    bx  lr
77    .size   main, .-main
78    .global f
79    .bss
80    .align  2
81#include <stdint.h>
82
83union foo {
84    uint32_t value;
85    struct {
86        uint16_t x;
87        uint16_t y;
88    };
89};
90extern union foo f;
91
92int main() {
93    volatile union foo *f_ptr = &f;
94    *f_ptr = (union foo) {
95        .x = 10,
96        .y = 20,
97    };
98    return 0;
99}
100main:
101        ldr     r3, .L2
102        mov     r0, #0
103        mov     r2, #10
104        str     r0, [r3, #0]
105        strh    r2, [r3, #0]    @ movhi
106        mov     r2, #20
107        strh    r2, [r3, #2]    @ movhi
108        bx      lr
109.L2:
110        .word   f
111#include <stdint.h>
112
113union foo {
114    uint32_t value;
115    struct {
116        uint16_t x;
117        uint16_t y;
118    };
119};
120extern union foo f;
121
122void store_1(void) {
123    volatile union foo *f_ptr = &f;
124    *f_ptr = (union foo) {
125        .x = 10,
126        .y = 20,
127    };
128}
129void store_2(void) {
130    volatile union foo *f_ptr = &f;
131    union foo bar = { .x = 10, .y = 20, };
132    *f_ptr = bar;
133}
134void store_3(void) {
135    volatile union foo *f_ptr = &f;
136    f_ptr->x = 10;
137    f_ptr->y = 20;
138}
139int main() {
140    return 0;
141}
142

Furthermore, removing the uint32_t value; generates calls to memcpy for the struct assignment version.

Code generated by arm gcc 4.6.4 linux:

1union foo {
2    uint32_t value;
3    struct {
4        uint32_t x : 1;
5        uint32_t y : 3;
6        uint32_t z : 28;
7    };
8};
9union foo f = {0};
10int main()
11{
12    volatile union foo *f_ptr = &f;
13    //union foo tmp;
14    *f_ptr =  (union foo) {
15        .x = 1,
16        .y = 7,
17        .z = 10,
18    };
19    //*f_ptr = tmp;
20    return 0;
21}
22main:
23    @ args = 0, pretend = 0, frame = 0
24    @ frame_needed = 0, uses_anonymous_args = 0
25    @ link register save eliminated.
26    movw    r3, #:lower16:.LANCHOR0
27    movs    r0, #0
28    movt    r3, #:upper16:.LANCHOR0
29    ldr r2, [r3]
30    orr r2, r2, #1
31    str r2, [r3]
32    ldr r2, [r3]
33    orr r2, r2, #14
34    str r2, [r3]
35    ldr r2, [r3]
36    and r2, r2, #15
37    orr r2, r2, #160
38    str r2, [r3]
39    bx  lr
40    .size   main, .-main
41    .global f
42    .bss
43    .align  2
44union foo {
45    uint32_t value;
46    struct {
47        uint32_t x : 1;
48        uint32_t y : 3;
49        uint32_t z : 28;
50    };
51};
52union foo f = {0};
53int main()
54{
55    volatile union foo *f_ptr = &f;
56    union foo tmp;
57    tmp =  (union foo) {
58        .x = 1,
59        .y = 7,
60        .z = 10,
61    };
62    *f_ptr = tmp;
63    return 0;
64}
65main:
66    @ args = 0, pretend = 0, frame = 0
67    @ frame_needed = 0, uses_anonymous_args = 0
68    @ link register save eliminated.
69    movs    r1, #10
70    movs    r2, #15
71    movw    r3, #:lower16:.LANCHOR0
72    bfi r2, r1, #4, #28
73    movt    r3, #:upper16:.LANCHOR0
74    movs    r0, #0
75    str r2, [r3]
76    bx  lr
77    .size   main, .-main
78    .global f
79    .bss
80    .align  2
81#include <stdint.h>
82
83union foo {
84    uint32_t value;
85    struct {
86        uint16_t x;
87        uint16_t y;
88    };
89};
90extern union foo f;
91
92int main() {
93    volatile union foo *f_ptr = &f;
94    *f_ptr = (union foo) {
95        .x = 10,
96        .y = 20,
97    };
98    return 0;
99}
100main:
101        ldr     r3, .L2
102        mov     r0, #0
103        mov     r2, #10
104        str     r0, [r3, #0]
105        strh    r2, [r3, #0]    @ movhi
106        mov     r2, #20
107        strh    r2, [r3, #2]    @ movhi
108        bx      lr
109.L2:
110        .word   f
111#include <stdint.h>
112
113union foo {
114    uint32_t value;
115    struct {
116        uint16_t x;
117        uint16_t y;
118    };
119};
120extern union foo f;
121
122void store_1(void) {
123    volatile union foo *f_ptr = &f;
124    *f_ptr = (union foo) {
125        .x = 10,
126        .y = 20,
127    };
128}
129void store_2(void) {
130    volatile union foo *f_ptr = &f;
131    union foo bar = { .x = 10, .y = 20, };
132    *f_ptr = bar;
133}
134void store_3(void) {
135    volatile union foo *f_ptr = &f;
136    f_ptr->x = 10;
137    f_ptr->y = 20;
138}
139int main() {
140    return 0;
141}
142store_1:
143        ldr     r3, .L2
144        mov     r2, #0
145        str     r2, [r3, #0]
146        mov     r2, #10
147        strh    r2, [r3, #0]    @ movhi
148        mov     r2, #20
149        strh    r2, [r3, #2]    @ movhi
150        bx      lr
151.L2:
152        .word   f
153store_2:
154        ldr     r3, .L5
155        ldr     r2, .L5+4
156        str     r2, [r3, #0]
157        bx      lr
158.L5:
159        .word   f
160        .word   1310730
161store_3:
162        ldr     r3, .L8
163        mov     r2, #10
164        strh    r2, [r3, #0]    @ movhi
165        mov     r2, #20
166        strh    r2, [r3, #2]    @ movhi
167        bx      lr
168.L8:
169        .word   f
170main:
171        mov     r0, #0
172        bx      lr
173

Further investigations seems to link the issue to the use of volatile union foo *f_ptr = &f; instead of tagging the union members as volatile:

1union foo {
2    uint32_t value;
3    struct {
4        uint32_t x : 1;
5        uint32_t y : 3;
6        uint32_t z : 28;
7    };
8};
9union foo f = {0};
10int main()
11{
12    volatile union foo *f_ptr = &f;
13    //union foo tmp;
14    *f_ptr =  (union foo) {
15        .x = 1,
16        .y = 7,
17        .z = 10,
18    };
19    //*f_ptr = tmp;
20    return 0;
21}
22main:
23    @ args = 0, pretend = 0, frame = 0
24    @ frame_needed = 0, uses_anonymous_args = 0
25    @ link register save eliminated.
26    movw    r3, #:lower16:.LANCHOR0
27    movs    r0, #0
28    movt    r3, #:upper16:.LANCHOR0
29    ldr r2, [r3]
30    orr r2, r2, #1
31    str r2, [r3]
32    ldr r2, [r3]
33    orr r2, r2, #14
34    str r2, [r3]
35    ldr r2, [r3]
36    and r2, r2, #15
37    orr r2, r2, #160
38    str r2, [r3]
39    bx  lr
40    .size   main, .-main
41    .global f
42    .bss
43    .align  2
44union foo {
45    uint32_t value;
46    struct {
47        uint32_t x : 1;
48        uint32_t y : 3;
49        uint32_t z : 28;
50    };
51};
52union foo f = {0};
53int main()
54{
55    volatile union foo *f_ptr = &f;
56    union foo tmp;
57    tmp =  (union foo) {
58        .x = 1,
59        .y = 7,
60        .z = 10,
61    };
62    *f_ptr = tmp;
63    return 0;
64}
65main:
66    @ args = 0, pretend = 0, frame = 0
67    @ frame_needed = 0, uses_anonymous_args = 0
68    @ link register save eliminated.
69    movs    r1, #10
70    movs    r2, #15
71    movw    r3, #:lower16:.LANCHOR0
72    bfi r2, r1, #4, #28
73    movt    r3, #:upper16:.LANCHOR0
74    movs    r0, #0
75    str r2, [r3]
76    bx  lr
77    .size   main, .-main
78    .global f
79    .bss
80    .align  2
81#include <stdint.h>
82
83union foo {
84    uint32_t value;
85    struct {
86        uint16_t x;
87        uint16_t y;
88    };
89};
90extern union foo f;
91
92int main() {
93    volatile union foo *f_ptr = &f;
94    *f_ptr = (union foo) {
95        .x = 10,
96        .y = 20,
97    };
98    return 0;
99}
100main:
101        ldr     r3, .L2
102        mov     r0, #0
103        mov     r2, #10
104        str     r0, [r3, #0]
105        strh    r2, [r3, #0]    @ movhi
106        mov     r2, #20
107        strh    r2, [r3, #2]    @ movhi
108        bx      lr
109.L2:
110        .word   f
111#include <stdint.h>
112
113union foo {
114    uint32_t value;
115    struct {
116        uint16_t x;
117        uint16_t y;
118    };
119};
120extern union foo f;
121
122void store_1(void) {
123    volatile union foo *f_ptr = &f;
124    *f_ptr = (union foo) {
125        .x = 10,
126        .y = 20,
127    };
128}
129void store_2(void) {
130    volatile union foo *f_ptr = &f;
131    union foo bar = { .x = 10, .y = 20, };
132    *f_ptr = bar;
133}
134void store_3(void) {
135    volatile union foo *f_ptr = &f;
136    f_ptr->x = 10;
137    f_ptr->y = 20;
138}
139int main() {
140    return 0;
141}
142store_1:
143        ldr     r3, .L2
144        mov     r2, #0
145        str     r2, [r3, #0]
146        mov     r2, #10
147        strh    r2, [r3, #0]    @ movhi
148        mov     r2, #20
149        strh    r2, [r3, #2]    @ movhi
150        bx      lr
151.L2:
152        .word   f
153store_2:
154        ldr     r3, .L5
155        ldr     r2, .L5+4
156        str     r2, [r3, #0]
157        bx      lr
158.L5:
159        .word   f
160        .word   1310730
161store_3:
162        ldr     r3, .L8
163        mov     r2, #10
164        strh    r2, [r3, #0]    @ movhi
165        mov     r2, #20
166        strh    r2, [r3, #2]    @ movhi
167        bx      lr
168.L8:
169        .word   f
170main:
171        mov     r0, #0
172        bx      lr
173#include <stdint.h>
174
175union foo {
176    uint32_t value;
177    struct {
178        volatile uint16_t x;
179        volatile uint16_t y;
180    };
181};
182extern union foo f;
183
184void store_1(void) {
185    union foo *f_ptr = &f;
186    *f_ptr = (union foo) {
187        .x = 10,
188        .y = 20,
189    };
190    *f_ptr = (union foo) {
191        .x = 10,
192        .y = 20,
193    };
194}
195void store_2(void) {
196    union foo *f_ptr = &f;
197    union foo bar = { .x = 10, .y = 20, };
198    *f_ptr = bar;
199    *f_ptr = bar;
200}
201void store_3(void) {
202    union foo *f_ptr = &f;
203    f_ptr->x = 10;
204    f_ptr->y = 20;
205    f_ptr->x = 10;
206    f_ptr->y = 20;
207}
208

Code generated:

1union foo {
2    uint32_t value;
3    struct {
4        uint32_t x : 1;
5        uint32_t y : 3;
6        uint32_t z : 28;
7    };
8};
9union foo f = {0};
10int main()
11{
12    volatile union foo *f_ptr = &f;
13    //union foo tmp;
14    *f_ptr =  (union foo) {
15        .x = 1,
16        .y = 7,
17        .z = 10,
18    };
19    //*f_ptr = tmp;
20    return 0;
21}
22main:
23    @ args = 0, pretend = 0, frame = 0
24    @ frame_needed = 0, uses_anonymous_args = 0
25    @ link register save eliminated.
26    movw    r3, #:lower16:.LANCHOR0
27    movs    r0, #0
28    movt    r3, #:upper16:.LANCHOR0
29    ldr r2, [r3]
30    orr r2, r2, #1
31    str r2, [r3]
32    ldr r2, [r3]
33    orr r2, r2, #14
34    str r2, [r3]
35    ldr r2, [r3]
36    and r2, r2, #15
37    orr r2, r2, #160
38    str r2, [r3]
39    bx  lr
40    .size   main, .-main
41    .global f
42    .bss
43    .align  2
44union foo {
45    uint32_t value;
46    struct {
47        uint32_t x : 1;
48        uint32_t y : 3;
49        uint32_t z : 28;
50    };
51};
52union foo f = {0};
53int main()
54{
55    volatile union foo *f_ptr = &f;
56    union foo tmp;
57    tmp =  (union foo) {
58        .x = 1,
59        .y = 7,
60        .z = 10,
61    };
62    *f_ptr = tmp;
63    return 0;
64}
65main:
66    @ args = 0, pretend = 0, frame = 0
67    @ frame_needed = 0, uses_anonymous_args = 0
68    @ link register save eliminated.
69    movs    r1, #10
70    movs    r2, #15
71    movw    r3, #:lower16:.LANCHOR0
72    bfi r2, r1, #4, #28
73    movt    r3, #:upper16:.LANCHOR0
74    movs    r0, #0
75    str r2, [r3]
76    bx  lr
77    .size   main, .-main
78    .global f
79    .bss
80    .align  2
81#include <stdint.h>
82
83union foo {
84    uint32_t value;
85    struct {
86        uint16_t x;
87        uint16_t y;
88    };
89};
90extern union foo f;
91
92int main() {
93    volatile union foo *f_ptr = &f;
94    *f_ptr = (union foo) {
95        .x = 10,
96        .y = 20,
97    };
98    return 0;
99}
100main:
101        ldr     r3, .L2
102        mov     r0, #0
103        mov     r2, #10
104        str     r0, [r3, #0]
105        strh    r2, [r3, #0]    @ movhi
106        mov     r2, #20
107        strh    r2, [r3, #2]    @ movhi
108        bx      lr
109.L2:
110        .word   f
111#include <stdint.h>
112
113union foo {
114    uint32_t value;
115    struct {
116        uint16_t x;
117        uint16_t y;
118    };
119};
120extern union foo f;
121
122void store_1(void) {
123    volatile union foo *f_ptr = &f;
124    *f_ptr = (union foo) {
125        .x = 10,
126        .y = 20,
127    };
128}
129void store_2(void) {
130    volatile union foo *f_ptr = &f;
131    union foo bar = { .x = 10, .y = 20, };
132    *f_ptr = bar;
133}
134void store_3(void) {
135    volatile union foo *f_ptr = &f;
136    f_ptr->x = 10;
137    f_ptr->y = 20;
138}
139int main() {
140    return 0;
141}
142store_1:
143        ldr     r3, .L2
144        mov     r2, #0
145        str     r2, [r3, #0]
146        mov     r2, #10
147        strh    r2, [r3, #0]    @ movhi
148        mov     r2, #20
149        strh    r2, [r3, #2]    @ movhi
150        bx      lr
151.L2:
152        .word   f
153store_2:
154        ldr     r3, .L5
155        ldr     r2, .L5+4
156        str     r2, [r3, #0]
157        bx      lr
158.L5:
159        .word   f
160        .word   1310730
161store_3:
162        ldr     r3, .L8
163        mov     r2, #10
164        strh    r2, [r3, #0]    @ movhi
165        mov     r2, #20
166        strh    r2, [r3, #2]    @ movhi
167        bx      lr
168.L8:
169        .word   f
170main:
171        mov     r0, #0
172        bx      lr
173#include <stdint.h>
174
175union foo {
176    uint32_t value;
177    struct {
178        volatile uint16_t x;
179        volatile uint16_t y;
180    };
181};
182extern union foo f;
183
184void store_1(void) {
185    union foo *f_ptr = &f;
186    *f_ptr = (union foo) {
187        .x = 10,
188        .y = 20,
189    };
190    *f_ptr = (union foo) {
191        .x = 10,
192        .y = 20,
193    };
194}
195void store_2(void) {
196    union foo *f_ptr = &f;
197    union foo bar = { .x = 10, .y = 20, };
198    *f_ptr = bar;
199    *f_ptr = bar;
200}
201void store_3(void) {
202    union foo *f_ptr = &f;
203    f_ptr->x = 10;
204    f_ptr->y = 20;
205    f_ptr->x = 10;
206    f_ptr->y = 20;
207}
208store_1:
209        ldr     r3, .L2
210        mov     r1, #10
211        mov     r2, #20
212        strh    r1, [r3, #0]    @ movhi
213        strh    r2, [r3, #2]    @ movhi
214        strh    r1, [r3, #0]    @ movhi
215        strh    r2, [r3, #2]    @ movhi
216        bx      lr
217.L2:
218        .word   f
219store_2:
220        ldr     r3, .L5
221        ldr     r2, .L5+4
222        str     r2, [r3, #0]
223        bx      lr
224.L5:
225        .word   f
226        .word   1310730
227store_3:
228        ldr     r3, .L8
229        mov     r1, #10
230        mov     r2, #20
231        strh    r1, [r3, #0]    @ movhi
232        strh    r2, [r3, #2]    @ movhi
233        strh    r1, [r3, #0]    @ movhi
234        strh    r2, [r3, #2]    @ movhi
235        bx      lr
236.L8:
237        .word   f
238

As you can see, assigning the union does not generate appropriate code in store_2, even when qualifying the value member as volatile too.

Using the C99 compound literals seems to work correctly in store_1, generating redundant stores when the fields are qualified as volatile.

Yet I would recommend assigning the fields explicitly as in store_3, making the assignment order explicit too. If instead you want to generate a single 32-bit store, assuming it is correct for your hardware, Aki Suihkonen suggested an interesting approach.

The original problem is a side effect of how the compiler generates code for assigning compound literals to structures and unions: it first initializes the destination to all bits zero, then stores the members specified in the compound literal explicitly. Redundant stores are eliminated unless the destination is volatile qualified`. I don't believe this behavior is mandated by the C Standard, so it may well be compiler specific.

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

QUESTION

How to cast nonconst variable to constant static integral class member variable via reinterpret_cast in C++?

Asked 2022-Jan-03 at 20:42

I am reading a book on writing modern C++ code for microcontrollers which is named "Real time C++". I am trying to write the codes in the book myself. However, while copying the code from the book and trying to build it, I got a compilation error of:

error C2131: expression did not evaluate to a constant.
message : a non-constant (sub-) expression was encountered

I inserted the relevant part of the code below:

1#include <cstdint>
2#include <iomanip>
3#include <iostream>
4namespace mcal
5{
6  namespace reg
7  {
8    // Simulate the transmit and receive hardware buffers on the PC.
9    std::uint8_t dummy_register_tbuf;
10    std::uint8_t dummy_register_rbuf;
11  }
12}
13
14class communication
15{
16  private:
17    static constexpr std::uint8_t* tbuf = reinterpret_cast<std::uint8_t*>(&mcal::reg::dummy_register_tbuf); 
18    static constexpr std::uint8_t* rbuf = reinterpret_cast<std::uint8_t*>(&mcal::reg::dummy_register_rbuf);
19};
20
21/* rest of the nonrelated code */
22

The error indicates those two lines where casting happens. I know that we try to use static constexpr integral class member variables, because this ensures optimization (constant folding) on them. I think that the error happens because we try to set a nonconstant variable to a constant variable, but I can be wrong surely. So, I would kindly ask you to explain to me what is the real problem here and why the author did such a mistake (if it is a mistake). Also, if you additionally point out the correct way of casting I would highly appreciate. Thank you very much.

ANSWER

Answered 2022-Jan-03 at 20:42

It is unclear what the intention behind the reinterpret_cast is, but the program is ill-formed.

constexpr on a variable requires that the initializer is a constant expression. But an expression is disqualified from being a constant expression if it would evaluate a reinterpret_cast. Therefore the initialization is ill-formed.

However, nothing else in the initialization stops it from being a constant expression and so

1#include <cstdint>
2#include <iomanip>
3#include <iostream>
4namespace mcal
5{
6  namespace reg
7  {
8    // Simulate the transmit and receive hardware buffers on the PC.
9    std::uint8_t dummy_register_tbuf;
10    std::uint8_t dummy_register_rbuf;
11  }
12}
13
14class communication
15{
16  private:
17    static constexpr std::uint8_t* tbuf = reinterpret_cast<std::uint8_t*>(&mcal::reg::dummy_register_tbuf); 
18    static constexpr std::uint8_t* rbuf = reinterpret_cast<std::uint8_t*>(&mcal::reg::dummy_register_rbuf);
19};
20
21/* rest of the nonrelated code */
22static constexpr std::uint8_t* tbuf = &mcal::reg::dummy_register_tbuf; 
23

will just work and the reinterpret_cast would be a redundant anyway since it would cast between identical pointer types which is specified to result in the same value.

GCC, ICC and MSVC up to v19.16 do seem to erroneously accept the code (https://godbolt.org/z/YKjhxqo3v). Maybe the author tested the code only on one of these compilers.

For GCC there is a bug report here.

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

Community Discussions contain sources that include Stack Exchange Network

Tutorials and Learning Resources in Hardware

Tutorials and Learning Resources are not available at this moment for Hardware

Share this Page

share link

Get latest updates on Hardware