react-native-navigation icon indicating copy to clipboard operation
react-native-navigation copied to clipboard

Android App stuck on splash screen after adding a product flavor.

Open gjvpaet opened this issue 8 years ago • 3 comments

I don't know if this is an RNN issue or RN issue but when I added two product flavors to my app/build.gradle namely dev and prod the splash screen is stuck in the dev flavor. I added an applicationIdSuffix to the dev flavor ".dev". But it works fine in the prod flavor where I haven't added an applicationIdSuffix.

Here's the product flavors that I added:

defaultConfig {
        applicationId "com.company.example"
        minSdkVersion 16
        targetSdkVersion 22
        versionCode versionMajor * 1000 + versionMinor * 100 + versionPatch
        versionName "${versionMajor}.${versionMinor}.${versionPatch}"
        ndk {
            abiFilters "armeabi-v7a", "x86"
        }
    }
    productFlavors {
        dev {
            applicationId "com.company.example"
            applicationIdSuffix ".dev"
            minSdkVersion 16
            targetSdkVersion 22
            versionCode versionMajor * 1000 + versionMinor * 100 + versionPatch
            versionName "${versionMajor}.${versionMinor}.${versionPatch}"
            ndk {
                abiFilters "armeabi-v7a", "x86"
            }
            resValue "string", "build_config_package", "com.volenday.asiaceoadmin"
        }
        prod {
            applicationId "com.company.example"
            minSdkVersion 16
            targetSdkVersion 22
            versionCode versionMajor * 1000 + versionMinor * 100 + versionPatch
            versionName "${versionMajor}.${versionMinor}.${versionPatch}"
            ndk {
                abiFilters "armeabi-v7a", "x86"
            }
        }
    }

Here's the code of my splash screen:

public class MainActivity extends SplashActivity {
    @Override
    public RelativeLayout createSplashLayout() {
        ImageView imageView = new ImageView(this);
        RelativeLayout parentView = new RelativeLayout(this);

        parentView.setBackgroundColor(Color.parseColor("#505865"));

        String backgroundImage = "examplebg";
        int resId = this.getResources().getIdentifier(backgroundImage, "drawable", this.getPackageName());
        imageView.setImageResource(resId);

        RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(1450, 1450);
        layoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
        layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT);
        
        imageView.setScaleType(ImageView.ScaleType.FIT_CENTER);
        imageView.setLayoutParams(layoutParams);

        parentView.addView(imageView);
        return parentView;
    }
}

Here's the build scripts in my package.json:

"scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start",
    "test": "jest",
    "buildDevDebug": "json -I -f package.json -e 'this.environment=\"staging\"' && react-native run-android --variant=devDebug",
    "buildProdDebug": "json -I -f package.json -e 'this.environment=\"production\"' && react-native run-android --variant=prodDebug",
    "buildDevRelease": "json -I -f package.json -e 'this.environment=\"staging\"' && react-native run-android --variant=devRelease",
    "buildProdRelease": "json -I -f package.json -e 'this.environment=\"production\"' && react-native run-android --variant=prodRelease"
  }

  • React Native Navigation version: 1.1.319
  • React Native version: 0.50.3
  • Platform: Android
  • Device info: Real Device/Marshmallow/Debug

gjvpaet avatar Mar 13 '18 01:03 gjvpaet

@guyca @gjvpaet Have you solved this and how? I'm having the same Issue!

ulfgebhardt avatar Apr 18 '18 17:04 ulfgebhardt

@ulfgebhardt I haven't solved it yet

gjvpaet avatar Apr 18 '18 23:04 gjvpaet

@gjvpaet I did:

Add --variant & --appIdSuffix in the run-android call

    "start:android:dev": "react-native run-android --variant=devDebug --appIdSuffix=dev",
    "start:android:alpha": "react-native run-android --variant=alphaDebug --appIdSuffix=alpha",
    "start:android:beta": "react-native run-android --variant=betaDebug --appIdSuffix=beta",
    "start:android:production": "react-native run-android --variant=productionDebug",

https://github.com/demokratie-live/democracy-client/blob/master/package.json#L12 https://github.com/demokratie-live/democracy-client/blob/master/android/app/build.gradle#L4 https://github.com/demokratie-live/democracy-client/blob/master/android/app/build.gradle#L155

ulfgebhardt avatar May 12 '18 20:05 ulfgebhardt