buttercup / buttercup-mobile

:iphone: React-Native mobile application for Buttercup
https://buttercup.pw
GNU General Public License v3.0
399 stars 71 forks source link

#129 - Remove res assets copied from previous version of RN #131

Closed se1exin closed 5 years ago

se1exin commented 5 years ago

This PR simply removes all images found in android/app/src/main/res/** that are provided from node_modules or the buttercup-mobile javascript base. Most of these assets were added in either https://github.com/buttercup/buttercup-mobile/commit/6edc7e856e0be728fa33c9c8609d93ad4f7b1458 or https://github.com/buttercup/buttercup-mobile/commit/3b9319d0cfafedf8960a41f3d18b59c1bd80458b, however the updates in RN 0.57 core no longer require these assets to be copied to res and are now causing the conflicts mentioned in #129

perry-mitchell commented 5 years ago

Thanks for this @se1exin! I believe the issue also lies in our release process. Would you have any advice on that?

We currently perform the following to release on Android:

  1. We run npm run build:android, which is actually running: react-native bundle --platform android --dev false --entry-file index.android.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res
  2. We generate a signed APK from Android Studio (this step fails - like in #129)
se1exin commented 5 years ago

@perry-mitchell What is the reasoning behind Step 1 (the react-native bundle step) in your release process? I'm guessing it is from pre RN 0.57? FYI the RN team and community have put in a lot of work on the Android/Gradle side this year, and in my experience I find that everything works perfectly out-of-the-box since 0.57 with just using gradle - as it also takes care of all the RN packing steps as well.

I just use a simple cd android && ./gradlew assembleRelease && cd .. from the command line to build for release, or directly generate a signed APK in Android Studio as per your Step 2, but without requiring Step 1. I've tested this on buttercup-mobile and it works fine as well.

Keep in mind that the CLI approach won't build a signed release APK as your app/build.gradle does not include any signing config. However, this is actually quite simple to configure with local gradle properties or environment variables to keep the your keystore secrets out of source control.

Example signingConfigs section from a project:

// File android/app/build.gradle
android {
    // ... other values

    buildTypes {
        debug {
            signingConfig signingConfigs.debug
        }
        release {
            // ... other values

            signingConfig signingConfigs.release
        }
    }
    signingConfigs {
        debug {
            // I usually use an explicit dummy keystore for debug builds
            storeFile file("debug-keystore.jks")
            storePassword "password"
            keyAlias "keystore"
            keyPassword "password"
        }
        release {
            if (project.hasProperty('APPNAME_KEYSTORE_FILE')) {
                /**
                 * These key/values are stored outside the repo in ~/.gradle/gradle.properties
                 * The actual Keystore file is stored in android/app and .gitignored
                 **/ 
                storeFile file(APPNAME_KEYSTORE_FILE)
                storePassword APPNAME_KEYSTORE_PASSWORD
                keyAlias APPNAME_KEYSTORE_ALIAS
                keyPassword APPNAME_KEYSTORE_PASSWORD
            } else if (System.getenv("BITRISE_IO") == "true") {
                /**
                 * I use bitrise CI for some React Native projects, environment variables
                 * are used instead of gradle.properties. The keystore file is injected into
                 * the build machine at the location below as a pre-build step
                 **/ 
                storeFile file(System.getenv("HOME") + "/keystores/keystore.jks")
                storePassword System.getenv("BITRISEIO_ANDROID_KEYSTORE_PASSWORD")
                keyAlias System.getenv("BITRISEIO_ANDROID_KEYSTORE_ALIAS")
                keyPassword System.getenv("BITRISEIO_ANDROID_KEYSTORE_PRIVATE_KEY_PASSWORD")
            }
        }
    }
}
perry-mitchell commented 5 years ago

What is the reasoning behind Step 1 (the react-native bundle step) in your release process? I'm guessing it is from pre RN 0.57?

Yep, it was pre-0.57.. I think we started with 0.44.

I just use a simple cd android && ./gradlew assembleRelease && cd .. from the command line to build for release, or directly generate a signed APK in Android Studio as per your Step 2

Yeah I think for now we'll try to stick with generating a signed APK from the studio GUI. In the long term we'd probably want to go for the configuration you shared - Thanks for that!

perry-mitchell commented 5 years ago

I'm going to merge this.. Cheers!