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

Popular New Releases in Storage

minio

Bugfix release

rclone

rclone v1.58.0

localForage

Avoid dropInstance uncaught errors

seaweedfs

Cloudreve

3.5.0-beta2

Popular Libraries in Storage

minio

by minio doticongodoticon

star image 32602 doticonAGPL-3.0

High Performance, Kubernetes Native Object Storage

rclone

by rclone doticongodoticon

star image 32354 doticonMIT

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Yandex Files

localForage

by localForage doticonjavascriptdoticon

star image 19416 doticonApache-2.0

💾 Offline storage, improved. Wraps IndexedDB, WebSQL, or localStorage using a simple but powerful API.

seaweedfs

by chrislusf doticongodoticon

star image 14297 doticonApache-2.0

SeaweedFS is a fast distributed storage system for blobs, objects, files, and data lake, for billions of files! Blob store has O(1) disk seek, cloud tiering. Filer supports Cloud Drive, cross-DC active-active replication, Kubernetes, POSIX FUSE mount, S3 API, S3 Gateway, Hadoop, WebDAV, encryption, Erasure Coding.

Cloudreve

by cloudreve doticongodoticon

star image 14265 doticonGPL-3.0

🌩支持多家云存储的云盘系统 (Self-hosted file management and sharing system, supports multiple storage providers)

store.js

by marcuswestin doticonjavascriptdoticon

star image 13575 doticonMIT

Cross-browser storage for all use cases, used across the web.

go-ipfs

by ipfs doticongodoticon

star image 13201 doticonNOASSERTION

IPFS implementation in Go

flysystem

by thephpleague doticonphpdoticon

star image 12433 doticonMIT

Abstraction for local and remote filesystems

ceph

by ceph doticonc++doticon

star image 10429 doticonNOASSERTION

Ceph is a distributed object, block, and file storage platform

Trending New libraries in Storage

juicefs

by juicedata doticongodoticon

star image 5231 doticonApache-2.0

JuiceFS is a distributed POSIX file system built on top of Redis and S3.

Tendis

by Tencent doticonc++doticon

star image 2127 doticonNOASSERTION

Tendis is a high-performance distributed storage system fully compatible with the Redis protocol.

terarkdb

by bytedance doticonc++doticon

star image 1606 doticonNOASSERTION

A RocksDB compatible KV storage engine with better performance

bee

by ethersphere doticongodoticon

star image 1335 doticonBSD-3-Clause

Bee is a Swarm client implemented in Go. It’s the basic building block for the Swarm network: a private; decentralized; and self-sustaining network for permissionless publishing and access to your (application) data.

nfs-subdir-external-provisioner

by kubernetes-sigs doticonshelldoticon

star image 965 doticonApache-2.0

Dynamic sub-dir volume provisioner on a remote NFS server.

modernstorage

by google doticonkotlindoticon

star image 952 doticonApache-2.0

ModernStorage is a group of libraries that provide an abstraction layer over storage on Android to simplify its interactions

utahfs

by cloudflare doticongodoticon

star image 746 doticonBSD-3-Clause

UtahFS is an encrypted storage system that provides a user-friendly FUSE drive backed by cloud storage.

use-local-storage-state

by astoilkov doticontypescriptdoticon

star image 649 doticonMIT

React hook that persists data in localStorage

cortx

by Seagate doticonjupyter notebookdoticon

star image 548 doticonApache-2.0

CORTX Community Object Storage is 100% open source object storage uniquely optimized for mass capacity storage devices.

Top Authors in Storage

1

ipfs

57 Libraries

star icon29583

2

ipfs-shipyard

45 Libraries

star icon5580

3

ipfs-inactive

27 Libraries

star icon413

4

aws-samples

23 Libraries

star icon967

5

awslabs

19 Libraries

star icon2283

6

gluster

19 Libraries

star icon4835

7

orbitdb

16 Libraries

star icon7535

8

RTradeLtd

16 Libraries

star icon68

9

textileio

16 Libraries

star icon1075

10

kubernetes-sigs

15 Libraries

star icon3731

1

57 Libraries

star icon29583

2

45 Libraries

star icon5580

3

27 Libraries

star icon413

4

23 Libraries

star icon967

5

19 Libraries

star icon2283

6

19 Libraries

star icon4835

7

16 Libraries

star icon7535

8

16 Libraries

star icon68

9

16 Libraries

star icon1075

10

15 Libraries

star icon3731

Trending Kits in Storage


Java Encryption Libraries enable password encryption, digital signatures, secure random number generation, message authentication, and 2FA. 


Encryption, decryption, and key generation are the three most crucial aspects of Java cryptography. Key-based data security can be enabled in two ways, using symmetric or asymmetric encryption algorithms, considering how secure the code needs to be. Moreover, developers can easily enable security functions directly into the code with the set of APIs available in the Java Cryptography Architecture (JCA). The JCA is the core of java encryption and decryption, hashing, secure random, and various other java cryptographic functions.


Check out the below list to find more trending Java encryption libraries for your applications:

tink  

  • Offers various cryptographic functions like encryption, digital signatures, and more.  
  • Provides an easy-to-use interface, simplifying the implementation of robust security measures.  
  • Follows best practices, minimizing the chance of security vulnerabilities in cryptographic operations.  

bc-java  

  • Provides various encryption, signatures, and hashing algorithms.  
  • Offers flexible options for cryptographic operations to suit various protocols.  
  • Seamlessly integrates into Java applications for strong security features.

jasypt  

  • Supports many encryption methods for tailored security.  
  • Seamlessly integrates encryption features into Java codebases.  
  • Allows easy setup of encryption configurations for different use cases.  

cryptomator  

  • Encrypts files before uploading them to the cloud, keeping data private.  
  • Can easily access encrypted files and work with your data as usual.  
  • Enables secure file storage and access from different environments.  

Aegis  

  • Offers authenticated encryption schemes, ensuring both data confidentiality and integrity.  
  • Provides a user-friendly and straightforward API for implementing cryptographic operations.  
  • Is lightweight and easy to carry, so it works well in limited environments or small systems.  

mockserver  

  • Facilitates creating mock servers for testing and simulating HTTP/HTTPS interactions.  
  • Setting precise expectations for requests and responses helps thoroughly test API interactions.  
  • Can save API requests to reuse in tests for accuracy and reproducibility.  

hawk  

  • Offers a strong MAC algorithm for verifying the integrity and authenticity of messages.  
  • Utilizes an authorization header to transmit authentication information, enhancing security securely.  
  • Works across various platforms and languages, allowing integration into different applications and systems.  

GDA-android-reversing-Tool  

  • Can learn about Android apps by analyzing them using reverse engineering.  
  • Helps analyze and break down the code of Android apps for inspection.  
  • The graphical interface makes it easy to use the reverse engineering features.  

wycheproof  

  • Enables testing cryptographic algorithms and libraries for known security vulnerabilities and weaknesses.  
  • Have many cryptography test cases to ensure it works well in different situations.  
  • Helps confirm if cryptographic implementations work well on different platforms and libraries.  

bt  

  • Can share files, reducing the need for central servers and speeding up downloads.  
  • To speed up downloads, it uses a method called "swarming." This method collects small pieces from many sources simultaneously.  
  • The protocol will download from other sources if a source is unavailable. This ensures that downloads are uninterrupted and strong.  

Peergos  

  • Provides strong file encryption, ensuring data privacy and security from unauthorized access.  
  • Users gain control over their data. They can securely share files and manage access permissions.  
  • It uses a network not centered in one place to save and find files. This makes it so we don't have to rely on one main server, which helps ensure the data is always there and strong.  

i2p.i2p  

  • Let users browse websites and send messages without showing their IP addresses.  
  • Uses powerful encryption to keep data safe and secure when it's sent.  
  • The routing mechanism is not centralized. This makes it difficult for others to track online activities.  

secure-preferences  

  • We use encryption to protect private information from people who shouldn't see it.  
  • It works with Android's SharedPreferences API. This means you can easily use secure data storage without changing much code.  
  • The app protects sensitive information, reducing the risk of data breaches or leaks. It enhances user privacy.  

AndroidWM  

  • Can add personalized watermarks to images, improving branding and ownership recognition.  
  • Can choose where the watermark goes, how big it is, how see-through it is, and what it looks like.  
  • Can process many images together, which makes it simpler to add watermarks to them.  

Cipher.so  

  • Can easily use native code for cryptography in Android apps.  
  • Optimized cryptographic algorithms for efficient and secure data encryption and decryption.  
  • Supports various encryption and decryption methods, enabling customization based on specific security requirements.  

conscrypt  

  • Uses many different ways to keep data safe when encrypted or sent.  
  • Offers up-to-date TLS and SSL protocol versions for secure network communication.  
  • Ensures compatibility with older Android versions, allowing applications to maintain security across devices.  

react-native-sensitive-info  

  • Can securely store sensitive information like passwords or tokens.  
  • Compatible with both Android and iOS, ensuring consistent security practices across different platforms.  
  • Utilizes encryption mechanisms to protect sensitive data from unauthorized access.  

android-storage  

  • Simplifies data storage and retrieval tasks in Android apps, promoting efficient data handling.  
  • Offers the option to encrypt files stored on the device, enhancing data security.  
  • Can focus on how things work instead of how things are stored.  

whorlwind  

  • Offer tools to protect data when stored and transferred, ensuring it stays safe.  
  • Supports various encryption algorithms for different security needs.  
  • Designed for use across various platforms, promoting consistent security practices.  

encrypt  

  • Enables encryption and decryption operations within Android applications.  
  • Supports many encryption algorithms, offering flexibility in choosing the appropriate method.  
  • Simplifies the process of implementing encryption-related functionalities.  

java-aes-crypto  

  • Offers AES encryption and decryption capabilities, a widely used symmetric encryption algorithm.  
  • Provides mechanisms for secure key generation and management within Java applications.  
  • Supports cryptographic modes that ensure both data confidentiality and integrity.  

Android-Goldfinger  

  • Facilitates fingerprint-based authentication and access control in Android apps.  
  • Enhances user security by integrating biometric authentication.  
  • Offers a user-friendly interface for integrating fingerprint-related functionalities.  

AESCrypt-Android  

  • Implements AES encryption and decryption for protecting sensitive data in Android applications.  
  • Provides straightforward methods for incorporating AES cryptography into your code.  
  • Enables users to store and transmit sensitive information securely.  

Secured-Preference-Store  

  • Enhances SharedPreferences with encryption, safeguarding sensitive user preferences.  
  • Offers a seamless way to integrate secure preference storage without extensive code modifications.  
  • Prevents unauthorized access to preference data by implementing encryption mechanisms.  

EncryptedPreferences  

  • Integrates secure storage mechanisms for sensitive preferences in Android apps.  
  • Implements encryption to prevent data exposure or tampering.  
  • Provides an API for easily incorporating encrypted preference storage in Android projects.  

FAQ

What are Java encryption Libraries, and what basic encryption capabilities do they provide?  

Java encryption libraries are tools used to improve data security in Java applications. They help implement cryptographic techniques. They offer:  

  • AES (Advanced Encryption Standard): Symmetric encryption for secure data transmission.  
  • RSA (Rivest–Shamir–Adleman): Asymmetric encryption for secure key exchange and digital signatures.  
  • Hashing Algorithms: Generate secure hash codes to verify data integrity.  
  • Digital Signatures: Authenticate data origin and verify integrity.  
  • Key Management: Generate, store, and handle encryption keys.  
  • SSL/TLS: Implement secure communication over networks.  
  • PGP (Pretty Good Privacy): Encrypt and decrypt data for privacy.  

   

How can password encryption be achieved using Java libraries?  

In Java, you can encrypt passwords using JCA or third-party libraries. Hashing algorithms, such as bcrypt and SHA-256, convert passwords into irreversible codes. To keep user credentials safe, adding salt and storing them securely is important. This helps to prevent attacks and maintain confidentiality.  

  

Are digital signatures supported by any of the Java encryption libraries?  

Yes, digital signatures are supported by various Java encryption libraries. Java Cryptography Architecture (JCA) libraries enable the creation and verification of digital signatures. They use algorithms like RSA for asymmetric encryption. Digital signatures are important in Java applications for secure communication and authentication. They ensure data is authentic, integral, and cannot be denied. Bouncy Castle and other Java libraries can help with digital signatures and cryptography.  

  

What is an encryption key, and how is it used to encrypt and decrypt data securely?  

An encryption key is a special code that turns normal data into secret code and back again. It decides how data is changed so only authorized people with the right key can see it. Strong key management is essential to maintain data security and prevent unauthorized access.   

Encryption keys are crucial for secure communication. Data is kept safe from unauthorized access. This happens when it's being transmitted or stored.  

  

Can you create a Message Authentication Code using a popular Java encryption library?  

Developers can use algorithms, such as HMAC from JCA, to implement MAC for security. The sender creates a code that receivers can check using a secret key. This process ensures data is correct and information is secure when sent.  

  

Is there an easy way to generate cipher text from plain text using a library written in Java?  

Java has libraries like JCA that help turn plain text into secret code. Developers can change plain text into cipher text. They do this by choosing an encryption algorithm, such as AES, and using a secret key. They can do this through straightforward method calls. Java applications can securely transmit and store data while keeping it confidential. Developers can easily add strong encryption using these libraries without needing complex coding.  

LocalStorage is a browser-native API that helps to store data in the user's browser. It's a widely supported Web Storage API specification interface. In Node.js, the "localStorage" module wraps the browser's native localStorage API.  

 

LocalStorage enables client-side content storage, persisting data even after the browser window closes. It offers a simple API with various methods to manipulate data items asynchronously. Dot-property syntax allows easy data access and modification using JavaScript functions.  

 

When working with LocalStorage, remember that it has a read-only property. The client-side code can only access and modify the data stored by itself. Moreover, implement error handlers for any access or modification issues.  

 

In Node.js, LocalStorage stores user data and application data for specific functionalities. It's useful for temporary data during asynchronous tasks or operations.  

 

