Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error building react-native release like variant #72

Open
fdrcslv opened this issue Sep 15, 2022 · 2 comments
Open

Error building react-native release like variant #72

fdrcslv opened this issue Sep 15, 2022 · 2 comments

Comments

@fdrcslv
Copy link

fdrcslv commented Sep 15, 2022

Thanks for developing this plugin

I'm trying to build my react-native app running react-native run-android --variant debugtwo, "debugtwo" being a variant in my build.gradle.
It should be no different from the release variant, except from react enviroment variables, which are hardcoded for debug purposes and a different app id from the release variant.

I get this error

/{MY_ROOT_DIRECTORY}/android/app/src/debugtwo/java/it/example/app/ReactNativeFlipper.java:26: error: cannot find symbol
import tech.bam.rnperformance.flipper.RNPerfMonitorPlugin

The current setup

ReactNativeFlipper.java in the "debugtwo" directory structure

I've copied the exact same structure from the regular "debug" variant, so the class file ReactNativeFlipper.java is in the correct position: android/app/src/debugtwo/java/it/example/app/ReactNativeFlipper.java

I get no errors with flipper iself or flipper plugins like CrashReporterPlugin, since i put to have flipper available in a release like build

implementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") {
        exclude group: 'com.facebook.fbjni'
    }

implementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
    exclude group: 'com.facebook.flipper'
    exclude group: 'com.squareup.okhttp3', module: 'okhttp'
}

implementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") {
    exclude group: 'com.facebook.flipper'
}

build.gradle

...
buildTypes {
    release {
                minifyEnabled enableProguardInReleaseBuilds
                proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
                signingConfig signingConfigs.release
            }
  
    debugtwo {
                initWith(buildTypes.release)
                matchingFallbacks = ['release']
            }
}
...

Something with the autolinking of the dependencies seems wrong, so i also tried manually linking like this

in android/settings.gradle

include ':react-native-flipper-performance-plugin'
project(':react-native-flipper-performance-plugin').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-flipper-performance-plugin/android')

and in android/app/build.gradle:

implementation project(':react-native-flipper-performance-plugin') // add this line

I have also checked the node version used in android studio and the default on my machine with nvm current and they match (16.15.0)

@Almouro
Copy link
Member

Almouro commented Sep 16, 2022

Hi @fdrcslv, thanks for posting an issue!

This is most definitely because the plugin code is only available in the debug build type (all the code is in the debug folder)

This plugin is a bit particular because I had added an actual React Native native module to make sure autolinking would work (quite ironic since it's not working in your case 😥). So to make sure the Flipper plugin code would not be added in production, that's why it's only present for the debug build type.

A quick fix could be to have a postinstall script that just does something like cp -R node_modules/react-native-flipper-performance-plugin/android/src/debug node_modules/react-native-flipper-performance-plugin/android/src/debugtwo/

I'm curious though, what's the reason for creating a debugtwo build type which is like release? 🤔

@whoami-shubham
Copy link

Hi @fdrcslv

in /android/settings.gradle

include ':flipper-plugin-rn-performance-android'
project(':flipper-plugin-rn-performance-android').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-flipper-performance-plugin/android')

and in ./android/app/build.gradle :

debugImplementation project(':flipper-plugin-rn-performance-android')

I guess this worked for me for manual linking

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants