本文介绍了React-Native productFlavors(错误类型3:活动类不存在)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的Android应用中使用2个productFlavors:livestaging.

I want to use 2 productFlavors for my Android App: live and staging.

app/build.grandle中,我这样定义它们:

In app/build.grandle I defined them like this:

defaultConfig {
    applicationId "com.some.id"
    minSdkVersion 16
    targetSdkVersion 22
    versionCode 1
    versionName "1.0"
    ndk {
        abiFilters "armeabi-v7a", "x86"
    }
}
splits {...}
buildTypes {
    release {
        minifyEnabled enableProguardInReleaseBuilds
        proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
    }
    debug {
        debuggable true
        minifyEnabled false
        proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
    }

    productFlavors {
        live {
            applicationId "com.some.id"
        }
        staging {
            applicationId "com.some.id.staging"
        }
    }
}

现在,当我运行react-native run-android --variant=liveDebug时,一切正常,但是当我尝试运行react-native run-android --variant=stagingDebug时,出现错误:

Now when I run react-native run-android --variant=liveDebug everything works just fine but when I try to run react-native run-android --variant=stagingDebug i get the error:

Installed on 1 device.

BUILD SUCCESSFUL

Total time: 11.824 secs
Starting the app on 192.168.56.101:5555 (/usr/local/opt/android-sdk/platform-tools/adb -s 192.168.56.101:5555 shell am start -n com.somepackage/.MainActivity)...
Starting: Intent { cmp=com.somepackage/.MainActivity }
Error type 3
Error: Activity class {com.somepackage/com.somepackage.MainActivity} does not exist.

如输出所示,该应用程序已安装在设备上,但是为什么说MainActivity不存在?我猜这是由于不同的applicationId引起的,尽管根据本指南,它是正确的

As the output says, the App was installed on the device but why does it say that MainActivity does not exist ? I guess it is due to the different applicationId although it is correct according to this guide

我该如何解决?

提前谢谢!

推荐答案

我遇到了同样的问题,我通过将appIdSuffix添加到react-native run命令来解决.

I had the same issue and I solve by adding the appIdSuffix to the react-native run command.

react-native run-android --variant variantDebug --appIdSuffix suffix

这篇关于React-Native productFlavors(错误类型3:活动类不存在)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-26 06:28