简体   繁体   English

Expo React-Native Android 版本未更新 Google Play 的版本代码

[英]Expo React-Native Android build not updating Version Code for Google Play

I built a React-Native android app and uploaded to Google Play, which worked fine.我构建了一个 React-Native android 应用程序并上传到 Google Play,效果很好。

Now I have a new build I am trying to upload (had no issues uploading to itunes Connect), and Google Play is giving me this error: "You need to use a different version code for your APK or Android App Bundle because you already have one with version code 1."现在我有一个我正在尝试上传的新版本(上传到 iTunes Connect 没有问题),Google Play 给我这个错误:“你需要为你的 APK 或 Android App Bundle 使用不同的版本代码,因为你已经有了一个版本代码为 1。”

After each build, I have updated the version in app.json, and I have tried updating the version in package.json as well.每次构建后,我都会更新 app.json 中的版本,并且我也尝试过更新 package.json 中的版本。 I've done a directory-wide search for 'versionCode' and there are no instances.我已经对“versionCode”进行了目录范围的搜索,但没有实例。 A directory-wide search of 'version' turned up over 2,000 results, and I scrolled through all of them, and did not see anything specific to android build.对“版本”的目录范围搜索出现了 2,000 多个结果,我滚动浏览了所有结果,并没有看到任何特定于 android build 的内容。 And I did NOT have an issue with iOS build.而且我对 iOS 构建没有任何问题。

I have tried publishing the app first using Max Expo XDE, and I am building it in command line with "exp build:android".我曾尝试使用 Max Expo XDE 首先发布该应用程序,并且我正在使用“exp build:android”在命令行中构建它。

I have the following in my app.json:我的 app.json 中有以下内容:

{
  "expo": {
    "name": "Placeholder",
        "sdkVersion": "27.0.0",
        "privacy": "unlisted",
        "orientation": "portrait",
        "icon": "./assets/img/AppIcon.png",
    "version": "0.3.4",
    "ios": {
      "bundleIdentifier": "com.placeholder.placeholder"
    },
    "android": {
      "package": "com.placeholder.placeholder"
    }
  }
}

and my package.json is as follows (and npm install has been run):我的 package.json 如下(并且 npm install 已经运行):

{
  "name": "placeholder",
  "version": "0.2.0",
  "private": true,
  "devDependencies": {
    "jest-expo": "~27.0.0",
    "react-native-scripts": "1.14.0",
    "react-test-renderer": "16.3.1"
  },
  "main": "./node_modules/react-native-scripts/build/bin/crna-entry.js",
  "scripts": {
    "start": "react-native-scripts start",
    "eject": "react-native-scripts eject",
    "android": "react-native-scripts android",
    "ios": "react-native-scripts ios",
    "test": "jest"
  },
  "jest": {
    "preset": "jest-expo"
  },
  "dependencies": {
    "axios": "^0.18.0",
    "expo": "^27.0.1",
    "native-base": "^2.4.3",
    "react": "16.3.1",
    "react-native": "https://github.com/expo/react-native/archive/sdk-27.0.0.tar.gz",
    "react-native-svg": "^6.3.1",
    "react-navigation": "^2.0.0",
    "redux-thunk": "^2.2.0",
    "socket.io-client": "^2.1.0"
  }
}

I also experience this issue, I resolved it by adding versionCode to my app.json under android.我也遇到了这个问题,我通过在android下的app.json中添加versionCode解决了这个问题。 For instance,例如,

"android": { “安卓”: {
"versionCode": 2 “版本代码”:2
} }

Notice that the '2' does not have quotation marks.请注意,“2”没有引号。

if you need know more about versionCode, see this documentation.如果您需要了解有关 versionCode 的更多信息,请参阅此文档。

versionCodeOnAndroid versionCodeOnAndroid

需要特别将“versionCode”添加到app.json的“android”部分......

If you are using vanilla react native (without expo) then changing app.json won't work.如果您使用的是原生反应原生(没有博览会),那么更改 app.json 将不起作用。 You have to rather go to build.gradle and increase both versionCode and versionName by 1您必须宁愿去 build.gradle 并将 versionCode 和 versionName 都增加 1

If you are using expo bare workflow then changing app.json won't work.如果您使用的是 expo 裸工作流,那么更改 app.json 将不起作用。 You have to rather go to android > app > build.gradle and increase both versionCode and versionName by 1你必须宁愿去android > app > build.gradle并将 versionCode 和 versionName 都增加 1

while building and delivering to testflight you need to update version before build.在构建和交付到 testflight 时,您需要在构建之前更新版本。 If you're annoyed with this as much as I am, you could use the nodejs simple script, lets call it build.js:如果你和我一样对此感到恼火,你可以使用 nodejs 简单脚本,我们称之为 build.js:

'use strict';
const fs = require('fs');
const { exec } = require('child_process');

let config = require('./app.json');

let t = new Date().getTime();
let backup = 'app.' + t + '.json';

// make some backup
fs.writeFile(backup, JSON.stringify(config)); 

let v = config.expo.version;
v = v.split('.');
let x = parseInt(v[v.length - 1]);

// add to last part of version, update to your needs
v[v.length - 1] = (x + 1); 
config.expo.version = v.join('.');

// write new config
fs.writeFile('app.json', JSON.stringify(config, null, 2));

According to Deploying to App Stores 1 , you need to follow the instructions from Building Standalone Apps.根据 Deploying to App Stores 1 ,您需要按照构建独立应用程序中的说明进行操作。 The "versionCode" is indeed referenced in 2 and it is an option specific to the Android section: 3 . “versionCode”确实在2中引用,它是特定于 Android 部分的选项: 3

Using these configurations worked for me:使用这些配置对我有用:

{
  "expo": {
    "name": "APP_NAME",
    "description": "APP_DESCRIPTION",
    "slug": "SLUG_NSME",
    "version": "1.1.0",
    "orientation": "portrait",
    "updates": {
      "fallbackToCacheTimeout": 0
    },
    "assetBundlePatterns": ["**/*"],

    "android": {
      "package": "com.company_name.project_name",
      "versionCode": 2 // just change/add this line
    }
  }
}

Find complete Guide here: expo documentation and Play Store Documentation .在此处查找完整指南: expo 文档Play 商店文档

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 React Native Android构建版本代码未更新 - React native android build version code not updating 谷歌 Play 商店的 react-native android 应用程序中的 64 位版本问题 - 64 bit version issue in react-native android app by google play store React-native Expo构建:“非法选项:-jarfile”尝试为Google API密钥android生成SHA1证书时出错 - React-native Expo build: “Illegal option: -jarfile” Error when trying to generate SHA1 certificate for Google API key android react-native expo android macos问题 - react-native expo android macos issue 将裸工作流 expo React-Native 应用程序发布到 Google Play,该应用程序之前在托管工作流中发布 - Publishing a bare-workflow expo React-Native app to Google Play which was previously published in the managed workflow React-Native 使用 expo sdk 播放视频 - React-Native play video using expo sdk Google Play 控制台未在来自 React Native expo 的捆绑包中正确检测到我的 SDK 版本 - Google play console not detecting my SDK version correctly in bundles from react native expo React Native 版本不匹配。 无法在 Android Studio 中生成构建,但通过 VS 代码 react-native run-android 正常运行 - React Native Version mismatch. Cannot generate build in Android Studio but runs properly through VS code react-native run-android 带有react-native版本0.57的Google admob - Google admob with react-native version 0.57 React-native 不会更新 android 中的更改 - React-native is not updating changes in android
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM