Code Monkey home page Code Monkey logo

Comments (7)

shwanton avatar shwanton commented on July 23, 2024 3

I confirmed this issue by checking the generated MainActivity Class name here. It was returning the entire identifier which included the applicationIdSuffix. (com.example.foo.beta)

I have a fix which requires exposing the defaultConfig.applicationId from the gradle file. Since I already had this value from react native config, I just had to look it up the applicationId inside RNBootSplashActivity.java and use that to create the Class name.

I thought I could use the BuildConfig.APPLICATION_ID, however that value returns the id for the library bundle, not the root RN app. I ended up with a solution based on this SO post

app/build.gradle

def appId = "com.example.foo"

defaultConfig {
   applicationId appId
   ...
   resValue "string", "build_config_package", appId
}

RNBootSplashActivity.java

int resId = this.getResources().getIdentifier("build_config_package", "string", this.getPackageName());
Intent intent = new Intent(this, Class.forName(this.getString(resId) + ".MainActivity"));

I'm not sure this is the best/cleanest solution, since it requires an addition to the app/build.gradle file. But it does fix this issue.

from react-native-bootsplash.

zoontek avatar zoontek commented on July 23, 2024 3

@andrewkslv #16 seems to fix the issue. I will make a new release with it today!

from react-native-bootsplash.

shwanton avatar shwanton commented on July 23, 2024

I'm seeing this same behavior. When I try to build for a specific environment/flavor, the splash screen will dismiss itself the first time after launched by the gradle task. However, when I manually launch the app the splash screen hangs and the js bundle never loads. I'm using an applicationIdSuffix for dev & staging. Both of those have the issue however my production build which just uses the plain bundleId works fine & can be relaunched without hanging.

    buildTypes {
        debug {
            signingConfig signingConfigs.debug
        }
        release {
            minifyEnabled enableProguardInReleaseBuilds
            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
        }
    }
    flavorDimensions "version"
    productFlavors {
        development {
            dimension "version"
            applicationIdSuffix ".dev"
        }
        staging {
            dimension "version"
            applicationIdSuffix ".beta"
        }
        production {
            dimension "version"
        }
    }

from react-native-bootsplash.

shwanton avatar shwanton commented on July 23, 2024

@zoontek Is multiple environments something you would like to support in this library? I can add a PR with an updated example. It will add a couple more steps to the android process. The biggest change is that you can't fun react-native run-android by itself anymore, you will have to pass the variant as well:

react-native run-android --variant=DevelopmentDebug

from react-native-bootsplash.

zoontek avatar zoontek commented on July 23, 2024

@shwanton Your issue seems related to #8 Will the meta-data solution be good enough?

What do you mean by supporting multiple environments? Displaying a different splash screen per env variant?

from react-native-bootsplash.

andrewkslv avatar andrewkslv commented on July 23, 2024

I bump into the same issue since I'm using applicationIdSuffix for having multiple application instances at the same time on the phone.

from react-native-bootsplash.

shwanton avatar shwanton commented on July 23, 2024

Just tried that fork out and it works great!
Much better solution than the one I proposed.
Thank you much!

from react-native-bootsplash.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.