Using LocalStorage in Node.js applications can enhance performance. Caching retrieved data from a web server improves application responsiveness, reducing HTTP requests. It benefits frequent data fetching, code editors, and file manipulation.  

 

A web server can cache data using LocalStorage, improving load and response times. The LocalStorage stores authentication tokens or session info for user authentication.  

Conclusion:

LocalStorage in Node.js provides efficient client-side data storage and retrieval. It enhances application performance, offers a simple API, and supports various browsers. Node.js and Linux developers enjoy LocalStorage's versatility in browser and server-side technologies. 

localForage   

- It helps in storing data locally within the browser.  

- It supports key-value pair storage for small to medium-sized data.  

- It stores user preferences, session data, or caching. 

lowdb:   

- It helps create and manage a lightweight JSON database on the local file system.  

- It supports querying, filtering, and updating data using a familiar syntax.  

- It is useful for small to medium-sized applications that require a simple database.  

nedb:   

- It helps in creating an in-memory or persistent embedded database.  

- It supports indexing, querying, and sorting data.  

- It is suitable for small to medium-sized apps requiring lightweight database solutions.  

store:   

- It helps in managing a simple key-value stored in memory.  

- It supports storing and retrieving data with an easy-to-use API.  

- It is used for temporary storage or caching data within a Node.js application. 

keyv:   

- It helps create a key-value store that supports various storage backends (e.g., memory, Redis, SQLite).  

- It supports TTL (Time-to-Live) for automatic data expiration.  

- It is suitable for distributed applications or scenarios with different storage options.  

level:   

- It helps in creating a fast and simple key-value store.  

- It supports various storage backends, including in-memory, disk-based, and cloud-based options.  

- It is useful for applications that require efficient data storage and retrieval.  

memcached:   

- It helps in utilizing a Memcached server for distributed caching.  

- It supports storing and retrieving data using a simple API.  

- It is helpful for applications with high read-intensive workloads or caching requirements.  

node-persist:   

- It helps in persisting data on the local file system.  

- It supports automatic serialization and deserialization of JavaScript objects.  

- It is suitable for storing larger data sets or complex data structures.

keyv-file:   

- It helps in creating a file-based key-value store.  

- It supports the persistence and synchronization of data across multiple instances.  

- It is suitable for scenarios where a file-based storage solution is preferred.  

FAQ 

1. What is the localStorage API, and what are its advantages?   

The localStorage API is a browser-native API that allows web apps to store data on the client side. Its simple key-value storage mechanism helps developers save user browser data. The advantages of using the localStorage API include:  

Simplicity:  

The API offers a straightforward interface with methods like setItem(), getItem(), and removeItem(). This helps with storing, retrieving, and removing data.  

Persistence:   

Data stored using localStorage persists even after the browser window is closed. This provides a reliable storage solution for web applications.  

Larger Storage Capacity:  

localStorage allows for larger storage capacity compared to other client-side storage options.  

Better Performance:   

Accessing data from localStorage is faster than making server requests. Thus, it helps in improving the performance of the web application.  

Security:   

Data stored in localStorage is only accessible by the web application itself. This is because it is tied to the origin and cannot be accessed by other websites or scripts.  

 

2. How does browser local storage work with Web Storage API?   

Browser local storage works hand in hand with the Web Storage API. It includes two storage mechanisms: localStorage and sessionStorage. Both mechanisms provide a key-value storage interface but differ in data persistence. localStorage stores data that remains available even after the browser window is closed. On the other hand, sessionStorage stores data for the duration of the page session.  

 

To use local browser storage, you can interact with it through the Web Storage API methods. These can include localStorage.setItem(), localStorage.getItem(), and localStorage.removeItem(). These methods allow storing, retrieving, and removing data from the localStorage object. Data is stored as strings and can be accessed using unique keys.  

 

3. What are the considerations for JavaScript files when using the Node.js LocalStorage library?   

Considerations when using JavaScript files with the Node.js localStorage library:  

  • Firstly, ensure to import the localStorage library into your JavaScript file. Do this using the require() function or include it in your project dependencies.  
  • Secondly, localStorage being browser-native API, is default unavailable in Node.js runtime environment. To use localStorage in Node.js, install & import a library emulating browser functionality.  

 

4. What browser support is available for the nodejs localstorage library?   

The browser support for Node.js localStorage library depends on the chosen module. Libraries vary in compatibility with browsers. Some support major browsers, and others have limitations or specific requirements.  

 

Check the localStorage library documentation for the browser support matrix. Modern browsers have good support for localStorage, including Chrome, Firefox, Safari, and more. However, testing your application across different browsers is good to ensure consistency.  

 

5. How do web requests interact with the nodejs localstorage library?   

The nodejs localStorage library does not interact with web requests. Node.js LocalStorage enables local storage within a runtime environment, like the browser localStorage. It stores and retrieves server data locally, avoiding external HTTP requests.  

 

When using web requests in Node.js, the localStorage library can cache fetched data. Storing frequently accessed data locally minimizes repetitive requests. This enhances performance and reduces network latency.  

 

Thus, the nodejs localStorage library provides local storage functionality within its runtime environment. Web requests in Node.js can use local storage to optimize data fetching and performance. 

Trending Discussions on Storage

Why is std::aligned_storage to be deprecated in C++23 and what to use instead?

`Firebase` package was successfully found. However, this package itself specifies a `main` module field that could not be resolved

After upgrading from Angular 12 to 13, cache is too large for Github

android:exported added but still getting error Apps targeting Android 12 and higher are required to specify an explicit value for android:exported

How to fix: "@angular/fire"' has no exported member 'AngularFireModule'.ts(2305) ionic, firebase, angular

How to solve FirebaseError: Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore problem?

How is optional assignment constexpr in C++ 20?

No analytics cookies is set upon a consent was updated

Do not nest files in rails active storage

What should happen if one calls `std::exit` in a global object's destructor?

QUESTION

Why is std::aligned_storage to be deprecated in C++23 and what to use instead?

Asked 2022-Apr-11 at 14:18

I just saw that C++23 plans to deprecate both std::aligned_storage and std::aligned_storage_t as well as std::aligned_union and std::aligned_union_t.

Placement new'd objects in aligned storage are not particularly constexpr friendly as far as I understand, but that doesn't appear to be a good reason to throw out the type completely. This leads me to assume that there is some other fundamental problem with using std::aligned_storage and friends that I am not aware of. What would that be?

And is there a proposed alternative to these types?

ANSWER

Answered 2022-Apr-11 at 14:18

Here are three excerpts from P1413R3:

Background

aligned_* are harmful to codebases and should not be used. At a high level:

  • Using aligned_* invokes undefined behavior (The types cannot provide storage.)
  • The guarantees are incorrect (The standard only requires that the type be at least as large as requested but does not put an upper bound on the size.)
  • The API is wrong for a plethora of reasons (See "On the API".)
  • Because the API is wrong, almost all usage involves the same repeated pre-work (See "Existing usage".)

On the API

std::aligned_* suffer from many poor API design decisions. Some of these are shared, and some are specific to each. As for what is shared, there are three main problems [only one is included here for brevity]:

  • Using reinterpret_cast is required to access the value

There is no .data() or even .data on std::aligned_* instances. Instead, the API requires you to take the address of the object, call reinterpret_cast<T*>(...) with it, and then finally indirect the resulting pointer giving you a T&. Not only does this mean that it cannot be used in constexpr, but at runtime it's much easier to accidentally invoke undefined behavior. reinterpret_cast being a requirement for use of an API is unacceptable.


Suggested replacement

The easiest replacement for aligned_* is actually not a library feature. Instead, users should use a properly-aligned array of std::byte, potentially with a call to std::max(std::initializer_list<T>) . These can be found in the <cstddef> and <algorithm> headers, respectively (with examples at the end of this section). Unfortunately, this replacement is not ideal. To access the value of aligned_*, users must call reinterpret_cast on the address to read the bytes as T instances. Using a byte array as a replacement does not avoid this problem. That said, it's important to recognize that continuing to use reinterpret_cast where it already exists is not nearly as bad as newly introducing it where it was previously not present. ...

The above section from the accepted proposal to retire aligned_* is then followed with a number of examples, like these two replacement suggestions:

1// To replace std::aligned_storage
2template &lt;typename T&gt;
3class MyContainer {
4private:
5    //std::aligned_storage_t&lt;sizeof(T), alignof(T)&gt; t_buff;
6    alignas(T) std::byte t_buff[sizeof(T)];
7};
8
1// To replace std::aligned_storage
2template &lt;typename T&gt;
3class MyContainer {
4private:
5    //std::aligned_storage_t&lt;sizeof(T), alignof(T)&gt; t_buff;
6    alignas(T) std::byte t_buff[sizeof(T)];
7};
8// To replace std::aligned_union
9template &lt;typename... Ts&gt;
10class MyContainer {
11private:
12    //std::aligned_union_t&lt;0, Ts...&gt; t_buff;
13    alignas(Ts...) std::byte t_buff[std::max({sizeof(Ts)...})];
14};
15

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

QUESTION

`Firebase` package was successfully found. However, this package itself specifies a `main` module field that could not be resolved

Asked 2022-Apr-02 at 17:19

I'm trying to read and write to firestore, use firebase's authentication, and firebase's storage within a expo managed react-native application.

Full Error:

