lisong / code-push-server

CodePush service is hot update services which adapter react-native-code-push and cordova-plugin-code-push - 热更新
MIT License
1.84k stars 543 forks source link

无法上传index.android.bundle #6

Closed WangJintong closed 8 years ago

WangJintong commented 8 years ago

我使用 code-push release ... ./bundle/index.android.bundle .... 会提示上传格式不对。 我使用 code-push release ... ./bundle .... 会提示 it must be publish it by ios type 。

请教一下,应该如何使用 code-push release 。

谢谢。

lisong commented 8 years ago

推荐使用code-push release-react 该命令自动帮你打包

lisong commented 8 years ago

没有必要使用code-push release,参数多,而且容易出错。react-native不同平台bundle的包不一样,所以一个命令发布更好,防止iOS的包发到andriod上

WangJintong commented 8 years ago

我使用 code-push release-react myapp android ,同样的错误出现: it must be publish it by ios type .

lisong commented 8 years ago

之前 myapp有发布过没?项目名字必须要以 ios 或者android 为前缀,然后项目第一次发布后平台类型确认定了是不能更改的,否则android和ios平台版本会混乱

$ code-push release-react ios_myapp ios
$ code-push release-react android_myapp android

不同平台必须单独创建应用

WangJintong commented 8 years ago

这样是不是不太合理?本身react native创建的应用,是在项目内部区分平台的,单独创建应用,岂不是意味着rn自创建的应用内,某个平台的代码是多余的?

lisong commented 8 years ago

不需要单独创建rn项目,rn项目还是一个。可以参考 https://github.com/lisong/code-push-demo-app 发布的时候在code-push-server上创建两个应用,react-native bundle的时候也是区分平台的,android打包规则和ios不一样,这是平台差异化。 本身react native创建的应用,是在项目内部区分平台的,但是react-native 发布到不同平台时候,只会打包特定平台的文件。

$ react-native bundle --entry-file demo/index.js --bundle-output ./ios/bundle/index.ios.jsbundle --platform ios --assets-dest ./ios/bundle --dev false

$ react-native bundle --entry-file demo/index.js --bundle-output ./ios/bundle/index.android.jsbundle --platform android --assets-dest ./ios/bundle --dev false

可以试验一下, index.ios.jsbundle 和 index.android.jsbundle 文件内容是不一样的。

WangJintong commented 8 years ago

我临时将 pubType 强制为 android ,server 逻辑是否可正常工作?这种状态下我可以publish bundle文件,手机端可以发起同步请求,但是并没能完成update动作。 GET /updateCheck?deploymentKey=.....&appVersion=1.0.0&packageHash=&isCompanion=&label=&clientUniqueId=.... 200 136.051ms -340

lisong commented 8 years ago

说明没有检查到更新,你可以新建一个应用,这个限制其实还是蛮有用的,避免用户将andriod类型的bundle误更新到iOS机器上,可以浏览器直接请求/updateCheck?deploymentKey=.....&appVersion=1.0.0&packageHash=&isCompanion=&label=&clientUniqueId= 地址,返回结果是?

lisong commented 8 years ago

你这信息没有办法定位是服务器端问题还是客户端问题,要不你用这个 https://github.com/lisong/code-push-demo-app 例子,连接你搭好的服务器,确认好服务器端是ok后,再找找啥问题,客户端集成应该没有啥区别。react-native-code-push 客户端更新也有几种配置,我也踩过雷。例如:“我把更新检测代码写到异步进程里面,以为好些。但是每次更新都自动回顾回去。”

WangJintong commented 8 years ago

浏览器直接请求 updateCheck 的返回结果是: {"updateInfo":{"downloadURL":"http://localhost:3000/download/FnrDpJniIUUPw1KeBWSE1LCtFjyR","description":"","isAvailable":true,"isMandatory":false,"appVersion":"1.0.0","packageHash":"3ed5069c5f8e5ef002464c7ef963653c222a4af4fc08b56ba24b33ffb088d713","label":"v1","packageSize":163416,"updateAppVersion":false,"shouldRunBinaryVersion":false}}

WangJintong commented 8 years ago

