React Native items packaged offline Android apk

React Native items packaged offline Android apk

1, generated signature key

1): Perform generate command (need to be performed under jdk bin directory)

#生成命令
keytool -genkey -v -keystore my-release-key.keystore -alias my-key-alias -keyalg RSA -keysize 2048 -validity 10000

2): Fill in the area of ​​information and

3): key generation is completed there will be a my-release-key.keystore key store file

Here Insert Picture Description

2, the global variable configuration gradle

  • Creating gradle.properties file \ Users \ username under \ .gradle, add the following: in C:
MYAPP_RELEASE_STORE_FILE=my-release-key.keystore
MYAPP_RELEASE_KEY_ALIAS=my-key-alias
MYAPP_RELEASE_STORE_PASSWORD=您设置的密码
MYAPP_RELEASE_KEY_PASSWORD=您设置的密码

Here Insert Picture Description

3, give yourself an RN configuration signature project

1): The signature file my-release-key.keystore on, react android native project \ app down.

Here Insert Picture Description

2): edit android / build.gradle file in the app, add the following:

signingConfigs {
          release {
              storeFile file(MYAPP_RELEASE_STORE_FILE)
              storePassword MYAPP_RELEASE_STORE_PASSWORD
              keyAlias MYAPP_RELEASE_KEY_ALIAS
              keyPassword MYAPP_RELEASE_KEY_PASSWORD
          }
      }
    
      buildTypes {
          release {
              minifyEnabled enableProguardInReleaseBuilds
              proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
              signingConfig signingConfigs.release
          }
      }

Here Insert Picture Description

3): edit android / gradle.properties file, add the following:

  MYAPP_RELEASE_STORE_FILE=my-release-key.keystore
  MYAPP_RELEASE_KEY_ALIAS=my-key-alias
  MYAPP_RELEASE_STORE_PASSWORD=您设置的密码
  MYAPP_RELEASE_KEY_PASSWORD=您设置的密码

Here Insert Picture Description

4, packing APk

  • After the package will apk android / app / build / outputs / apk directory in
#进入安卓目录
cd android

#清理缓存
gradlew clean 

#执行打包
gradlew assembleRelease

Here Insert Picture Description

Guess you like

Origin blog.csdn.net/weixin_44187730/article/details/86492907