简体   繁体   中英

React Native release apk doesn't match app when running react-native run-android

I'm currently building my first React Native app. I set up a release in Play Console for Internal Testing and was able to push my first signed apk. Since then, we've made bug fixes that are now merged into master. When I try to generate a new release by running:

cd android && ./gradlew assembleRelease

and upload as a new release, I don't see any of the new changes after updating my app via the Play Store.

I've tried running

react-native bundle --entry-file ./index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res/

before generating a new release, but I still don't see the changes.

Running react-native run-android while my device is hooked up with USB Debugging works fine, as well as in any emulator. I just can't figure out why my APK doesn't match the code generated on my local device.

Is there a step that I'm missing that's keeping my APK from representing the latest changes on master when I build?

Using React Native 0.56

Updated to add my Gradle Config:

 // android/app/build.grade
 signingConfigs {
    release {
        if(project.hasProperty('MY_RELEASE_STORE_FILE')) {
            storeFile file(MY_RELEASE_STORE_FILE)
            storePassword pass
            keyAlias MY_RELEASE_KEY_ALIAS
            keyPassword pass
        }
    }
}

you should update the android\\app\\build.gradle file under the app folder by placing this code under the defaultConfig

signingConfigs {
    debug {
        storeFile file('debug.keystore')
        keyAlias 'androiddebugkey'
        keyPassword 'android'
        storePassword 'android'
    }

    release {
        if (project.hasProperty('MYAPP_RELEASE_STORE_FILE')) {
            storeFile file(MYAPP_RELEASE_STORE_FILE)
            storePassword MYAPP_RELEASE_STORE_PASSWORD
            keyAlias MYAPP_RELEASE_KEY_ALIAS
            keyPassword MYAPP_RELEASE_KEY_PASSWORD
        }
    }
}

Also within android\\app\\build.gradle, ensure your buildTypes for release includes the correct signingConfig line.

buildTypes {
    debug {
        signingConfig signingConfigs.debug
    }
    release {
        signingConfig signingConfigs.release
        ...
        ...
    }
}

Just like that and update your gradle.properties file with these properties

MYAPP_RELEASE_STORE_FILE="Key Store Name"
MYAPP_RELEASE_KEY_ALIAS="Key Store alias"
MYAPP_RELEASE_STORE_PASSWORD="Key Store Password"
MYAPP_RELEASE_KEY_PASSWORD="Key Password"

Try to change

--entry-file ./index.js

to

--entry-file ./index.android.js

maybe its late but I hope this save someone : It looks like you have to rebundle it whenever you add new module or asset

react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM