0

herehere 안내를 따르기 위해 최선을 다했습니다. Android 디버그 빌드 (react-native run-android)는 안드로이드 에뮬레이터와 내 장치에서 예상대로 실행됩니다. 즉, 새로 설치하거나 업데이트 할 때마다 JS 파일을 다시로드합니다. 그러나 릴리스 빌드 (react-native run-android --variant=release)를 설치하면 앱의 첫 화면이 표시되고 앱 기능이 작동하지 않습니다. iOS에서 설치를 시도하지 않았습니다. 그것은 codepush에서 JS 파일을로드하지 않는 것 같습니다. (에뮬레이터의 릴리스 빌드를 설치하는 동안) 나는 로그 파일을 검사 할 때,이 라인에 달려 :React Native CodePush Android 출시 빌드가 없습니다. JS 파일로드

[CodePush] Loading JS bundle from "assets://index.android.bundle" 

내가 찾으 릴리스 빌드가 CodePush를 확인하는 대신 로컬 JS 번들을로드하려고하는 것은 놀라운 일 원격 서버. My React-native 및 react-native-code-push 버전은 0.45.1 및 3.0.1-beta입니다. 나는 준비 및 생산 codepush 서버에 내 코드를 배치했고 그것이 내가 또한 적절하게 내 키를 구성한

code-push deployment ls onetext-Android -k 

을 실행하여 거기에 확인했습니다. 이 10 배 이상을 수행 한 후,이 릴리스 설치에 대한 로그 파일이 실제로 보여 주었다 한 순간이었다

[CodePush] Loading JS bundle from "/data/user/0/com.onetext/files/CodePush/f93a24d467d53.../CodePush/index.android.bundle" 

이 앱은 최신 업데이트를 설치하라고 메시지. 그러나 설치가 끝나자 마자 추락했습니다. 그 순간부터 코드 덤프 서버에서 파일을로드 할 수 없었습니다. 어디서 볼 것인지 또는 디버깅하는 방법에 대한 정보는 많은 도움이 될 것입니다. 내 응용 프로그램은 native-starter-kit으로 시작 지점으로 만들어졌습니다. 여기 내 settings.gradle 파일입니다 :

rootProject.name = 'OneText' 
include ':react-native-onesignal' 
project(':react-native-onesignal').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-onesignal/android') 

include ':react-native-image-picker' 
project(':react-native-image-picker').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-image-picker/android') 

include ':react-native-code-push' 
project(':react-native-code-push').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-code-push/android/app') 

include ':app' 
내 build.gradle 파일의

관련 부품 :

apply from: "../../node_modules/react-native/react.gradle" 
apply from: "../../node_modules/react-native-code-push/android/codepush.gradle" 

def enableSeparateBuildPerCPUArchitecture = false 

def enableProguardInReleaseBuilds = false 

android { 
    compileSdkVersion 23 
    buildToolsVersion "23.0.2" 

    defaultConfig { 
     applicationId "com.onetext" 
     minSdkVersion 16 
     targetSdkVersion 22 
     versionCode 4 
     versionName "1.0.1" 
     ndk { 
      abiFilters "armeabi-v7a", "x86" 
     } 
     manifestPlaceholders = [onesignal_app_id: "xxx", 
             onesignal_google_project_number: "xxx"] 
    } 
    signingConfigs { 
     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 
      } 
     } 
    } 
    splits { 
     abi { 
      reset() 
      enable enableSeparateBuildPerCPUArchitecture 
      universalApk false // If true, also generate a universal APK 
      include "armeabi-v7a", "x86" 
     } 
    } 
    buildTypes { 
     debug { 
      buildConfigField "String", "CODEPUSH_KEY", '""' 
     } 
     releaseStaging { 
      buildConfigField "String", "CODEPUSH_KEY", '"H3ZFJ..."' 
     } 
     release { 
      buildConfigField "String", "CODEPUSH_KEY", '"r0Sx..."' 
      minifyEnabled enableProguardInReleaseBuilds 
      proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro" 
      signingConfig signingConfigs.release 
     } 
    } 
    // applicationVariants are e.g. debug, release 
    applicationVariants.all { variant -> 
     variant.outputs.each { output -> 
      // For each separate APK per architecture, set a unique version code as described here: 
      // http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits 
      def versionCodes = ["armeabi-v7a":1, "x86":2] 
      def abi = output.getFilter(OutputFile.ABI) 
      if (abi != null) { // null for the universal-debug, universal-release variants 
       output.versionCodeOverride = 
         versionCodes.get(abi) * 1048576 + defaultConfig.versionCode 
      } 
     } 
    } 
} 

