'You attempted to use a firebase module that's not installed on your Android project by calling firebase.perf()
I have added the @react-native-firebase/perf package to my react-native app following the steps here: perf/installation to monitor my app's performance
Proceeded to create a simple trace in a simple function following the steps here: perf/usage
Then I notice an error in the console telling me:
Error: You attempted to use a firebase module that's not installed on your Android project by calling firebase.perf().
Ensure you have:
1) imported the 'io.invertase.firebase.perf.ReactNativeFirebasePerfPackage' module in your 'MainApplication.java' file.
2) Added the 'new ReactNativeFirebasePerfPackage()' line inside of the RN 'getPackages()' method list.
I added what it asked me to add, googled it some more but no luck, also on the firebase console I can't see my performance under the performance tab (I see, instead, the welcome screen/add SDK)
Below are all the related files I think, Idk what I am missing im not really experienced with android development
- My
package.json:
"dependencies": {
...
"@react-native-firebase/perf": "^14.8.0",
}
- My custom trace:
const appPerformanceRef = async () => {
const trace = await perf().startTrace('TEST_TRACE');
trace.putAttribute('test trace', 'looping a bunch of times');
trace.putMetric('metric', 25);
await trace.start();
for (let i = 0; i < 100000; i++) {}
console.log(trace.getMetrics());
await trace.stop();
};
appPerformanceRef();
MainApplication.java:
import io.invertase.firebase.perf.ReactNativeFirebasePerfPackage;
And inside MainApplication class
...
private final ReactNativeHost mReactNativeHost =
new ReactNativeHostWrapper(this, new ReactNativeHost(this) {
@Override
public boolean getUseDeveloperSupport() {
return BuildConfig.DEBUG;
}
// this part
@Override
protected List<ReactPackage> getPackages() {
@SuppressWarnings("UnnecessaryLocalVariable")
protected List<ReactPackage> getPackages() {
return Arrays.asList(
new MainReactPackage(),
new ReactNativeFirebasePerfPackage(),
}
@Override
protected String getJSMainModuleName() {
return "index";
}
@Override
protected String getJSBundleFile() {
return CodePush.getJSBundleFile();
}
});
android/app/build.gradle
apply plugin: 'com.google.firebase.firebase-perf'
build.gradle
dependencies {
...
classpath('com.google.firebase:perf-plugin:1.4.1')
}
settings.gradle
include ':@react-native-firebase_perf'
project(':@react-native-firebase_perf').projectDir = new File(rootProject.projectDir, './../node_modules/@react-native-firebase/perf/android')
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
