在本机反应中添加产品风味的正确方法是什么?

时间:2019-02-27 14:43:06

标签: android react-native fastlane android-productflavors

在我的本机项目中添加了产品风味之后,发布后(即刚启动),该应用程序总是崩溃。

我试图打开android studio来查看Logcat,但是由于该应用在启动时崩溃,所以我什么也看不到。

这是我的app / build.gladle的一部分:

project.ext.envConfigFiles = [
    dev: ".env.local",
    production: ".env.production",
    staging: ".env.staging"
]

apply from: project(':react-native-config').projectDir.getPath() + "/dotenv.gradle"

android {
    flavorDimensions "default"

    defaultConfig {
        applicationId "com.company"
        applicationIdSuffix ""
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        ndk {
            abiFilters "armeabi-v7a", "x86"
        }
        resValue "string", "build_config_package", "com.company"
    }
    buildTypes {
        release {
            minifyEnabled enableProguardInReleaseBuilds
            proguardFiles getDefaultProguardFile("proguard-android.txt"), 
            "proguard-rules.pro"
        }
    }
    productFlavors {
        dev {
            minSdkVersion rootProject.ext.minSdkVersion
            targetSdkVersion rootProject.ext.targetSdkVersion
            applicationIdSuffix ".dev"
            versionNameSuffix "-dev"
        }
        staging {
            minSdkVersion rootProject.ext.minSdkVersion
            targetSdkVersion rootProject.ext.targetSdkVersion
            applicationIdSuffix ".staging"
            versionNameSuffix "-staging"
        }
        production {
        }
    }
}

我也在使用fastLane部署我的应用程序,如下所示:

lane :staging do |options|
gradle(task: 'clean')
gradle(
  task: "assemble",
  flavor: "Staging",
  build_type: "Release",
  print_command: false,
  properties: {
    "android.injected.signing.store.file" => "file.keystore",
    "android.injected.signing.store.password" => options[:storepass],
    "android.injected.signing.key.alias" => options[:keyalias],
    "android.injected.signing.key.password" => options[:keypass],
  }
)
upload_to_play_store(track: 'alpha')
end

1 个答案:

答案 0 :(得分:0)

尝试重命名productFlavors,例如:

dev更改为devTest