我试着编译了你的 code-push-demo-app 例子 ,还没能编译成功,不过我比对了你的demo和我的demo代码,只在一个地方存在差异: new CodePush 时,我的第二个参数用了MainApplication.this,你的是getApplicationContext()。

lisong commented 8 years ago

按照返回结果是有更新包下载的,只是下载地址配置有问题,如果你用的android模拟器,你需要执行 adb reverse tcp:3000 tcp:3000 代理一下。最佳修改方案参照 https://github.com/lisong/code-push-server/issues/5 配置一下

WangJintong commented 8 years ago

修改 config/config.js 文件中downloadUrl的配置localhost改成你机器的IP地址或者域名之后,OK。

lisong commented 8 years ago

正确使用code-push热更新

acmelacross commented 5 years ago

var os = require('os');

var config = {}; config.development = { // Config for database, only support mysql. db: { username: process.env.RDS_USERNAME || "root", password: process.env.RDS_PASSWORD || '1111', database: process.env.DATA_BASE || "codepush", host: process.env.RDS_HOST || "127.0.0.1", port: process.env.RDS_PORT || 3306, dialect: "mysql", logging: false, operatorsAliases: false, }, // Config for qiniu (http://www.qiniu.com/) cloud storage when storageType value is "qiniu". qiniu: { accessKey: "", secretKey: "", bucketName: "", downloadUrl: "" // Binary files download host address. }, // Config for upyun (https://www.upyun.com/) storage when storageType value is "upyun" upyun: { storageDir: process.env.UPYUN_STORAGE_DIR, serviceName: process.env.UPYUN_SERVICE_NAME, operatorName: process.env.UPYUN_OPERATOR_NAME, operatorPass: process.env.UPYUN_OPERATOR_PASS, downloadUrl: process.env.DOWNLOAD_URL, }, // Config for Amazon s3 (https://aws.amazon.com/cn/s3/) storage when storageType value is "s3". s3: { accessKeyId: process.env.AWS_ACCESS_KEY_ID, secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY, sessionToken: process.env.AWS_SESSION_TOKEN, //(optional) bucketName: process.env.BUCKET_NAME, region: process.env.REGION, downloadUrl: process.env.DOWNLOAD_URL, // binary files download host address. }, // Config for Aliyun OSS (https://www.aliyun.com/product/oss) when storageType value is "oss". oss: { accessKeyId: "", secretAccessKey: "", endpoint: "", bucketName: "", prefix: "", // Key prefix in object key downloadUrl: "", // binary files download host address. }, // Config for tencentyun COS (https://cloud.tencent.com/product/cos) when storageType value is "oss". tencentcloud: { accessKeyId: "", secretAccessKey: "", bucketName: "", region: "", downloadUrl: "", // binary files download host address. }, // Config for local storage when storageType value is "local". local: { // Binary files storage dir, Do not use tmpdir and it's public download dir. storageDir: process.env.STORAGE_DIR || "/Users/dev02/Desktop/working/demo/pushServer/storage", // Binary files download host address which Code Push Server listen to. the files storage in storageDir. downloadUrl: process.env.LOCAL_DOWNLOAD_URL || "http://127.0.0.1:3000/download", // public static download spacename. public: '/download' }, jwt: { // Recommended: 63 random alpha-numeric characters // Generate using: https://www.grc.com/passwords.htm // tokenSecret: process.env.TOKEN_SECRET ||'INSERT_RANDOM_TOKEN_KEY' MieNU6ugOdvfa8fG56kCL9F8VkCTy05vNVvMjrEiMLhEqkZzh9vIFtO2JlRxkKH tokenSecret:'MieNU6ugOdvfa8fG56kCL9F8VkCTy05vNVvMjrEiMLhEqkZzh9vIFtO2JlRxkKH' }, common: { /*

config.development.log4js = { appenders: {console: { type: 'console'}}, categories : { "default": { appenders: ['console'], level:'error'}, "startup": { appenders: ['console'], level:'info'}, "http": { appenders: ['console'], level:'info'} } }

config.production = Object.assign({}, config.development); module.exports = config;

acmelacross commented 5 years ago

我也遇到了同样的问题 it must be publish it by ios type
可是我的downloadUrl: process.env.LOCAL_DOWNLOAD_URL || "http://127.0.0.1:3000/download", 已经改了啊