dependencies { 
    compile project(':react-native-onesignal') 
    compile project(':react-native-image-picker') 
    compile project(':react-native-code-push') 
    compile fileTree(dir: "libs", include: ["*.jar"]) 
    compile "com.android.support:appcompat-v7:23.0.1" 
    compile "com.facebook.react:react-native:+" // From node_modules 
} 

// Run this once to be able to run the application with BUCK 
// puts all compile dependencies into folder libs for BUCK to use 
task copyDownloadableDepsToLibs(type: Copy) { 
    from configurations.compile 
    into 'libs' 
} 

MainApplication.java :

package com.onetext; 

import android.app.Application; 

import com.facebook.react.ReactApplication; 
import com.geektime.rnonesignalandroid.ReactNativeOneSignalPackage; 
import com.microsoft.codepush.react.CodePush; 
import com.facebook.react.ReactNativeHost; 
import com.facebook.react.ReactPackage; 
import com.facebook.react.shell.MainReactPackage; 
import com.facebook.soloader.SoLoader; 
import com.imagepicker.ImagePickerPackage; 

import java.util.Arrays; 
import java.util.List; 

public class MainApplication extends Application implements ReactApplication { 

    private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) { 

    @Override 
    protected String getJSBundleFile() { 
     return CodePush.getJSBundleFile(); 
    } 

    @Override 
    public boolean getUseDeveloperSupport() { 
     return BuildConfig.DEBUG; 
    } 

    @Override 
    protected List<ReactPackage> getPackages() { 
     return Arrays.<ReactPackage>asList(
      new MainReactPackage(), 
      new ReactNativeOneSignalPackage(), 
      new CodePush(BuildConfig.CODEPUSH_KEY, MainApplication.this, BuildConfig.DEBUG), // Add/change this line. 
      new ImagePickerPackage() 
    ); 
    } 
    }; 

    @Override 
    public ReactNativeHost getReactNativeHost() { 
    return mReactNativeHost; 
    } 

    @Override 
    public void onCreate() { 
    super.onCreate(); 
    SoLoader.init(this, /* native exopackage */ false); 
    } 
} 

답변

0

비 디버그 응용 프로그램 항상 요구 CodePush를 사용하는 경우에도 JS 번들을 포함시킬 수 있습니다. CodePush의 동기화/업데이트/확인 설치 기능은 모두 Java 또는 ObjC/Swift가 아닌 JS에서 호출됩니다 (이 응용 프로그램은 codePush 고차원 구성 요소를 사용하여 AppRegistry에 등록 된 구성 요소를 래핑하거나 응용 프로그램에서 codePush.sync() 함수를 호출합니다) 또는 하위 레벨 기능을 사용하여 업데이트 확인 및 업데이트 설치).

이 질문을 쓰는 시점에 jsbundle을 재 작성하지 않았으므로 표시되는 버전이 최신이 아니며 CodePush와의 통합이 포함되지 않았을 가능성이 매우 높습니다. 모두 따라서 CodePush에 게시 된 업데이트도 확인하지 않습니다.

요약 - Android jsbundle을 빌드하고 릴리스 빌드를 다시 설치하면 모든 것이 작동합니다.