1While trying to resolve module `firebase` from file `C:\Users\joshu\Desktop\VSProjects\VolleyballConnect\firebase.js`, the package `C:\Users\joshu\Desktop\VSProjects\VolleyballConnect\node_modules\firebase\package.json` was successfully found. However, this package itself specifies a `main` module field that could not be resolved (`C:\Users\joshu\Desktop\VSProjects\VolleyballConnect\node_modules\firebase\index`. Indeed, none of these files exist:
2
3  * C:\Users\joshu\Desktop\VSProjects\VolleyballConnect\node_modules\firebase\index(.native|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx|.android.js|.native.js|.js|.android.jsx|.native.jsx|.jsx|.android.json|.native.json|.json)
4  * C:\Users\joshu\Desktop\VSProjects\VolleyballConnect\node_modules\firebase\index\index(.native|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx|.android.js|.native.js|.js|.android.jsx|.native.jsx|.jsx|.android.json|.native.json|.json)
5

My firebase config file:

1While trying to resolve module `firebase` from file `C:\Users\joshu\Desktop\VSProjects\VolleyballConnect\firebase.js`, the package `C:\Users\joshu\Desktop\VSProjects\VolleyballConnect\node_modules\firebase\package.json` was successfully found. However, this package itself specifies a `main` module field that could not be resolved (`C:\Users\joshu\Desktop\VSProjects\VolleyballConnect\node_modules\firebase\index`. Indeed, none of these files exist:
2
3  * C:\Users\joshu\Desktop\VSProjects\VolleyballConnect\node_modules\firebase\index(.native|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx|.android.js|.native.js|.js|.android.jsx|.native.jsx|.jsx|.android.json|.native.json|.json)
4  * C:\Users\joshu\Desktop\VSProjects\VolleyballConnect\node_modules\firebase\index\index(.native|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx|.android.js|.native.js|.js|.android.jsx|.native.jsx|.jsx|.android.json|.native.json|.json)
5import firebase from &quot;firebase&quot;;
6import { initializeApp } from &quot;firebase/app&quot;;
7import &quot;firebase/firestore&quot;;
8import &quot;firebase/auth&quot;;
9import &quot;firebase/storage&quot;;
10
11// I'm using the example key here, I have the correct config
12const firebaseConfig = {
13  apiKey: &quot;api-key&quot;,
14  authDomain: &quot;project-id.firebaseapp.com&quot;,
15  databaseURL: &quot;https://project-id.firebaseio.com&quot;,
16  projectId: &quot;project-id&quot;,
17  storageBucket: &quot;project-id.appspot.com&quot;,
18  messagingSenderId: &quot;sender-id&quot;,
19  appId: &quot;app-id&quot;,
20  measurementId: &quot;G-measurement-id&quot;,
21};
22
23if (firebase.apps.length === 0) {
24  initializeApp(firebaseConfig);
25}
26
27const db = firebase.firestore();
28const auth = firebase.auth();
29const storage = firebase.storage();
30
31export { db, auth, storage };
32

I installed the firebase package with:

1While trying to resolve module `firebase` from file `C:\Users\joshu\Desktop\VSProjects\VolleyballConnect\firebase.js`, the package `C:\Users\joshu\Desktop\VSProjects\VolleyballConnect\node_modules\firebase\package.json` was successfully found. However, this package itself specifies a `main` module field that could not be resolved (`C:\Users\joshu\Desktop\VSProjects\VolleyballConnect\node_modules\firebase\index`. Indeed, none of these files exist:
2
3  * C:\Users\joshu\Desktop\VSProjects\VolleyballConnect\node_modules\firebase\index(.native|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx|.android.js|.native.js|.js|.android.jsx|.native.jsx|.jsx|.android.json|.native.json|.json)
4  * C:\Users\joshu\Desktop\VSProjects\VolleyballConnect\node_modules\firebase\index\index(.native|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx|.android.js|.native.js|.js|.android.jsx|.native.jsx|.jsx|.android.json|.native.json|.json)
5import firebase from &quot;firebase&quot;;
6import { initializeApp } from &quot;firebase/app&quot;;
7import &quot;firebase/firestore&quot;;
8import &quot;firebase/auth&quot;;
9import &quot;firebase/storage&quot;;
10
11// I'm using the example key here, I have the correct config
12const firebaseConfig = {
13  apiKey: &quot;api-key&quot;,
14  authDomain: &quot;project-id.firebaseapp.com&quot;,
15  databaseURL: &quot;https://project-id.firebaseio.com&quot;,
16  projectId: &quot;project-id&quot;,
17  storageBucket: &quot;project-id.appspot.com&quot;,
18  messagingSenderId: &quot;sender-id&quot;,
19  appId: &quot;app-id&quot;,
20  measurementId: &quot;G-measurement-id&quot;,
21};
22
23if (firebase.apps.length === 0) {
24  initializeApp(firebaseConfig);
25}
26
27const db = firebase.firestore();
28const auth = firebase.auth();
29const storage = firebase.storage();
30
31export { db, auth, storage };
32expo install firebase
33

Any help would be greatly appreciated. Thank you!

ANSWER

Answered 2021-Nov-03 at 05:52

To reduce the size of the app, firebase SDK (v9.0.0) became modular. You can no longer do the import statement like before on v8.

You have two options.

  1. Use the backwards compatible way. (it will be later removed):

This:

1While trying to resolve module `firebase` from file `C:\Users\joshu\Desktop\VSProjects\VolleyballConnect\firebase.js`, the package `C:\Users\joshu\Desktop\VSProjects\VolleyballConnect\node_modules\firebase\package.json` was successfully found. However, this package itself specifies a `main` module field that could not be resolved (`C:\Users\joshu\Desktop\VSProjects\VolleyballConnect\node_modules\firebase\index`. Indeed, none of these files exist:
2
3  * C:\Users\joshu\Desktop\VSProjects\VolleyballConnect\node_modules\firebase\index(.native|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx|.android.js|.native.js|.js|.android.jsx|.native.jsx|.jsx|.android.json|.native.json|.json)
4  * C:\Users\joshu\Desktop\VSProjects\VolleyballConnect\node_modules\firebase\index\index(.native|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx|.android.js|.native.js|.js|.android.jsx|.native.jsx|.jsx|.android.json|.native.json|.json)
5import firebase from &quot;firebase&quot;;
6import { initializeApp } from &quot;firebase/app&quot;;
7import &quot;firebase/firestore&quot;;
8import &quot;firebase/auth&quot;;
9import &quot;firebase/storage&quot;;
10
11// I'm using the example key here, I have the correct config
12const firebaseConfig = {
13  apiKey: &quot;api-key&quot;,
14  authDomain: &quot;project-id.firebaseapp.com&quot;,
15  databaseURL: &quot;https://project-id.firebaseio.com&quot;,
16  projectId: &quot;project-id&quot;,
17  storageBucket: &quot;project-id.appspot.com&quot;,
18  messagingSenderId: &quot;sender-id&quot;,
19  appId: &quot;app-id&quot;,
20  measurementId: &quot;G-measurement-id&quot;,
21};
22
23if (firebase.apps.length === 0) {
24  initializeApp(firebaseConfig);
25}
26
27const db = firebase.firestore();
28const auth = firebase.auth();
29const storage = firebase.storage();
30
31export { db, auth, storage };
32expo install firebase
33import firebase from 'firebase/app';
34import 'firebase/auth';
35import 'firebase/firestore';
36

Should be changed to:

1While trying to resolve module `firebase` from file `C:\Users\joshu\Desktop\VSProjects\VolleyballConnect\firebase.js`, the package `C:\Users\joshu\Desktop\VSProjects\VolleyballConnect\node_modules\firebase\package.json` was successfully found. However, this package itself specifies a `main` module field that could not be resolved (`C:\Users\joshu\Desktop\VSProjects\VolleyballConnect\node_modules\firebase\index`. Indeed, none of these files exist:
2
3  * C:\Users\joshu\Desktop\VSProjects\VolleyballConnect\node_modules\firebase\index(.native|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx|.android.js|.native.js|.js|.android.jsx|.native.jsx|.jsx|.android.json|.native.json|.json)
4  * C:\Users\joshu\Desktop\VSProjects\VolleyballConnect\node_modules\firebase\index\index(.native|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx|.android.js|.native.js|.js|.android.jsx|.native.jsx|.jsx|.android.json|.native.json|.json)
5import firebase from &quot;firebase&quot;;
6import { initializeApp } from &quot;firebase/app&quot;;
7import &quot;firebase/firestore&quot;;
8import &quot;firebase/auth&quot;;
9import &quot;firebase/storage&quot;;
10
11// I'm using the example key here, I have the correct config
12const firebaseConfig = {
13  apiKey: &quot;api-key&quot;,
14  authDomain: &quot;project-id.firebaseapp.com&quot;,
15  databaseURL: &quot;https://project-id.firebaseio.com&quot;,
16  projectId: &quot;project-id&quot;,
17  storageBucket: &quot;project-id.appspot.com&quot;,
18  messagingSenderId: &quot;sender-id&quot;,
19  appId: &quot;app-id&quot;,
20  measurementId: &quot;G-measurement-id&quot;,
21};
22
23if (firebase.apps.length === 0) {
24  initializeApp(firebaseConfig);
25}
26
27const db = firebase.firestore();
28const auth = firebase.auth();
29const storage = firebase.storage();
30
31export { db, auth, storage };
32expo install firebase
33import firebase from 'firebase/app';
34import 'firebase/auth';
35import 'firebase/firestore';
36// v9 compat packages are API compatible with v8 code
37import firebase from 'firebase/compat/app';
38import 'firebase/compat/auth';
39import 'firebase/compat/firestore';
40
  1. Refactor your code now.

From this:

1While trying to resolve module `firebase` from file `C:\Users\joshu\Desktop\VSProjects\VolleyballConnect\firebase.js`, the package `C:\Users\joshu\Desktop\VSProjects\VolleyballConnect\node_modules\firebase\package.json` was successfully found. However, this package itself specifies a `main` module field that could not be resolved (`C:\Users\joshu\Desktop\VSProjects\VolleyballConnect\node_modules\firebase\index`. Indeed, none of these files exist:
2
3  * C:\Users\joshu\Desktop\VSProjects\VolleyballConnect\node_modules\firebase\index(.native|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx|.android.js|.native.js|.js|.android.jsx|.native.jsx|.jsx|.android.json|.native.json|.json)
4  * C:\Users\joshu\Desktop\VSProjects\VolleyballConnect\node_modules\firebase\index\index(.native|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx|.android.js|.native.js|.js|.android.jsx|.native.jsx|.jsx|.android.json|.native.json|.json)
5import firebase from &quot;firebase&quot;;
6import { initializeApp } from &quot;firebase/app&quot;;
7import &quot;firebase/firestore&quot;;
8import &quot;firebase/auth&quot;;
9import &quot;firebase/storage&quot;;
10
11// I'm using the example key here, I have the correct config
12const firebaseConfig = {
13  apiKey: &quot;api-key&quot;,
14  authDomain: &quot;project-id.firebaseapp.com&quot;,
15  databaseURL: &quot;https://project-id.firebaseio.com&quot;,
16  projectId: &quot;project-id&quot;,
17  storageBucket: &quot;project-id.appspot.com&quot;,
18  messagingSenderId: &quot;sender-id&quot;,
19  appId: &quot;app-id&quot;,
20  measurementId: &quot;G-measurement-id&quot;,
21};
22
23if (firebase.apps.length === 0) {
24  initializeApp(firebaseConfig);
25}
26
27const db = firebase.firestore();
28const auth = firebase.auth();
29const storage = firebase.storage();
30
31export { db, auth, storage };
32expo install firebase
33import firebase from 'firebase/app';
34import 'firebase/auth';
35import 'firebase/firestore';
36// v9 compat packages are API compatible with v8 code
37import firebase from 'firebase/compat/app';
38import 'firebase/compat/auth';
39import 'firebase/compat/firestore';
40import firebase from &quot;firebase/compat/app&quot;;
41import &quot;firebase/compat/auth&quot;;
42
43const auth = firebase.auth();
44auth.onAuthStateChanged(user =&gt; { 
45  // Check for user status
46});
47

To this:

1While trying to resolve module `firebase` from file `C:\Users\joshu\Desktop\VSProjects\VolleyballConnect\firebase.js`, the package `C:\Users\joshu\Desktop\VSProjects\VolleyballConnect\node_modules\firebase\package.json` was successfully found. However, this package itself specifies a `main` module field that could not be resolved (`C:\Users\joshu\Desktop\VSProjects\VolleyballConnect\node_modules\firebase\index`. Indeed, none of these files exist:
2
3  * C:\Users\joshu\Desktop\VSProjects\VolleyballConnect\node_modules\firebase\index(.native|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx|.android.js|.native.js|.js|.android.jsx|.native.jsx|.jsx|.android.json|.native.json|.json)
4  * C:\Users\joshu\Desktop\VSProjects\VolleyballConnect\node_modules\firebase\index\index(.native|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx|.android.js|.native.js|.js|.android.jsx|.native.jsx|.jsx|.android.json|.native.json|.json)
5import firebase from &quot;firebase&quot;;
6import { initializeApp } from &quot;firebase/app&quot;;
7import &quot;firebase/firestore&quot;;
8import &quot;firebase/auth&quot;;
9import &quot;firebase/storage&quot;;
10
11// I'm using the example key here, I have the correct config
12const firebaseConfig = {
13  apiKey: &quot;api-key&quot;,
14  authDomain: &quot;project-id.firebaseapp.com&quot;,
15  databaseURL: &quot;https://project-id.firebaseio.com&quot;,
16  projectId: &quot;project-id&quot;,
17  storageBucket: &quot;project-id.appspot.com&quot;,
18  messagingSenderId: &quot;sender-id&quot;,
19  appId: &quot;app-id&quot;,
20  measurementId: &quot;G-measurement-id&quot;,
21};
22
23if (firebase.apps.length === 0) {
24  initializeApp(firebaseConfig);
25}
26
27const db = firebase.firestore();
28const auth = firebase.auth();
29const storage = firebase.storage();
30
31export { db, auth, storage };
32expo install firebase
33import firebase from 'firebase/app';
34import 'firebase/auth';
35import 'firebase/firestore';
36// v9 compat packages are API compatible with v8 code
37import firebase from 'firebase/compat/app';
38import 'firebase/compat/auth';
39import 'firebase/compat/firestore';
40import firebase from &quot;firebase/compat/app&quot;;
41import &quot;firebase/compat/auth&quot;;
42
43const auth = firebase.auth();
44auth.onAuthStateChanged(user =&gt; { 
45  // Check for user status
46});
47import { getAuth, onAuthStateChanged } from &quot;firebase/auth&quot;;
48
49const auth = getAuth(firebaseApp);
50onAuthStateChanged(auth, user =&gt; {
51  // Check for user status
52});
53

You should definitely check the documentation

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

QUESTION

After upgrading from Angular 12 to 13, cache is too large for Github

Asked 2022-Mar-28 at 18:10

I recently upgraded all of my dependencies in package.json to the latest. I went from Angular 12.2.0 to 13.0.1 and github is now rejecting my push with the following file size error. Is there some setting I need to define in angular.json build profile that will help minimize these cache file sizes?

1remote: warning: File .angular/cache/angular-webpack/72163742903fc8ba00e684045de261c2e3a2fb86/3.pack is 54.01 MB; this is larger than GitHub's recommended maximum file size of 50.00 MB
2remote: warning: File .angular/cache/angular-webpack/72163742903fc8ba00e684045de261c2e3a2fb86/2.pack is 56.42 MB; this is larger than GitHub's recommended maximum file size of 50.00 MB
3remote: error: Trace: 0b9557fffbe30aac33f6d9858ef97559341c5c1614ace35524fcba85ac99ca76
4remote: error: See http://git.io/iEPt8g for more information.
5remote: error: File .angular/cache/angular-webpack/72163742903fc8ba00e684045de261c2e3a2fb86/3.pack is 122.06 MB; this exceeds GitHub's file size limit of 100.00 MB
6remote: error: File .angular/cache/angular-webpack/72163742903fc8ba00e684045de261c2e3a2fb86/5.pack is 123.92 MB; this exceeds GitHub's file size limit of 100.00 MB
7remote: error: File .angular/cache/angular-webpack/f48e9bc724ec0d5ae9a9d2fed858970d0a503f10/0.pack is 154.05 MB; this exceeds GitHub's file size limit of 100.00 MB
8remote: error: File .angular/cache/angular-webpack/9327900b3187f0b6351b4801d208e7b58f1af17e/0.pack is 165.50 MB; this exceeds GitHub's file size limit of 100.00 MB
9remote: error: File .angular/cache/angular-webpack/663bcd30d50863949acf1c25f02b95cab85c248a/0.pack is 151.56 MB; this exceeds GitHub's file size limit of 100.00 MB
10remote: error: File .angular/cache/angular-webpack/663bcd30d50863949acf1c25f02b95cab85c248a/0.pack is 151.55 MB; this exceeds GitHub's file size limit of 100.00 MB
11remote: error: GH001: Large files detected. You may want to try Git Large File Storage - https://git-lfs.github.com.
12

Edit:

  1. I created this repo with Angular cli and have been maintaining and updating through many versions of Angular and had no issue until this latest update.

  2. The .gitignore file is in the root of the application and matches the suggested example: enter image description here

  3. When adding /.angular/cache to the gitignore file, I run git rm -rf --cached . && git add . && git commit -m 'fix(gitignore): add angular cache' && git push --set-upstream origin chore/bump-deps but still get the file size error.

ANSWER

Answered 2021-Nov-24 at 16:53

Make sure your .gitignore is in the parent folder of .angular.
In that .gitignore file, a simple .angular/cache/ should be enough to ignore that subfolder content.

Check it with:

1remote: warning: File .angular/cache/angular-webpack/72163742903fc8ba00e684045de261c2e3a2fb86/3.pack is 54.01 MB; this is larger than GitHub's recommended maximum file size of 50.00 MB
2remote: warning: File .angular/cache/angular-webpack/72163742903fc8ba00e684045de261c2e3a2fb86/2.pack is 56.42 MB; this is larger than GitHub's recommended maximum file size of 50.00 MB
3remote: error: Trace: 0b9557fffbe30aac33f6d9858ef97559341c5c1614ace35524fcba85ac99ca76
4remote: error: See http://git.io/iEPt8g for more information.
5remote: error: File .angular/cache/angular-webpack/72163742903fc8ba00e684045de261c2e3a2fb86/3.pack is 122.06 MB; this exceeds GitHub's file size limit of 100.00 MB
6remote: error: File .angular/cache/angular-webpack/72163742903fc8ba00e684045de261c2e3a2fb86/5.pack is 123.92 MB; this exceeds GitHub's file size limit of 100.00 MB
7remote: error: File .angular/cache/angular-webpack/f48e9bc724ec0d5ae9a9d2fed858970d0a503f10/0.pack is 154.05 MB; this exceeds GitHub's file size limit of 100.00 MB
8remote: error: File .angular/cache/angular-webpack/9327900b3187f0b6351b4801d208e7b58f1af17e/0.pack is 165.50 MB; this exceeds GitHub's file size limit of 100.00 MB
9remote: error: File .angular/cache/angular-webpack/663bcd30d50863949acf1c25f02b95cab85c248a/0.pack is 151.56 MB; this exceeds GitHub's file size limit of 100.00 MB
10remote: error: File .angular/cache/angular-webpack/663bcd30d50863949acf1c25f02b95cab85c248a/0.pack is 151.55 MB; this exceeds GitHub's file size limit of 100.00 MB
11remote: error: GH001: Large files detected. You may want to try Git Large File Storage - https://git-lfs.github.com.
12git check-ignore -v -- .angular/cache/angular-webpack/72163742903fc8ba00e684045de261c2e3a2fb86/2.pack
13

You can see an example in ganatan/angular-starter/.gitignore (from an Angular 13 Example Starter project), where /.angular/cache/ is used, to anchor the rule to the top folder of the repository.

The OP S. Taylor confirms in the comments:

I'm pretty sure that was my issue.
I abandoned the dev branch and updated my dependencies without using the compound commands like git add . && git commit -m 'fix(gitignore): add angular cache'.
Making sure to note what was staged.

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

QUESTION

android:exported added but still getting error Apps targeting Android 12 and higher are required to specify an explicit value for android:exported

Asked 2022-Mar-24 at 15:30

I have added android:exported="true" to my only activity in manifest but still getting below error after updating compile sdk and target sdk version to 31.I also tried rebuilding the project , invalidating cache and restart but that didn't helped

Error- 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.

AndroidManifest File
1&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
2&lt;manifest xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
3    package=&quot;com.xyz.abc&quot;&gt;
4
5    &lt;uses-permission android:name=&quot;android.permission.WRITE_EXTERNAL_STORAGE&quot; /&gt;
6    &lt;uses-permission android:name=&quot;android.permission.READ_EXTERNAL_STORAGE&quot; /&gt;
7
8    &lt;application
9        android:name=&quot;.framework.presentation.BaseApplication&quot;
10        android:allowBackup=&quot;true&quot;
11        android:icon=&quot;@mipmap/ic_launcher&quot;
12        android:label=&quot;@string/app_name&quot;
13        android:roundIcon=&quot;@mipmap/ic_launcher_round&quot;
14        android:supportsRtl=&quot;true&quot;
15        android:theme=&quot;@style/AppTheme&quot;&gt;
16        &lt;activity android:name=&quot;com.xyz.presentation.MainActivity&quot;
17            android:exported=&quot;true&quot;&gt;
18            &lt;intent-filter&gt;
19                &lt;action android:name=&quot;android.intent.action.MAIN&quot; /&gt;
20
21                &lt;category android:name=&quot;android.intent.category.LAUNCHER&quot; /&gt;
22            &lt;/intent-filter&gt;
23        &lt;/activity&gt;
24    &lt;/application&gt;
25
26&lt;/manifest&gt;
27
Merged manifest error

Other Manifest Files (Included in merge, but did not contribute any elements) firebase-installations:17.0.0 manifest, versionedparcelable:1.1.1 manifest, runtime:1.0.1 manifest, test:core:1.2.0 manifest, loader:1.0.0 manifest, facebook-share:11.1.0 manifest, leakcanary:leaksentry:2.0-alpha-3 manifest, material-dialogs:input:3.2.1 manifest, material-icons-extended:1.0.0 manifest, play-services-stats:17.0.0 manifest, interpolator:1.0.0 manifest, activity-compose:1.3.1 manifest, material-ripple:1.0.0 manifest, foundation:1.0.0 manifest, asynclayoutinflater:1.0.0 manifest, savedstate-ktx:1.1.0 manifest, navigation-dynamic-features-fragment:2.3.5 manifest, firebase-ui-auth:7.2.0 manifest, animation:1.0.1 manifest, animation-core:1.0.1 manifest, installreferrer:1.0 manifest, firebase-crashlytics:18.0.0 manifest, ui:1.0.1 manifest, lifecycle-viewmodel-savedstate:2.3.1 manifest, play-services-auth-base:17.0.0 manifest, hilt-android:2.35.1 manifest, material-dialogs:core:3.2.1 manifest, AndroidManifest.xml navigation file, savedstate:1.1.0 manifest, cursoradapter:1.0.0 manifest, sqlite-framework:2.0.1 manifest, room-ktx:2.1.0 manifest, leakcanary-android-core:2.0-alpha-3 manifest, AndroidManifest.xml navigation file, media:1.0.0 manifest, coordinatorlayout:1.1.0 manifest, legacy-support-core-utils:1.0.0 manifest, lifecycle-runtime:2.3.1 manifest, coil-kt:coil:1.3.1 manifest, ui-tooling-preview:1.0.0 manifest, facebook-core:11.1.0 manifest, core:1.6.0 manifest, material:1.0.0 manifest, firebase-common:20.0.0 manifest, documentfile:1.0.0 manifest, lifecycle-viewmodel-compose:2.4.0-beta01 manifest, play-services-base:17.1.0 manifest, ui-tooling-data:1.0.0 manifest, coil-base:1.3.1 manifest, firebase-analytics-ktx:19.0.0 manifest, localbroadcastmanager:1.0.0 manifest, swiperefreshlayout:1.1.0-alpha03 manifest, constraintlayout-compose:1.0.0-beta02 manifest, core-ktx:1.6.0 manifest, firebase-database-collection:18.0.0 manifest, coil-compose-base:1.3.1 manifest, activity:1.3.1 manifest, AndroidManifest.xml navigation file, facebook-messenger:11.1.0 manifest, print:1.0.0 manifest, customview:1.1.0 manifest, material-icons-core:1.0.0 manifest, play-services-measurement-sdk:19.0.0 manifest, fragment:1.3.4 manifest, firebase-appcheck-interop:16.0.0-beta01 manifest, facebook-login:11.1.0 manifest, cardview:1.0.0 manifest, runtime-rxjava2:1.0.0 manifest, viewpager2:1.0.0 manifest, play-services-ads-identifier:17.0.0 manifest, play-services-measurement-impl:19.0.0 manifest, lifecycle-livedata-core:2.3.1 manifest, play-services-safetynet:17.0.0 manifest, AndroidManifest.xml navigation file, lifecycle-viewmodel-ktx:2.3.1 manifest, transport-backend-cct:3.0.0 manifest, fragment-ktx:1.2.4 manifest, appcompat:1.3.0 manifest, transport-runtime:3.0.0 manifest, lifecycle-livedata-core-ktx:2.2.0 manifest, firebase-firestore-ktx:23.0.0 manifest, legacy-support-v4:1.0.0 manifest, play-services-basement:17.1.1 manifest, firebase-storage:20.0.0 manifest, play-services-auth-api-phone:17.4.0 manifest, leakcanary-android:2.0-alpha-3 manifest, firebase-auth-interop:20.0.0 manifest, lifecycle-viewmodel:2.3.1 manifest, browser:1.0.0 manifest, firebase-auth:21.0.1 manifest, material:1.2.1 manifest, slidingpanelayout:1.0.0 manifest, vectordrawable:1.1.0 manifest, recyclerview:1.1.0 manifest, play-services-auth:19.0.0 manifest, room-runtime:2.1.0 manifest, dagger-lint-aar:2.35.1 manifest, navigation-dynamic-features-runtime:2.3.5 manifest, play-services-measurement-api:19.0.0 manifest, firebase-encoders-json:18.0.0 manifest, sqlite:2.0.1 manifest, facebook-android-sdk:11.1.0 manifest, firebase-components:17.0.0 manifest, transport-api:3.0.0 manifest, protolite-well-known-types:18.0.0 manifest, markdown-processor:0.1.3 manifest, play-services-measurement-base:19.0.0 manifest, firebase-common-ktx:20.0.0 manifest, activity-ktx:1.3.1 manifest, firebase-crashlytics-ktx:18.0.0 manifest, coil-compose:1.3.1 manifest, multidex:2.0.1 manifest, core-runtime:2.1.0 manifest, fragment-testing:1.2.0 manifest, ui-graphics:1.0.1 manifest, AndroidManifest.xml navigation file, ui-tooling:1.0.0 manifest, grpc-android:1.28.0 manifest, ui-unit:1.0.1 manifest, play-services-measurement:19.0.0 manifest, play:core:1.9.1 manifest, annotation-experimental:1.1.0 manifest, play-services-measurement-sdk-api:19.0.0 manifest, play-services-tasks:17.0.0 manifest, firebase-analytics:19.0.0 manifest, facebook-common:11.1.0 manifest, drawerlayout:1.1.1 manifest, AndroidManifest.xml navigation file, navigation-compose:2.4.0-alpha09 manifest, facebook-gamingservices:11.1.0 manifest, firebase-firestore:23.0.0 manifest, lifecycle-livedata:2.2.0 manifest, legacy-support-core-ui:1.0.0 manifest, test:monitor:1.2.0 manifest, AndroidManifest.xml navigation file, facebook-applinks:11.1.0 manifest, viewpager:1.0.0 manifest, ui-geometry:1.0.1 manifest, lifecycle-runtime-ktx:2.3.1 manifest, constraintlayout:2.0.4 manifest, ui-text:1.0.1 manifest, AndroidManifest.xml navigation file, firebase-installations-interop:17.0.0 manifest, transition:1.3.0 manifest, foundation-layout:1.0.1 manifest, appcompat-resources:1.3.1 manifest, runtime-livedata:1.0.0 manifest, runtime-saveable:1.0.1 manifest, firebase-measurement-connector:19.0.0 manifest, vectordrawable-animated:1.1.0 manifest, main nav_graph.xml navigation file 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. Dairy.app main manifest (this file) 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. Dairy.app main manifest (this file) 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. Dairy.app main manifest (this file)

ANSWER

Answered 2021-Oct-05 at 10:38

After the build has failed go to AndroidManifest.xml and in the bottom click merged manifest see which activities which have intent-filter but don't have exported=true attribute. Or you can just get the activities which are giving error.

Add these activities to your App manifest with android:exported="true" and app tools:node="merge" this will add exported attribute to the activities giving error.

Example:

1&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
2&lt;manifest xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
3    package=&quot;com.xyz.abc&quot;&gt;
4
5    &lt;uses-permission android:name=&quot;android.permission.WRITE_EXTERNAL_STORAGE&quot; /&gt;
6    &lt;uses-permission android:name=&quot;android.permission.READ_EXTERNAL_STORAGE&quot; /&gt;
7
8    &lt;application
9        android:name=&quot;.framework.presentation.BaseApplication&quot;
10        android:allowBackup=&quot;true&quot;
11        android:icon=&quot;@mipmap/ic_launcher&quot;
12        android:label=&quot;@string/app_name&quot;
13        android:roundIcon=&quot;@mipmap/ic_launcher_round&quot;
14        android:supportsRtl=&quot;true&quot;
15        android:theme=&quot;@style/AppTheme&quot;&gt;
16        &lt;activity android:name=&quot;com.xyz.presentation.MainActivity&quot;
17            android:exported=&quot;true&quot;&gt;
18            &lt;intent-filter&gt;
19                &lt;action android:name=&quot;android.intent.action.MAIN&quot; /&gt;
20
21                &lt;category android:name=&quot;android.intent.category.LAUNCHER&quot; /&gt;
22            &lt;/intent-filter&gt;
23        &lt;/activity&gt;
24    &lt;/application&gt;
25
26&lt;/manifest&gt;
27      &lt;activity
28            android:name=&quot;&lt;activity which is giving error&gt;&quot;
29            android:exported=&quot;true&quot;
30            tools:node=&quot;merge&quot; /&gt;
31

You will have to do this once, you can remove this once the library developers update their libs.

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

QUESTION

How to fix: &quot;@angular/fire&quot;' has no exported member 'AngularFireModule'.ts(2305) ionic, firebase, angular

Asked 2022-Feb-11 at 07:31

I'm trying to connect my app with a firebase db, but I receive 4 error messages on app.module.ts:

1'&quot;@angular/fire&quot;' has no exported member 'AngularFireModule'.ts(2305),
2'&quot;@angular/fire/storage&quot;' has no exported member 'AngularFireStorageModule'.ts(2305)
3'&quot;@angular/fire/database&quot;' has no exported member 'AngularFireDatabaseModule'.ts(2305)
4'&quot;@angular/fire/auth&quot;' has no exported member 'AngularFireAuthModule'.ts(2305)
5

here is my package.json file:

1'&quot;@angular/fire&quot;' has no exported member 'AngularFireModule'.ts(2305),
2'&quot;@angular/fire/storage&quot;' has no exported member 'AngularFireStorageModule'.ts(2305)
3'&quot;@angular/fire/database&quot;' has no exported member 'AngularFireDatabaseModule'.ts(2305)
4'&quot;@angular/fire/auth&quot;' has no exported member 'AngularFireAuthModule'.ts(2305)
5{
6  &quot;name&quot;: &quot;gescable&quot;,
7  &quot;version&quot;: &quot;0.0.1&quot;,
8  &quot;author&quot;: &quot;Ionic Framework&quot;,
9  &quot;homepage&quot;: &quot;https://ionicframework.com/&quot;,
10  &quot;scripts&quot;: {
11    &quot;ng&quot;: &quot;ng&quot;,
12    &quot;start&quot;: &quot;ng serve&quot;,
13    &quot;build&quot;: &quot;ng build&quot;,
14    &quot;test&quot;: &quot;ng test&quot;,
15    &quot;lint&quot;: &quot;ng lint&quot;,
16    &quot;e2e&quot;: &quot;ng e2e&quot;
17  },
18  &quot;private&quot;: true,
19  &quot;dependencies&quot;: {
20    &quot;@angular-devkit/architect&quot;: &quot;^0.1202.5&quot;,
21    &quot;@angular-devkit/architect-cli&quot;: &quot;^0.1202.5&quot;,
22    &quot;@angular/common&quot;: &quot;~12.1.1&quot;,
23    &quot;@angular/core&quot;: &quot;~12.1.1&quot;,
24    &quot;@angular/fire&quot;: &quot;^7.0.4&quot;,
25    &quot;@angular/forms&quot;: &quot;~12.1.1&quot;,
26    &quot;@angular/platform-browser&quot;: &quot;~12.1.1&quot;,
27    &quot;@angular/platform-browser-dynamic&quot;: &quot;~12.1.1&quot;,
28    &quot;@angular/router&quot;: &quot;~12.1.1&quot;,
29    &quot;@ionic/angular&quot;: &quot;^5.5.2&quot;,
30    &quot;ajv&quot;: &quot;^8.6.2&quot;,
31    &quot;angularfire2&quot;: &quot;^5.4.2&quot;,
32    &quot;firebase&quot;: &quot;^7.24.0&quot;,
33    &quot;rxfire&quot;: &quot;^6.0.0&quot;,
34    &quot;rxjs&quot;: &quot;~6.6.0&quot;,
35    &quot;tslib&quot;: &quot;^2.2.0&quot;,
36    &quot;zone.js&quot;: &quot;~0.11.4&quot;
37  },
38  &quot;devDependencies&quot;: {
39    &quot;@angular-devkit/build-angular&quot;: &quot;~12.1.1&quot;,
40    &quot;@angular-eslint/builder&quot;: &quot;~12.0.0&quot;,
41    &quot;@angular-eslint/eslint-plugin&quot;: &quot;~12.0.0&quot;,
42    &quot;@angular-eslint/eslint-plugin-template&quot;: &quot;~12.0.0&quot;,
43    &quot;@angular-eslint/template-parser&quot;: &quot;~12.0.0&quot;,
44    &quot;@angular/cli&quot;: &quot;~12.1.1&quot;,
45    &quot;@angular/compiler&quot;: &quot;~12.1.1&quot;,
46    &quot;@angular/compiler-cli&quot;: &quot;~12.1.1&quot;,
47    &quot;@angular/language-service&quot;: &quot;~12.0.1&quot;,
48    &quot;@ionic/angular-toolkit&quot;: &quot;^4.0.0&quot;,
49    &quot;@types/jasmine&quot;: &quot;~3.6.0&quot;,
50    &quot;@types/jasminewd2&quot;: &quot;~2.0.3&quot;,
51    &quot;@types/node&quot;: &quot;^12.11.1&quot;,
52    &quot;@typescript-eslint/eslint-plugin&quot;: &quot;4.16.1&quot;,
53    &quot;@typescript-eslint/parser&quot;: &quot;4.16.1&quot;,
54    &quot;eslint&quot;: &quot;^7.6.0&quot;,
55    &quot;eslint-plugin-import&quot;: &quot;2.22.1&quot;,
56    &quot;eslint-plugin-jsdoc&quot;: &quot;30.7.6&quot;,
57    &quot;eslint-plugin-prefer-arrow&quot;: &quot;1.2.2&quot;,
58    &quot;jasmine-core&quot;: &quot;~3.8.0&quot;,
59    &quot;jasmine-spec-reporter&quot;: &quot;~5.0.0&quot;,
60    &quot;karma&quot;: &quot;~6.3.2&quot;,
61    &quot;karma-chrome-launcher&quot;: &quot;~3.1.0&quot;,
62    &quot;karma-coverage&quot;: &quot;~2.0.3&quot;,
63    &quot;karma-coverage-istanbul-reporter&quot;: &quot;~3.0.2&quot;,
64    &quot;karma-jasmine&quot;: &quot;~4.0.0&quot;,
65    &quot;karma-jasmine-html-reporter&quot;: &quot;^1.5.0&quot;,
66    &quot;protractor&quot;: &quot;~7.0.0&quot;,
67    &quot;ts-node&quot;: &quot;~8.3.0&quot;,
68    &quot;typescript&quot;: &quot;~4.2.4&quot;,
69    &quot;@angular-devkit/architect&quot;: &quot;^0.1200.0&quot;,
70    &quot;firebase-tools&quot;: &quot;^9.0.0&quot;,
71    &quot;fuzzy&quot;: &quot;^0.1.3&quot;,
72    &quot;inquirer&quot;: &quot;^6.2.2&quot;,
73    &quot;inquirer-autocomplete-prompt&quot;: &quot;^1.0.1&quot;,
74    &quot;open&quot;: &quot;^7.0.3&quot;,
75    &quot;jsonc-parser&quot;: &quot;^3.0.0&quot;
76  },
77  &quot;description&quot;: &quot;An Ionic project&quot;
78}
79

And here is my app.module.ts:

1'&quot;@angular/fire&quot;' has no exported member 'AngularFireModule'.ts(2305),
2'&quot;@angular/fire/storage&quot;' has no exported member 'AngularFireStorageModule'.ts(2305)
3'&quot;@angular/fire/database&quot;' has no exported member 'AngularFireDatabaseModule'.ts(2305)
4'&quot;@angular/fire/auth&quot;' has no exported member 'AngularFireAuthModule'.ts(2305)
5{
6  &quot;name&quot;: &quot;gescable&quot;,
7  &quot;version&quot;: &quot;0.0.1&quot;,
8  &quot;author&quot;: &quot;Ionic Framework&quot;,
9  &quot;homepage&quot;: &quot;https://ionicframework.com/&quot;,
10  &quot;scripts&quot;: {
11    &quot;ng&quot;: &quot;ng&quot;,
12    &quot;start&quot;: &quot;ng serve&quot;,
13    &quot;build&quot;: &quot;ng build&quot;,
14    &quot;test&quot;: &quot;ng test&quot;,
15    &quot;lint&quot;: &quot;ng lint&quot;,
16    &quot;e2e&quot;: &quot;ng e2e&quot;
17  },
18  &quot;private&quot;: true,
19  &quot;dependencies&quot;: {
20    &quot;@angular-devkit/architect&quot;: &quot;^0.1202.5&quot;,
21    &quot;@angular-devkit/architect-cli&quot;: &quot;^0.1202.5&quot;,
22    &quot;@angular/common&quot;: &quot;~12.1.1&quot;,
23    &quot;@angular/core&quot;: &quot;~12.1.1&quot;,
24    &quot;@angular/fire&quot;: &quot;^7.0.4&quot;,
25    &quot;@angular/forms&quot;: &quot;~12.1.1&quot;,
26    &quot;@angular/platform-browser&quot;: &quot;~12.1.1&quot;,
27    &quot;@angular/platform-browser-dynamic&quot;: &quot;~12.1.1&quot;,
28    &quot;@angular/router&quot;: &quot;~12.1.1&quot;,
29    &quot;@ionic/angular&quot;: &quot;^5.5.2&quot;,
30    &quot;ajv&quot;: &quot;^8.6.2&quot;,
31    &quot;angularfire2&quot;: &quot;^5.4.2&quot;,
32    &quot;firebase&quot;: &quot;^7.24.0&quot;,
33    &quot;rxfire&quot;: &quot;^6.0.0&quot;,
34    &quot;rxjs&quot;: &quot;~6.6.0&quot;,
35    &quot;tslib&quot;: &quot;^2.2.0&quot;,
36    &quot;zone.js&quot;: &quot;~0.11.4&quot;
37  },
38  &quot;devDependencies&quot;: {
39    &quot;@angular-devkit/build-angular&quot;: &quot;~12.1.1&quot;,
40    &quot;@angular-eslint/builder&quot;: &quot;~12.0.0&quot;,
41    &quot;@angular-eslint/eslint-plugin&quot;: &quot;~12.0.0&quot;,
42    &quot;@angular-eslint/eslint-plugin-template&quot;: &quot;~12.0.0&quot;,
43    &quot;@angular-eslint/template-parser&quot;: &quot;~12.0.0&quot;,
44    &quot;@angular/cli&quot;: &quot;~12.1.1&quot;,
45    &quot;@angular/compiler&quot;: &quot;~12.1.1&quot;,
46    &quot;@angular/compiler-cli&quot;: &quot;~12.1.1&quot;,
47    &quot;@angular/language-service&quot;: &quot;~12.0.1&quot;,
48    &quot;@ionic/angular-toolkit&quot;: &quot;^4.0.0&quot;,
49    &quot;@types/jasmine&quot;: &quot;~3.6.0&quot;,
50    &quot;@types/jasminewd2&quot;: &quot;~2.0.3&quot;,
51    &quot;@types/node&quot;: &quot;^12.11.1&quot;,
52    &quot;@typescript-eslint/eslint-plugin&quot;: &quot;4.16.1&quot;,
53    &quot;@typescript-eslint/parser&quot;: &quot;4.16.1&quot;,
54    &quot;eslint&quot;: &quot;^7.6.0&quot;,
55    &quot;eslint-plugin-import&quot;: &quot;2.22.1&quot;,
56    &quot;eslint-plugin-jsdoc&quot;: &quot;30.7.6&quot;,
57    &quot;eslint-plugin-prefer-arrow&quot;: &quot;1.2.2&quot;,
58    &quot;jasmine-core&quot;: &quot;~3.8.0&quot;,
59    &quot;jasmine-spec-reporter&quot;: &quot;~5.0.0&quot;,
60    &quot;karma&quot;: &quot;~6.3.2&quot;,
61    &quot;karma-chrome-launcher&quot;: &quot;~3.1.0&quot;,
62    &quot;karma-coverage&quot;: &quot;~2.0.3&quot;,
63    &quot;karma-coverage-istanbul-reporter&quot;: &quot;~3.0.2&quot;,
64    &quot;karma-jasmine&quot;: &quot;~4.0.0&quot;,
65    &quot;karma-jasmine-html-reporter&quot;: &quot;^1.5.0&quot;,
66    &quot;protractor&quot;: &quot;~7.0.0&quot;,
67    &quot;ts-node&quot;: &quot;~8.3.0&quot;,
68    &quot;typescript&quot;: &quot;~4.2.4&quot;,
69    &quot;@angular-devkit/architect&quot;: &quot;^0.1200.0&quot;,
70    &quot;firebase-tools&quot;: &quot;^9.0.0&quot;,
71    &quot;fuzzy&quot;: &quot;^0.1.3&quot;,
72    &quot;inquirer&quot;: &quot;^6.2.2&quot;,
73    &quot;inquirer-autocomplete-prompt&quot;: &quot;^1.0.1&quot;,
74    &quot;open&quot;: &quot;^7.0.3&quot;,
75    &quot;jsonc-parser&quot;: &quot;^3.0.0&quot;
76  },
77  &quot;description&quot;: &quot;An Ionic project&quot;
78}
79import { NgModule } from '@angular/core';
80import { BrowserModule } from '@angular/platform-browser';
81import { RouteReuseStrategy } from '@angular/router';
82import { IonicModule, IonicRouteStrategy } from '@ionic/angular';
83import { AppRoutingModule } from './app-routing.module';
84import { AppComponent } from './app.component';
85import { ClientPageModule } from './client/client.module';
86import { environment } from '../environments/environment';
87import { AngularFireModule } from '@angular/fire';
88import { AngularFireAuthModule } from '@angular/fire/auth';
89import { AngularFireStorageModule } from '@angular/fire/storage';
90import { AngularFireDatabaseModule } from '@angular/fire/database';
91
92@NgModule({
93  declarations: [AppComponent],
94  entryComponents: [],
95  imports: [
96    BrowserModule,
97    IonicModule.forRoot(),
98    AppRoutingModule,
99    ClientPageModule,
100    AngularFireModule.initializeApp(environment.firebaseConfig),
101    AngularFireAuthModule,
102    AngularFireStorageModule,
103    AngularFireDatabaseModule
104  ],
105  providers: [{ provide: RouteReuseStrategy, useClass: IonicRouteStrategy }],
106  bootstrap: [AppComponent],
107})
108export class AppModule {}
109

Here is my tsonfig.ts file

1'&quot;@angular/fire&quot;' has no exported member 'AngularFireModule'.ts(2305),
2'&quot;@angular/fire/storage&quot;' has no exported member 'AngularFireStorageModule'.ts(2305)
3'&quot;@angular/fire/database&quot;' has no exported member 'AngularFireDatabaseModule'.ts(2305)
4'&quot;@angular/fire/auth&quot;' has no exported member 'AngularFireAuthModule'.ts(2305)
5{
6  &quot;name&quot;: &quot;gescable&quot;,
7  &quot;version&quot;: &quot;0.0.1&quot;,
8  &quot;author&quot;: &quot;Ionic Framework&quot;,
9  &quot;homepage&quot;: &quot;https://ionicframework.com/&quot;,
10  &quot;scripts&quot;: {
11    &quot;ng&quot;: &quot;ng&quot;,
12    &quot;start&quot;: &quot;ng serve&quot;,
13    &quot;build&quot;: &quot;ng build&quot;,
14    &quot;test&quot;: &quot;ng test&quot;,
15    &quot;lint&quot;: &quot;ng lint&quot;,
16    &quot;e2e&quot;: &quot;ng e2e&quot;
17  },
18  &quot;private&quot;: true,
19  &quot;dependencies&quot;: {
20    &quot;@angular-devkit/architect&quot;: &quot;^0.1202.5&quot;,
21    &quot;@angular-devkit/architect-cli&quot;: &quot;^0.1202.5&quot;,
22    &quot;@angular/common&quot;: &quot;~12.1.1&quot;,
23    &quot;@angular/core&quot;: &quot;~12.1.1&quot;,
24    &quot;@angular/fire&quot;: &quot;^7.0.4&quot;,
25    &quot;@angular/forms&quot;: &quot;~12.1.1&quot;,
26    &quot;@angular/platform-browser&quot;: &quot;~12.1.1&quot;,
27    &quot;@angular/platform-browser-dynamic&quot;: &quot;~12.1.1&quot;,
28    &quot;@angular/router&quot;: &quot;~12.1.1&quot;,
29    &quot;@ionic/angular&quot;: &quot;^5.5.2&quot;,
30    &quot;ajv&quot;: &quot;^8.6.2&quot;,
31    &quot;angularfire2&quot;: &quot;^5.4.2&quot;,
32    &quot;firebase&quot;: &quot;^7.24.0&quot;,
33    &quot;rxfire&quot;: &quot;^6.0.0&quot;,
34    &quot;rxjs&quot;: &quot;~6.6.0&quot;,
35    &quot;tslib&quot;: &quot;^2.2.0&quot;,
36    &quot;zone.js&quot;: &quot;~0.11.4&quot;
37  },
38  &quot;devDependencies&quot;: {
39    &quot;@angular-devkit/build-angular&quot;: &quot;~12.1.1&quot;,
40    &quot;@angular-eslint/builder&quot;: &quot;~12.0.0&quot;,
41    &quot;@angular-eslint/eslint-plugin&quot;: &quot;~12.0.0&quot;,
42    &quot;@angular-eslint/eslint-plugin-template&quot;: &quot;~12.0.0&quot;,
43    &quot;@angular-eslint/template-parser&quot;: &quot;~12.0.0&quot;,
44    &quot;@angular/cli&quot;: &quot;~12.1.1&quot;,
45    &quot;@angular/compiler&quot;: &quot;~12.1.1&quot;,
46    &quot;@angular/compiler-cli&quot;: &quot;~12.1.1&quot;,
47    &quot;@angular/language-service&quot;: &quot;~12.0.1&quot;,
48    &quot;@ionic/angular-toolkit&quot;: &quot;^4.0.0&quot;,
49    &quot;@types/jasmine&quot;: &quot;~3.6.0&quot;,
50    &quot;@types/jasminewd2&quot;: &quot;~2.0.3&quot;,
51    &quot;@types/node&quot;: &quot;^12.11.1&quot;,
52    &quot;@typescript-eslint/eslint-plugin&quot;: &quot;4.16.1&quot;,
53    &quot;@typescript-eslint/parser&quot;: &quot;4.16.1&quot;,
54    &quot;eslint&quot;: &quot;^7.6.0&quot;,
55    &quot;eslint-plugin-import&quot;: &quot;2.22.1&quot;,
56    &quot;eslint-plugin-jsdoc&quot;: &quot;30.7.6&quot;,
57    &quot;eslint-plugin-prefer-arrow&quot;: &quot;1.2.2&quot;,
58    &quot;jasmine-core&quot;: &quot;~3.8.0&quot;,
59    &quot;jasmine-spec-reporter&quot;: &quot;~5.0.0&quot;,
60    &quot;karma&quot;: &quot;~6.3.2&quot;,
61    &quot;karma-chrome-launcher&quot;: &quot;~3.1.0&quot;,
62    &quot;karma-coverage&quot;: &quot;~2.0.3&quot;,
63    &quot;karma-coverage-istanbul-reporter&quot;: &quot;~3.0.2&quot;,
64    &quot;karma-jasmine&quot;: &quot;~4.0.0&quot;,
65    &quot;karma-jasmine-html-reporter&quot;: &quot;^1.5.0&quot;,
66    &quot;protractor&quot;: &quot;~7.0.0&quot;,
67    &quot;ts-node&quot;: &quot;~8.3.0&quot;,
68    &quot;typescript&quot;: &quot;~4.2.4&quot;,
69    &quot;@angular-devkit/architect&quot;: &quot;^0.1200.0&quot;,
70    &quot;firebase-tools&quot;: &quot;^9.0.0&quot;,
71    &quot;fuzzy&quot;: &quot;^0.1.3&quot;,
72    &quot;inquirer&quot;: &quot;^6.2.2&quot;,
73    &quot;inquirer-autocomplete-prompt&quot;: &quot;^1.0.1&quot;,
74    &quot;open&quot;: &quot;^7.0.3&quot;,
75    &quot;jsonc-parser&quot;: &quot;^3.0.0&quot;
76  },
77  &quot;description&quot;: &quot;An Ionic project&quot;
78}
79import { NgModule } from '@angular/core';
80import { BrowserModule } from '@angular/platform-browser';
81import { RouteReuseStrategy } from '@angular/router';
82import { IonicModule, IonicRouteStrategy } from '@ionic/angular';
83import { AppRoutingModule } from './app-routing.module';
84import { AppComponent } from './app.component';
85import { ClientPageModule } from './client/client.module';
86import { environment } from '../environments/environment';
87import { AngularFireModule } from '@angular/fire';
88import { AngularFireAuthModule } from '@angular/fire/auth';
89import { AngularFireStorageModule } from '@angular/fire/storage';
90import { AngularFireDatabaseModule } from '@angular/fire/database';
91
92@NgModule({
93  declarations: [AppComponent],
94  entryComponents: [],
95  imports: [
96    BrowserModule,
97    IonicModule.forRoot(),
98    AppRoutingModule,
99    ClientPageModule,
100    AngularFireModule.initializeApp(environment.firebaseConfig),
101    AngularFireAuthModule,
102    AngularFireStorageModule,
103    AngularFireDatabaseModule
104  ],
105  providers: [{ provide: RouteReuseStrategy, useClass: IonicRouteStrategy }],
106  bootstrap: [AppComponent],
107})
108export class AppModule {}
109  &quot;compileOnSave&quot;: false,
110  &quot;compilerOptions&quot;: {
111    &quot;baseUrl&quot;: &quot;./&quot;,
112    &quot;outDir&quot;: &quot;./dist/out-tsc&quot;,
113    &quot;sourceMap&quot;: true,
114    &quot;declaration&quot;: false,
115    &quot;downlevelIteration&quot;: true,
116    &quot;experimentalDecorators&quot;: true,
117    &quot;moduleResolution&quot;: &quot;node&quot;,
118    &quot;importHelpers&quot;: true,
119    &quot;target&quot;: &quot;es2015&quot;,
120    &quot;module&quot;: &quot;es2020&quot;,
121    &quot;lib&quot;: [&quot;es2018&quot;, &quot;dom&quot;]
122  },
123  &quot;angularCompilerOptions&quot;: {
124    &quot;enableI18nLegacyMessageIdFormat&quot;: false,
125    &quot;strictInjectionParameters&quot;: true,
126    &quot;strictInputAccessModifiers&quot;: true,
127    &quot;strictTemplates&quot;: true,
128    &quot;skipLibCheck&quot;: true 
129  }
130}
131

ANSWER

Answered 2021-Sep-10 at 12:47

You need to add "compat" like this

1'&quot;@angular/fire&quot;' has no exported member 'AngularFireModule'.ts(2305),
2'&quot;@angular/fire/storage&quot;' has no exported member 'AngularFireStorageModule'.ts(2305)
3'&quot;@angular/fire/database&quot;' has no exported member 'AngularFireDatabaseModule'.ts(2305)
4'&quot;@angular/fire/auth&quot;' has no exported member 'AngularFireAuthModule'.ts(2305)
5{
6  &quot;name&quot;: &quot;gescable&quot;,
7  &quot;version&quot;: &quot;0.0.1&quot;,
8  &quot;author&quot;: &quot;Ionic Framework&quot;,
9  &quot;homepage&quot;: &quot;https://ionicframework.com/&quot;,
10  &quot;scripts&quot;: {
11    &quot;ng&quot;: &quot;ng&quot;,
12    &quot;start&quot;: &quot;ng serve&quot;,
13    &quot;build&quot;: &quot;ng build&quot;,
14    &quot;test&quot;: &quot;ng test&quot;,
15    &quot;lint&quot;: &quot;ng lint&quot;,
16    &quot;e2e&quot;: &quot;ng e2e&quot;
17  },
18  &quot;private&quot;: true,
19  &quot;dependencies&quot;: {
20    &quot;@angular-devkit/architect&quot;: &quot;^0.1202.5&quot;,
21    &quot;@angular-devkit/architect-cli&quot;: &quot;^0.1202.5&quot;,
22    &quot;@angular/common&quot;: &quot;~12.1.1&quot;,
23    &quot;@angular/core&quot;: &quot;~12.1.1&quot;,
24    &quot;@angular/fire&quot;: &quot;^7.0.4&quot;,
25    &quot;@angular/forms&quot;: &quot;~12.1.1&quot;,
26    &quot;@angular/platform-browser&quot;: &quot;~12.1.1&quot;,
27    &quot;@angular/platform-browser-dynamic&quot;: &quot;~12.1.1&quot;,
28    &quot;@angular/router&quot;: &quot;~12.1.1&quot;,
29    &quot;@ionic/angular&quot;: &quot;^5.5.2&quot;,
30    &quot;ajv&quot;: &quot;^8.6.2&quot;,
31    &quot;angularfire2&quot;: &quot;^5.4.2&quot;,
32    &quot;firebase&quot;: &quot;^7.24.0&quot;,
33    &quot;rxfire&quot;: &quot;^6.0.0&quot;,
34    &quot;rxjs&quot;: &quot;~6.6.0&quot;,
35    &quot;tslib&quot;: &quot;^2.2.0&quot;,
36    &quot;zone.js&quot;: &quot;~0.11.4&quot;
37  },
38  &quot;devDependencies&quot;: {
39    &quot;@angular-devkit/build-angular&quot;: &quot;~12.1.1&quot;,
40    &quot;@angular-eslint/builder&quot;: &quot;~12.0.0&quot;,
41    &quot;@angular-eslint/eslint-plugin&quot;: &quot;~12.0.0&quot;,
42    &quot;@angular-eslint/eslint-plugin-template&quot;: &quot;~12.0.0&quot;,
43    &quot;@angular-eslint/template-parser&quot;: &quot;~12.0.0&quot;,
44    &quot;@angular/cli&quot;: &quot;~12.1.1&quot;,
45    &quot;@angular/compiler&quot;: &quot;~12.1.1&quot;,
46    &quot;@angular/compiler-cli&quot;: &quot;~12.1.1&quot;,
47    &quot;@angular/language-service&quot;: &quot;~12.0.1&quot;,
48    &quot;@ionic/angular-toolkit&quot;: &quot;^4.0.0&quot;,
49    &quot;@types/jasmine&quot;: &quot;~3.6.0&quot;,
50    &quot;@types/jasminewd2&quot;: &quot;~2.0.3&quot;,
51    &quot;@types/node&quot;: &quot;^12.11.1&quot;,
52    &quot;@typescript-eslint/eslint-plugin&quot;: &quot;4.16.1&quot;,
53    &quot;@typescript-eslint/parser&quot;: &quot;4.16.1&quot;,
54    &quot;eslint&quot;: &quot;^7.6.0&quot;,
55    &quot;eslint-plugin-import&quot;: &quot;2.22.1&quot;,
56    &quot;eslint-plugin-jsdoc&quot;: &quot;30.7.6&quot;,
57    &quot;eslint-plugin-prefer-arrow&quot;: &quot;1.2.2&quot;,
58    &quot;jasmine-core&quot;: &quot;~3.8.0&quot;,
59    &quot;jasmine-spec-reporter&quot;: &quot;~5.0.0&quot;,
60    &quot;karma&quot;: &quot;~6.3.2&quot;,
61    &quot;karma-chrome-launcher&quot;: &quot;~3.1.0&quot;,
62    &quot;karma-coverage&quot;: &quot;~2.0.3&quot;,
63    &quot;karma-coverage-istanbul-reporter&quot;: &quot;~3.0.2&quot;,
64    &quot;karma-jasmine&quot;: &quot;~4.0.0&quot;,
65    &quot;karma-jasmine-html-reporter&quot;: &quot;^1.5.0&quot;,
66    &quot;protractor&quot;: &quot;~7.0.0&quot;,
67    &quot;ts-node&quot;: &quot;~8.3.0&quot;,
68    &quot;typescript&quot;: &quot;~4.2.4&quot;,
69    &quot;@angular-devkit/architect&quot;: &quot;^0.1200.0&quot;,
70    &quot;firebase-tools&quot;: &quot;^9.0.0&quot;,
71    &quot;fuzzy&quot;: &quot;^0.1.3&quot;,
72    &quot;inquirer&quot;: &quot;^6.2.2&quot;,
73    &quot;inquirer-autocomplete-prompt&quot;: &quot;^1.0.1&quot;,
74    &quot;open&quot;: &quot;^7.0.3&quot;,
75    &quot;jsonc-parser&quot;: &quot;^3.0.0&quot;
76  },
77  &quot;description&quot;: &quot;An Ionic project&quot;
78}
79import { NgModule } from '@angular/core';
80import { BrowserModule } from '@angular/platform-browser';
81import { RouteReuseStrategy } from '@angular/router';
82import { IonicModule, IonicRouteStrategy } from '@ionic/angular';
83import { AppRoutingModule } from './app-routing.module';
84import { AppComponent } from './app.component';
85import { ClientPageModule } from './client/client.module';
86import { environment } from '../environments/environment';
87import { AngularFireModule } from '@angular/fire';
88import { AngularFireAuthModule } from '@angular/fire/auth';
89import { AngularFireStorageModule } from '@angular/fire/storage';
90import { AngularFireDatabaseModule } from '@angular/fire/database';
91
92@NgModule({
93  declarations: [AppComponent],
94  entryComponents: [],
95  imports: [
96    BrowserModule,
97    IonicModule.forRoot(),
98    AppRoutingModule,
99    ClientPageModule,
100    AngularFireModule.initializeApp(environment.firebaseConfig),
101    AngularFireAuthModule,
102    AngularFireStorageModule,
103    AngularFireDatabaseModule
104  ],
105  providers: [{ provide: RouteReuseStrategy, useClass: IonicRouteStrategy }],
106  bootstrap: [AppComponent],
107})
108export class AppModule {}
109  &quot;compileOnSave&quot;: false,
110  &quot;compilerOptions&quot;: {
111    &quot;baseUrl&quot;: &quot;./&quot;,
112    &quot;outDir&quot;: &quot;./dist/out-tsc&quot;,
113    &quot;sourceMap&quot;: true,
114    &quot;declaration&quot;: false,
115    &quot;downlevelIteration&quot;: true,
116    &quot;experimentalDecorators&quot;: true,
117    &quot;moduleResolution&quot;: &quot;node&quot;,
118    &quot;importHelpers&quot;: true,
119    &quot;target&quot;: &quot;es2015&quot;,
120    &quot;module&quot;: &quot;es2020&quot;,
121    &quot;lib&quot;: [&quot;es2018&quot;, &quot;dom&quot;]
122  },
123  &quot;angularCompilerOptions&quot;: {
124    &quot;enableI18nLegacyMessageIdFormat&quot;: false,
125    &quot;strictInjectionParameters&quot;: true,
126    &quot;strictInputAccessModifiers&quot;: true,
127    &quot;strictTemplates&quot;: true,
128    &quot;skipLibCheck&quot;: true 
129  }
130}
131import { AngularFireModule } from &quot;@angular/fire/compat&quot;;
132import { AngularFireAuthModule } from &quot;@angular/fire/compat/auth&quot;;
133import { AngularFireStorageModule } from '@angular/fire/compat/storage';
134import { AngularFirestoreModule } from '@angular/fire/compat/firestore';
135import { AngularFireDatabaseModule } from '@angular/fire/compat/database';
136

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

QUESTION

How to solve FirebaseError: Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore problem?

Asked 2022-Jan-11 at 15:08

I am trying to set up Firebase with next.js. I am getting this error in the console.

FirebaseError: Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore

This is one of my custom hook

1import { onAuthStateChanged, User } from '@firebase/auth'
2import { doc, onSnapshot, Unsubscribe } from 'firebase/firestore'
3import { useEffect, useState } from 'react'
4import { auth, fireStore } from './firebase'
5
6export const useUserData = () =&gt; {
7  const [username, setUsername] = useState&lt;string | null&gt;(null)
8
9  const [currentUser, setCurrentUser] = useState&lt;User | null&gt;(null)
10
11  useEffect(() =&gt; {
12    let unsubscribe: void | Unsubscribe
13
14    onAuthStateChanged(auth, (user) =&gt; {
15      if (user) {
16        setCurrentUser(user)
17        // The Problem is inside this try blog
18        try {
19          // the onsnapshot function is causing the problem
20          console.log('firestore: ', fireStore)
21          unsubscribe = onSnapshot(doc(fireStore, 'users', user.uid), (doc) =&gt; {
22            setUsername(doc.data()?.username)
23          })
24        } catch (e) {
25          console.log(e.message)
26        }
27      } else {
28        setCurrentUser(null)
29        setUsername(null)
30      }
31    })
32
33    return unsubscribe
34  }, [currentUser])
35
36  return { currentUser, username }
37}
38

I also have this firebase.ts file where I initialized my firebase app

1import { onAuthStateChanged, User } from '@firebase/auth'
2import { doc, onSnapshot, Unsubscribe } from 'firebase/firestore'
3import { useEffect, useState } from 'react'
4import { auth, fireStore } from './firebase'
5
6export const useUserData = () =&gt; {
7  const [username, setUsername] = useState&lt;string | null&gt;(null)
8
9  const [currentUser, setCurrentUser] = useState&lt;User | null&gt;(null)
10
11  useEffect(() =&gt; {
12    let unsubscribe: void | Unsubscribe
13
14    onAuthStateChanged(auth, (user) =&gt; {
15      if (user) {
16        setCurrentUser(user)
17        // The Problem is inside this try blog
18        try {
19          // the onsnapshot function is causing the problem
20          console.log('firestore: ', fireStore)
21          unsubscribe = onSnapshot(doc(fireStore, 'users', user.uid), (doc) =&gt; {
22            setUsername(doc.data()?.username)
23          })
24        } catch (e) {
25          console.log(e.message)
26        }
27      } else {
28        setCurrentUser(null)
29        setUsername(null)
30      }
31    })
32
33    return unsubscribe
34  }, [currentUser])
35
36  return { currentUser, username }
37}
38import { FirebaseApp, getApps, initializeApp } from 'firebase/app'
39import { getAuth } from 'firebase/auth'
40import { getFirestore } from 'firebase/firestore/lite'
41import { getStorage } from 'firebase/storage'
42
43const firebaseConfig = {
44  apiKey: 'some-api',
45  authDomain: 'some-auth-domain',
46  projectId: 'some-project-id',
47  storageBucket: 'some-storage-bucket',
48  messagingSenderId: 'some-id',
49  appId: 'some-app-id',
50  measurementId: 'some-measurement-id',
51}
52
53let firebaseApp: FirebaseApp
54
55if (!getApps.length) {
56  firebaseApp = initializeApp(firebaseConfig)
57}
58
59const fireStore = getFirestore(firebaseApp)
60const auth = getAuth(firebaseApp)
61const storage = getStorage(firebaseApp)
62
63export { fireStore, auth, storage }
64

I don't know whether the problem is in the project initialization. I am pretty sure the error is generated from my custom hook file. I also found out that there must be something wrong with onSnapshot function. Am I passing the docRef wrong or something? What am I doing wrong here?

The console.log(firestore) log:

1import { onAuthStateChanged, User } from '@firebase/auth'
2import { doc, onSnapshot, Unsubscribe } from 'firebase/firestore'
3import { useEffect, useState } from 'react'
4import { auth, fireStore } from './firebase'
5
6export const useUserData = () =&gt; {
7  const [username, setUsername] = useState&lt;string | null&gt;(null)
8
9  const [currentUser, setCurrentUser] = useState&lt;User | null&gt;(null)
10
11  useEffect(() =&gt; {
12    let unsubscribe: void | Unsubscribe
13
14    onAuthStateChanged(auth, (user) =&gt; {
15      if (user) {
16        setCurrentUser(user)
17        // The Problem is inside this try blog
18        try {
19          // the onsnapshot function is causing the problem
20          console.log('firestore: ', fireStore)
21          unsubscribe = onSnapshot(doc(fireStore, 'users', user.uid), (doc) =&gt; {
22            setUsername(doc.data()?.username)
23          })
24        } catch (e) {
25          console.log(e.message)
26        }
27      } else {
28        setCurrentUser(null)
29        setUsername(null)
30      }
31    })
32
33    return unsubscribe
34  }, [currentUser])
35
36  return { currentUser, username }
37}
38import { FirebaseApp, getApps, initializeApp } from 'firebase/app'
39import { getAuth } from 'firebase/auth'
40import { getFirestore } from 'firebase/firestore/lite'
41import { getStorage } from 'firebase/storage'
42
43const firebaseConfig = {
44  apiKey: 'some-api',
45  authDomain: 'some-auth-domain',
46  projectId: 'some-project-id',
47  storageBucket: 'some-storage-bucket',
48  messagingSenderId: 'some-id',
49  appId: 'some-app-id',
50  measurementId: 'some-measurement-id',
51}
52
53let firebaseApp: FirebaseApp
54
55if (!getApps.length) {
56  firebaseApp = initializeApp(firebaseConfig)
57}
58
59const fireStore = getFirestore(firebaseApp)
60const auth = getAuth(firebaseApp)
61const storage = getStorage(firebaseApp)
62
63export { fireStore, auth, storage }
64
65    type: &quot;firestore-lite&quot;
66    _app: FirebaseAppImpl
67    _automaticDataCollectionEnabled: false
68    _config: {name: &quot;[DEFAULT]&quot;, automaticDataCollectionEnabled: false}
69    _container: ComponentContainer {name: &quot;[DEFAULT]&quot;, providers: Map(15)}
70    _isDeleted: false
71    _name: &quot;[DEFAULT]&quot;
72    _options:
73    apiKey: 'some-api'
74    authDomain: 'some-auth-domain'
75    projectId: 'some-project-id'
76    storageBucket: 'some-storage-bucket'
77    messagingSenderId: 'some-id'
78    appId: 'some-app-id'
79    measurementId: 'some-measurement-id'
80    [[Prototype]]: Object
81    automaticDataCollectionEnabled: (...)
82    config: (...)
83    container: (...)
84    isDeleted: (...)
85    name: (...)
86    options: (...)
87    [[Prototype]]: Object
88    _credentials: Q {auth: AuthInterop}
89    _databaseId: H {projectId: &quot;next-firebase-fireship&quot;, database: &quot;(default)&quot;}
90    _persistenceKey: &quot;(lite)&quot;
91    _settings: ee {host: &quot;firestore.googleapis.com&quot;, ssl: true, credentials: undefined, ignoreUndefinedProperties: false, cacheSizeBytes: 41943040, …}
92    _settingsFrozen: false
93    app: (...)
94    _initialized: (...)
95    _terminated: (...)
96
97

ANSWER

Answered 2022-Jan-07 at 19:07

Using getFirestore from lite library will not work with onSnapshot. You are importing getFirestore from lite version:

1import { onAuthStateChanged, User } from '@firebase/auth'
2import { doc, onSnapshot, Unsubscribe } from 'firebase/firestore'
3import { useEffect, useState } from 'react'
4import { auth, fireStore } from './firebase'
5
6export const useUserData = () =&gt; {
7  const [username, setUsername] = useState&lt;string | null&gt;(null)
8
9  const [currentUser, setCurrentUser] = useState&lt;User | null&gt;(null)
10
11  useEffect(() =&gt; {
12    let unsubscribe: void | Unsubscribe
13
14    onAuthStateChanged(auth, (user) =&gt; {
15      if (user) {
16        setCurrentUser(user)
17        // The Problem is inside this try blog
18        try {
19          // the onsnapshot function is causing the problem
20          console.log('firestore: ', fireStore)
21          unsubscribe = onSnapshot(doc(fireStore, 'users', user.uid), (doc) =&gt; {
22            setUsername(doc.data()?.username)
23          })
24        } catch (e) {
25          console.log(e.message)
26        }
27      } else {
28        setCurrentUser(null)
29        setUsername(null)
30      }
31    })
32
33    return unsubscribe
34  }, [currentUser])
35
36  return { currentUser, username }
37}
38import { FirebaseApp, getApps, initializeApp } from 'firebase/app'
39import { getAuth } from 'firebase/auth'
40import { getFirestore } from 'firebase/firestore/lite'
41import { getStorage } from 'firebase/storage'
42
43const firebaseConfig = {
44  apiKey: 'some-api',
45  authDomain: 'some-auth-domain',
46  projectId: 'some-project-id',
47  storageBucket: 'some-storage-bucket',
48  messagingSenderId: 'some-id',
49  appId: 'some-app-id',
50  measurementId: 'some-measurement-id',
51}
52
53let firebaseApp: FirebaseApp
54
55if (!getApps.length) {
56  firebaseApp = initializeApp(firebaseConfig)
57}
58
59const fireStore = getFirestore(firebaseApp)
60const auth = getAuth(firebaseApp)
61const storage = getStorage(firebaseApp)
62
63export { fireStore, auth, storage }
64
65    type: &quot;firestore-lite&quot;
66    _app: FirebaseAppImpl
67    _automaticDataCollectionEnabled: false
68    _config: {name: &quot;[DEFAULT]&quot;, automaticDataCollectionEnabled: false}
69    _container: ComponentContainer {name: &quot;[DEFAULT]&quot;, providers: Map(15)}
70    _isDeleted: false
71    _name: &quot;[DEFAULT]&quot;
72    _options:
73    apiKey: 'some-api'
74    authDomain: 'some-auth-domain'
75    projectId: 'some-project-id'
76    storageBucket: 'some-storage-bucket'
77    messagingSenderId: 'some-id'
78    appId: 'some-app-id'
79    measurementId: 'some-measurement-id'
80    [[Prototype]]: Object
81    automaticDataCollectionEnabled: (...)
82    config: (...)
83    container: (...)
84    isDeleted: (...)
85    name: (...)
86    options: (...)
87    [[Prototype]]: Object
88    _credentials: Q {auth: AuthInterop}
89    _databaseId: H {projectId: &quot;next-firebase-fireship&quot;, database: &quot;(default)&quot;}
90    _persistenceKey: &quot;(lite)&quot;
91    _settings: ee {host: &quot;firestore.googleapis.com&quot;, ssl: true, credentials: undefined, ignoreUndefinedProperties: false, cacheSizeBytes: 41943040, …}
92    _settingsFrozen: false
93    app: (...)
94    _initialized: (...)
95    _terminated: (...)
96
97import { getFirestore } from 'firebase/firestore/lite'
98

Change the import to:

1import { onAuthStateChanged, User } from '@firebase/auth'
2import { doc, onSnapshot, Unsubscribe } from 'firebase/firestore'
3import { useEffect, useState } from 'react'
4import { auth, fireStore } from './firebase'
5
6export const useUserData = () =&gt; {
7  const [username, setUsername] = useState&lt;string | null&gt;(null)
8
9  const [currentUser, setCurrentUser] = useState&lt;User | null&gt;(null)
10
11  useEffect(() =&gt; {
12    let unsubscribe: void | Unsubscribe
13
14    onAuthStateChanged(auth, (user) =&gt; {
15      if (user) {
16        setCurrentUser(user)
17        // The Problem is inside this try blog
18        try {
19          // the onsnapshot function is causing the problem
20          console.log('firestore: ', fireStore)
21          unsubscribe = onSnapshot(doc(fireStore, 'users', user.uid), (doc) =&gt; {
22            setUsername(doc.data()?.username)
23          })
24        } catch (e) {
25          console.log(e.message)
26        }
27      } else {
28        setCurrentUser(null)
29        setUsername(null)
30      }
31    })
32
33    return unsubscribe
34  }, [currentUser])
35
36  return { currentUser, username }
37}
38import { FirebaseApp, getApps, initializeApp } from 'firebase/app'
39import { getAuth } from 'firebase/auth'
40import { getFirestore } from 'firebase/firestore/lite'
41import { getStorage } from 'firebase/storage'
42
43const firebaseConfig = {
44  apiKey: 'some-api',
45  authDomain: 'some-auth-domain',
46  projectId: 'some-project-id',
47  storageBucket: 'some-storage-bucket',
48  messagingSenderId: 'some-id',
49  appId: 'some-app-id',
50  measurementId: 'some-measurement-id',
51}
52
53let firebaseApp: FirebaseApp
54
55if (!getApps.length) {
56  firebaseApp = initializeApp(firebaseConfig)
57}
58
59const fireStore = getFirestore(firebaseApp)
60const auth = getAuth(firebaseApp)
61const storage = getStorage(firebaseApp)
62
63export { fireStore, auth, storage }
64
65    type: &quot;firestore-lite&quot;
66    _app: FirebaseAppImpl
67    _automaticDataCollectionEnabled: false
68    _config: {name: &quot;[DEFAULT]&quot;, automaticDataCollectionEnabled: false}
69    _container: ComponentContainer {name: &quot;[DEFAULT]&quot;, providers: Map(15)}
70    _isDeleted: false
71    _name: &quot;[DEFAULT]&quot;
72    _options:
73    apiKey: 'some-api'
74    authDomain: 'some-auth-domain'
75    projectId: 'some-project-id'
76    storageBucket: 'some-storage-bucket'
77    messagingSenderId: 'some-id'
78    appId: 'some-app-id'
79    measurementId: 'some-measurement-id'
80    [[Prototype]]: Object
81    automaticDataCollectionEnabled: (...)
82    config: (...)
83    container: (...)
84    isDeleted: (...)
85    name: (...)
86    options: (...)
87    [[Prototype]]: Object
88    _credentials: Q {auth: AuthInterop}
89    _databaseId: H {projectId: &quot;next-firebase-fireship&quot;, database: &quot;(default)&quot;}
90    _persistenceKey: &quot;(lite)&quot;
91    _settings: ee {host: &quot;firestore.googleapis.com&quot;, ssl: true, credentials: undefined, ignoreUndefinedProperties: false, cacheSizeBytes: 41943040, …}
92    _settingsFrozen: false
93    app: (...)
94    _initialized: (...)
95    _terminated: (...)
96
97import { getFirestore } from 'firebase/firestore/lite'
98import { getFirestore } from 'firebase/firestore'
99

From the documentation,

The onSnapshot method and DocumentChange, SnapshotListenerOptions, SnapshotMetadata, SnapshotOptions and Unsubscribe objects are not included in lite version.


Another reason for this error to show up could be passing invalid first argument to collection() or doc() functions. They both take a Firestore instance as first argument.

1import { onAuthStateChanged, User } from '@firebase/auth'
2import { doc, onSnapshot, Unsubscribe } from 'firebase/firestore'
3import { useEffect, useState } from 'react'
4import { auth, fireStore } from './firebase'
5
6export const useUserData = () =&gt; {
7  const [username, setUsername] = useState&lt;string | null&gt;(null)
8
9  const [currentUser, setCurrentUser] = useState&lt;User | null&gt;(null)
10
11  useEffect(() =&gt; {
12    let unsubscribe: void | Unsubscribe
13
14    onAuthStateChanged(auth, (user) =&gt; {
15      if (user) {
16        setCurrentUser(user)
17        // The Problem is inside this try blog
18        try {
19          // the onsnapshot function is causing the problem
20          console.log('firestore: ', fireStore)
21          unsubscribe = onSnapshot(doc(fireStore, 'users', user.uid), (doc) =&gt; {
22            setUsername(doc.data()?.username)
23          })
24        } catch (e) {
25          console.log(e.message)
26        }
27      } else {
28        setCurrentUser(null)
29        setUsername(null)
30      }
31    })
32
33    return unsubscribe
34  }, [currentUser])
35
36  return { currentUser, username }
37}
38import { FirebaseApp, getApps, initializeApp } from 'firebase/app'
39import { getAuth } from 'firebase/auth'
40import { getFirestore } from 'firebase/firestore/lite'
41import { getStorage } from 'firebase/storage'
42
43const firebaseConfig = {
44  apiKey: 'some-api',
45  authDomain: 'some-auth-domain',
46  projectId: 'some-project-id',
47  storageBucket: 'some-storage-bucket',
48  messagingSenderId: 'some-id',
49  appId: 'some-app-id',
50  measurementId: 'some-measurement-id',
51}
52
53let firebaseApp: FirebaseApp
54
55if (!getApps.length) {
56  firebaseApp = initializeApp(firebaseConfig)
57}
58
59const fireStore = getFirestore(firebaseApp)
60const auth = getAuth(firebaseApp)
61const storage = getStorage(firebaseApp)
62
63export { fireStore, auth, storage }
64
65    type: &quot;firestore-lite&quot;
66    _app: FirebaseAppImpl
67    _automaticDataCollectionEnabled: false
68    _config: {name: &quot;[DEFAULT]&quot;, automaticDataCollectionEnabled: false}
69    _container: ComponentContainer {name: &quot;[DEFAULT]&quot;, providers: Map(15)}
70    _isDeleted: false
71    _name: &quot;[DEFAULT]&quot;
72    _options:
73    apiKey: 'some-api'
74    authDomain: 'some-auth-domain'
75    projectId: 'some-project-id'
76    storageBucket: 'some-storage-bucket'
77    messagingSenderId: 'some-id'
78    appId: 'some-app-id'
79    measurementId: 'some-measurement-id'
80    [[Prototype]]: Object
81    automaticDataCollectionEnabled: (...)
82    config: (...)
83    container: (...)
84    isDeleted: (...)
85    name: (...)
86    options: (...)
87    [[Prototype]]: Object
88    _credentials: Q {auth: AuthInterop}
89    _databaseId: H {projectId: &quot;next-firebase-fireship&quot;, database: &quot;(default)&quot;}
90    _persistenceKey: &quot;(lite)&quot;
91    _settings: ee {host: &quot;firestore.googleapis.com&quot;, ssl: true, credentials: undefined, ignoreUndefinedProperties: false, cacheSizeBytes: 41943040, …}
92    _settingsFrozen: false
93    app: (...)
94    _initialized: (...)
95    _terminated: (...)
96
97import { getFirestore } from 'firebase/firestore/lite'
98import { getFirestore } from 'firebase/firestore'
99// Ensure that &quot;db&quot; is defined and initialized
100const db = getFirestore();
101// console.log(db);
102
103const colRef = collection(db, &quot;collection_name&quot;);
104

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

QUESTION

How is optional assignment constexpr in C++ 20?

Asked 2021-Dec-26 at 03:03

To the internal content of an optional, doesn't the optional require placement new in order to reconstruct the internal in place storage or union? Is there some new feature like placement new in C++ 20 that allows for constexpr assignment of std::optional?

1template&lt; class U = T &gt;
2optional&amp; operator=( U&amp;&amp; value );
3(since C++17)
4(until C++20)
5template&lt; class U = T &gt;
6constexpr optional&amp; operator=( U&amp;&amp; value );
7(since C++20)
8

ANSWER

Answered 2021-Dec-26 at 03:03

To the internal content of an optional, doesn't the optional require placement new in order to reconstruct the internal in place storage or union?

For assignment, yes it does.

But while we still cannot do actual placement new during constexpr time, we did get a workaround for its absence: std::construct_at (from P0784). This is a very limited form of placement new, but it's enough to get optional assignment working.

The other change was that we also needed to be able to actually change the active member of a union - since it wouldn't matter if we could construct the new object if we couldn't actually switch. That also happened in C++20 (P1330).

Put those together, and you get a functional implementation of optional assignment: P2231. An abbreviated implementation would look like this:

1template&lt; class U = T &gt;
2optional&amp; operator=( U&amp;&amp; value );
3(since C++17)
4(until C++20)
5template&lt; class U = T &gt;
6constexpr optional&amp; operator=( U&amp;&amp; value );
7(since C++20)
8template &lt;typename T&gt;
9struct optional {
10    union {
11        T value;
12        char empty;
13    };
14    bool has_value;
15
16    constexpr optional&amp; operator=(T const&amp; rhs) {
17        if (has_value) {
18            value = rhs;
19        } else {
20            // basically ::new (&amp;value) T(rhs);
21            // except blessed for constexpr usage
22            std::construct_at(&amp;value, rhs); 
23        }
24        has_value = true;
25        return *this;
26    }
27};
28

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

QUESTION

No analytics cookies is set upon a consent was updated

Asked 2021-Dec-11 at 17:17

I am using the Google Tag Manager with a single tag referencing a default Google Analytics script. My solution is based on the information from these resources:

The code is simple (commit):

index.html: define gtag() and set denied as a default for all storages

1  &lt;script&gt;
2    window.dataLayer = window.dataLayer || [];
3    function gtag() { window.dataLayer.push(arguments); }
4    gtag('consent', 'default', {
5      ad_storage: 'denied',
6      analytics_storage: 'denied',
7      personalization_storage: 'denied',
8      functionality_storage: 'granted',
9      security_storage: 'granted',
10      wait_for_update: 400,
11    });
12

Then load a user configuration from the localStorage and call update:

1  &lt;script&gt;
2    window.dataLayer = window.dataLayer || [];
3    function gtag() { window.dataLayer.push(arguments); }
4    gtag('consent', 'default', {
5      ad_storage: 'denied',
6      analytics_storage: 'denied',
7      personalization_storage: 'denied',
8      functionality_storage: 'granted',
9      security_storage: 'granted',
10      wait_for_update: 400,
11    });
12handleCookies(preferences) {
13  console.log('handleCookies callback');
14  gtag('consent', 'update', {
15    ad_storage: preferences.ad,
16    analytics_storage: preferences.analytics,
17    personalization_storage: preferences.personalization,
18  });
19  console.log(window.dataLayer);
20},
21

So far so good because I see the event queue is updated in dataLayer:

chrome console

As the consent is set I anticipate the the cookies will be set for the Google Analytics now. But they are missing. What stupid mistake have I done?

cookies box

GTM configuration

See https://beta.mezinamiridici.cz

ANSWER

Answered 2021-Dec-08 at 10:11

From your screenshot, gtm.js is executed before the update of the consent mode so the pageview continues to be sent to Google Analytics as denied.

The update must take place before gtm.js

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

QUESTION

Do not nest files in rails active storage

Asked 2021-Nov-04 at 20:01

It appears that by default, Rails Active Storage nests your file uploads by means of the associated active_storage_blob key.

The rules appear to be as follows for the default behavior. Within the <Rails.root>/storage/ directory:

  • take the first two characters of the key and make a directory
    • within that directory, take the next two characters of the key and make another directory
      • store the file there, and the file name is the entire key

For example: where the key of a particular file's associated active_storage_blob is: 2HadGpe3G4r5ygdgdfh5534346, It would look like the following:

Rails Active Storage Nesting Default Behavior

I do not want this nesting behavior. I want to store the files flat within the storage directory. So I simply want it to look like this:

Desired Active Storage Behavior.

How can I do that? A google search and a read through of the Active Storage Rails Guides didn't reveal a solution.

Also just out of curiosity: why is this the default behavior?

ANSWER

Answered 2021-Oct-30 at 13:03

Digging around in the code of the ActiveStorage DiskService, I found the code which generates the folder structure. All is conveniently contained within a single function:

1def folder_for(key)
2  [ key[0..1], key[2..3] ].join(&quot;/&quot;)
3end
4

This makes it easy to eliminate the two-letter subfolder structure by a simple patch:

1def folder_for(key)
2  [ key[0..1], key[2..3] ].join(&quot;/&quot;)
3end
4module ActiveStorage
5  class Service::DiskService &lt; Service
6    private
7      def folder_for(key)
8        &quot;&quot;
9      end
10  end
11end
12

Best to do a little testing on this patch, but as far as I could tell it should work just fine.

The answer to the second question I was not able to determine by just looking at the DiskService code. There are no clues there to this folder structure, so the reasons may lie elsewhere. It may be done entirely for cosmetic purposes, in order to avoid a giant single folder blob on large servers. Perhaps someone who knows more can comment.

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

QUESTION

What should happen if one calls `std::exit` in a global object's destructor?

Asked 2021-Oct-28 at 07:46

Consider the following code:

1#include &lt;cstdlib&gt;
2struct Foo {
3    ~Foo() {
4        std::exit(0);
5    }
6} foo;
7int main() {
8}
9

It compiles and terminates with zero successfully for me both on my Linux (GCC, Clang) and Windows (Visual Studio). However, when compiled with MSYS2's GCC on Windows (g++ (Rev2, Built by MSYS2 project) 10.3.0), it enters an infinite recursion and dies from stack overflow. This can be checked by adding some debug output right before std::exit(); I did not add it initially to avoid thinking about the destruction of std::cout.

Does any C++ standard have anything to say about such behavior? Is it well-defined/implementation-defined/undefined/etc and why?

For instance, [support.start.term]/9.1 of some recent draft says the following about std::exit's behavior:

First, objects with thread storage duration and associated with the current thread are destroyed. Next, objects with static storage duration are destroyed and functions registered by calling atexit are called. See [basic.start.term] for the order of destructions and calls.

which refers to [basic.start.term]/1, I guess:

Constructed objects ([dcl.init]) with static storage duration are destroyed and functions registered with std​::​atexit are called as part of a call to std​::​exit ([support.start.term]). The call to std​::​exit is sequenced before the destructions and the registered functions.

I don't see any immediate restriction on calling std::exit in a destructor.

Sidenote: please refrain from commenting that "this code is bad", "thou shalt not use destructors in global objects" (which you probably should not) and probing for the XY problem in the comments. Consider this an academic question from a curious student who knows a much better solution to their original problem, but have stumbled upon this quirk while exploring the vast meadows of C++.

ANSWER

Answered 2021-Oct-27 at 12:26

[basic.start.main]/4:

If std​::​exit is called to end a program during the destruction of an object with static or thread storage duration, the program has undefined behavior.

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

Community Discussions contain sources that include Stack Exchange Network

Tutorials and Learning Resources in Storage

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

Share this Page

share link

Get latest updates on Storage