gpt4 book ai didi

android - React Native 构建在构建除调试/发布之外的新构建类型时失败

转载 作者:行者123 更新时间:2023-12-03 15:27:44 25 4
gpt4 key购买 nike

我正在尝试准备一个暂存版本构建,但我的构建失败了。它给了我一个巨大的错误列表。我已经修改了我的 build.gradle 以添加一个暂存环境。我不确定为什么会发生这种情况,因为我的调试和发布版本工作正常。

我用了yarn android --variant=stagingrelease生成构建并在我的物理 android 设备上运行。使用 React-Native: 0.61.5 .

部分错误如下

FAILURE: Build failed with an exception.

* What went wrong: Could not determine the dependencies of task ':app:preStagingreleaseBuild'.
> Could not resolve all task dependencies for configuration ':app:stagingreleaseRuntimeClasspath'.
> Could not resolve project :@react-native-community_masked-view.
Required by:
project :app
> Unable to find a matching variant of project :@react-native-community_masked-view:
- Variant 'debugApiElements' capability Furry:@react-native-community_masked-view:unspecified:
- Incompatible attributes:
- Required com.android.build.api.attributes.BuildTypeAttr 'stagingrelease' and found incompatible value 'debug'.
- Required org.gradle.usage 'java-runtime' and found incompatible value 'java-api'.
- Other attributes:
- Found com.android.build.api.attributes.VariantAttr 'debug' but wasn't required.
- Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
- Variant 'debugRuntimeElements' capability Furry:@react-native-community_masked-view:unspecified:
- Incompatible attribute:
- Required com.android.build.api.attributes.BuildTypeAttr 'stagingrelease' and found incompatible value 'debug'.
- Other attributes:
- Found com.android.build.api.attributes.VariantAttr 'debug' but wasn't required.
- Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
- Required org.gradle.usage 'java-runtime' and found compatible value 'java-runtime'.
- Variant 'releaseApiElements' capability Furry:@react-native-community_masked-view:unspecified:
- Incompatible attributes:
- Required com.android.build.api.attributes.BuildTypeAttr 'stagingrelease' and found incompatible value 'release'.
- Required org.gradle.usage 'java-runtime' and found incompatible value 'java-api'.
- Other attributes:
- Found com.android.build.api.attributes.VariantAttr 'release' but wasn't required.
- Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
- Variant 'releaseRuntimeElements' capability Furry:@react-native-community_masked-view:unspecified:
- Incompatible attribute:
- Required com.android.build.api.attributes.BuildTypeAttr 'stagingrelease' and found incompatible value 'release'.
- Other attributes:
- Found com.android.build.api.attributes.VariantAttr 'release' but wasn't required.
- Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
- Required org.gradle.usage 'java-runtime' and found compatible value 'java-runtime'.
> Could not resolve project :react-native-bootsplash.
Required by:
project :app
> Unable to find a matching variant of project :react-native-bootsplash:
- Variant 'debugApiElements' capability Furry:react-native-bootsplash:unspecified:
- Incompatible attributes:
- Required com.android.build.api.attributes.BuildTypeAttr 'stagingrelease' and found incompatible value 'debug'.
- Required org.gradle.usage 'java-runtime' and found incompatible value 'java-api'.
- Other attributes:
- Found com.android.build.api.attributes.VariantAttr 'debug' but wasn't required.
- Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
- Variant 'debugRuntimeElements' capability Furry:react-native-bootsplash:unspecified:
- Incompatible attribute:
- Required com.android.build.api.attributes.BuildTypeAttr 'stagingrelease' and found incompatible value 'debug'.
- Other attributes:
- Found com.android.build.api.attributes.VariantAttr 'debug' but wasn't required.
- Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
- Required org.gradle.usage 'java-runtime' and found compatible value 'java-runtime'.
- Variant 'releaseApiElements' capability Furry:react-native-bootsplash:unspecified:
- Incompatible attributes:
- Required com.android.build.api.attributes.BuildTypeAttr 'stagingrelease' and found incompatible value 'release'.
- Required org.gradle.usage 'java-runtime' and found incompatible value 'java-api'.
- Other attributes:
- Found com.android.build.api.attributes.VariantAttr 'release' but wasn't required.
- Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
- Variant 'releaseRuntimeElements' capability Furry:react-native-bootsplash:unspecified:
- Incompatible attribute:
- Required com.android.build.api.attributes.BuildTypeAttr 'stagingrelease' and found incompatible value 'release'.
- Other attributes:
- Found com.android.build.api.attributes.VariantAttr 'release' but wasn't required.
- Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
- Required org.gradle.usage 'java-runtime' and found compatible value 'java-runtime'.
> Could not resolve project :react-native-config.
Required by:
project :app
> Unable to find a matching variant of project :react-native-config:
- Variant 'debugApiElements' capability Furry:react-native-config:unspecified:
- Incompatible attributes:
- Required com.android.build.api.attributes.BuildTypeAttr 'stagingrelease' and found incompatible value 'debug'.
- Required org.gradle.usage 'java-runtime' and found incompatible value 'java-api'.
- Other attributes:
- Found com.android.build.api.attributes.VariantAttr 'debug' but wasn't required.
- Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
- Variant 'debugRuntimeElements' capability Furry:react-native-config:unspecified:
- Incompatible attribute:
- Required com.android.build.api.attributes.BuildTypeAttr 'stagingrelease' and found incompatible value 'debug'.
- Other attributes:
- Found com.android.build.api.attributes.VariantAttr 'debug' but wasn't required.
- Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
- Required org.gradle.usage 'java-runtime' and found compatible value 'java-runtime'.
- Variant 'releaseApiElements' capability Furry:react-native-config:unspecified:
- Incompatible attributes:
- Required com.android.build.api.attributes.BuildTypeAttr 'stagingrelease' and found incompatible value 'release'.
- Required org.gradle.usage 'java-runtime' and found incompatible value 'java-api'.
- Other attributes:
- Found com.android.build.api.attributes.VariantAttr 'release' but wasn't required.
- Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
- Variant 'releaseRuntimeElements' capability Furry:react-native-config:unspecified:
- Incompatible attribute:
- Required com.android.build.api.attributes.BuildTypeAttr 'stagingrelease' and found incompatible value 'release'.
- Other attributes:
- Found com.android.build.api.attributes.VariantAttr 'release' but wasn't required.
- Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
- Required org.gradle.usage 'java-runtime' and found compatible value 'java-runtime'.
> Could not resolve project :react-native-gesture-handler.
Required by:
project :app
> Unable to find a matching variant of project :react-native-gesture-handler:
- Variant 'debugApiElements' capability Furry:react-native-gesture-handler:unspecified:
- Incompatible attributes:
- Required com.android.build.api.attributes.BuildTypeAttr 'stagingrelease' and found incompatible value 'debug'.
- Required org.gradle.usage 'java-runtime' and found incompatible value 'java-api'.
- Other attributes:
- Found com.android.build.api.attributes.VariantAttr 'debug' but wasn't required.
- Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
- Variant 'debugRuntimeElements' capability Furry:react-native-gesture-handler:unspecified:
- Incompatible attribute:
- Required com.android.build.api.attributes.BuildTypeAttr 'stagingrelease' and found incompatible value 'debug'.
- Other attributes:
- Found com.android.build.api.attributes.VariantAttr 'debug' but wasn't required.
- Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
- Required org.gradle.usage 'java-runtime' and found compatible value 'java-runtime'.
- Variant 'releaseApiElements' capability Furry:react-native-gesture-handler:unspecified:
- Incompatible attributes:
- Required com.android.build.api.attributes.BuildTypeAttr 'stagingrelease' and found incompatible value 'release'.
- Required org.gradle.usage 'java-runtime' and found incompatible value 'java-api'.
- Other attributes:
- Found com.android.build.api.attributes.VariantAttr 'release' but wasn't required.
- Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
- Variant 'releaseRuntimeElements' capability Furry:react-native-gesture-handler:unspecified:
- Incompatible attribute:
- Required com.android.build.api.attributes.BuildTypeAttr 'stagingrelease' and found incompatible value 'release'.
- Other attributes:
- Found com.android.build.api.attributes.VariantAttr 'release' but wasn't required.
- Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
- Required org.gradle.usage 'java-runtime' and found compatible value 'java-runtime'.
> Could not resolve project :react-native-reanimated.
Required by:
project :app
> Unable to find a matching variant of project :react-native-reanimated:
- Variant 'debugApiElements' capability com.swmansion.reanimated:react-native-reanimated:unspecified:
- Incompatible attributes:
- Required com.android.build.api.attributes.BuildTypeAttr 'stagingrelease' and found incompatible value 'debug'.
- Required org.gradle.usage 'java-runtime' and found incompatible value 'java-api'.
- Other attributes:
- Found com.android.build.api.attributes.VariantAttr 'debug' but wasn't required.
- Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
- Variant 'debugRuntimeElements' capability com.swmansion.reanimated:react-native-reanimated:unspecified:
- Incompatible attribute:
- Required com.android.build.api.attributes.BuildTypeAttr 'stagingrelease' and found incompatible value 'debug'.
- Other attributes:
- Found com.android.build.api.attributes.VariantAttr 'debug' but wasn't required.
- Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
- Required org.gradle.usage 'java-runtime' and found compatible value 'java-runtime'.
- Variant 'releaseApiElements' capability com.swmansion.reanimated:react-native-reanimated:unspecified:
- Incompatible attributes:
- Required com.android.build.api.attributes.BuildTypeAttr 'stagingrelease' and found incompatible value 'release'.
- Required org.gradle.usage 'java-runtime' and found incompatible value 'java-api'.
- Other attributes:
- Found com.android.build.api.attributes.VariantAttr 'release' but wasn't required.
- Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
- Variant 'releaseRuntimeElements' capability com.swmansion.reanimated:react-native-reanimated:unspecified:
- Incompatible attribute:
- Required com.android.build.api.attributes.BuildTypeAttr 'stagingrelease' and found incompatible value 'release'.
- Other attributes:
- Found com.android.build.api.attributes.VariantAttr 'release' but wasn't required.
- Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
- Required org.gradle.usage 'java-runtime' and found compatible value 'java-runtime'.
> Could not resolve project :react-native-safe-area-context.
Required by:
project :app
> Unable to find a matching variant of project :react-native-safe-area-context:
- Variant 'debugApiElements' capability Furry:react-native-safe-area-context:unspecified:
- Incompatible attributes:
- Required com.android.build.api.attributes.BuildTypeAttr 'stagingrelease' and found incompatible value 'debug'.
- Required org.gradle.usage 'java-runtime' and found incompatible value 'java-api'.
- Other attributes:
- Found com.android.build.api.attributes.VariantAttr 'debug' but wasn't required.
- Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
- Variant 'debugRuntimeElements' capability Furry:react-native-safe-area-context:unspecified:
- Incompatible attribute:
- Required com.android.build.api.attributes.BuildTypeAttr 'stagingrelease' and found incompatible value 'debug'.
- Other attributes:
- Found com.android.build.api.attributes.VariantAttr 'debug' but wasn't required.
- Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
- Required org.gradle.usage 'java-runtime' and found compatible value 'java-runtime'.
- Variant 'releaseApiElements' capability Furry:react-native-safe-area-context:unspecified:
- Incompatible attributes:
- Required com.android.build.api.attributes.BuildTypeAttr 'stagingrelease' and found incompatible value 'release'.
- Required org.gradle.usage 'java-runtime' and found incompatible value 'java-api'.
- Other attributes:
- Found com.android.build.api.attributes.VariantAttr 'release' but wasn't required.
- Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
- Variant 'releaseRuntimeElements' capability Furry:react-native-safe-area-context:unspecified:
- Incompatible attribute:
- Required com.android.build.api.attributes.BuildTypeAttr 'stagingrelease' and found incompatible value 'release'.
- Other attributes:
- Found com.android.build.api.attributes.VariantAttr 'release' but wasn't required.
- Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
- Required org.gradle.usage 'java-runtime' and found compatible value 'java-runtime'.
> Could not resolve project :react-native-screens.
Required by:
project :app
> Unable to find a matching variant of project :react-native-screens:
- Variant 'debugApiElements' capability com.swmansion.rnscreens:react-native-screens:unspecified:
- Incompatible attributes:
- Required com.android.build.api.attributes.BuildTypeAttr 'stagingrelease' and found incompatible value 'debug'.
- Required org.gradle.usage 'java-runtime' and found incompatible value 'java-api'.
- Other attributes:
- Found com.android.build.api.attributes.VariantAttr 'debug' but wasn't required.
- Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
- Variant 'debugRuntimeElements' capability com.swmansion.rnscreens:react-native-screens:unspecified:
- Incompatible attribute:
- Required com.android.build.api.attributes.BuildTypeAttr 'stagingrelease' and found incompatible value 'debug'.
- Other attributes:
- Found com.android.build.api.attributes.VariantAttr 'debug' but wasn't required.
- Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
- Required org.gradle.usage 'java-runtime' and found compatible value 'java-runtime'.
- Variant 'releaseApiElements' capability com.swmansion.rnscreens:react-native-screens:unspecified:
- Incompatible attributes:
- Required com.android.build.api.attributes.BuildTypeAttr 'stagingrelease' and found incompatible value 'release'.
- Required org.gradle.usage 'java-runtime' and found incompatible value 'java-api'.
- Other attributes:
- Found com.android.build.api.attributes.VariantAttr 'release' but wasn't required.
- Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
- Variant 'releaseRuntimeElements' capability com.swmansion.rnscreens:react-native-screens:unspecified:
- Incompatible attribute:
- Required com.android.build.api.attributes.BuildTypeAttr 'stagingrelease' and found incompatible value 'release'.
- Other attributes:
- Found com.android.build.api.attributes.VariantAttr 'release' but wasn't required.
- Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
- Required org.gradle.usage 'java-runtime' and found compatible value 'java-runtime'.

android/app/build.gradle 的 fragment
project.ext.envConfigFiles = [
debug: ".env",
release: ".env.production",
stagingrelease: ".env.staging",
]
apply from: project(':react-native-config').projectDir.getPath() + "/dotenv.gradle"

project.ext.react = [
entryFile: "index.js",
enableHermes: false, // clean and rebuild if changing
]

apply from: "../../node_modules/react-native/react.gradle"

def enableSeparateBuildPerCPUArchitecture = false

def enableProguardInReleaseBuilds = true

def enableHermes = project.ext.react.get("enableHermes", false);

android {
compileSdkVersion rootProject.ext.compileSdkVersion

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

defaultConfig {
applicationId "com.furry"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
versionName "1.0"
}
splits {
abi {
reset()
enable enableSeparateBuildPerCPUArchitecture
universalApk false // If true, also generate a universal APK
include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
}
}
signingConfigs {
debug {
storeFile file('debug.keystore')
storePassword 'android'
keyAlias 'androiddebugkey'
keyPassword 'android'
}
}
buildTypes {
debug {
signingConfig signingConfigs.debug
}
release {
// Caution! In production, you need to generate your own keystore file.
// see https://facebook.github.io/react-native/docs/signed-apk-android.
signingConfig signingConfigs.debug
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
}
stagingrelease {
initWith release
}
}

dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "com.facebook.react:react-native:+" // From node_modules
implementation "androidx.appcompat:appcompat:1.1.0-rc01"
implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.1.0-alpha02"

if (enableHermes) {
def hermesPath = "../../node_modules/hermes-engine/android/";
debugImplementation files(hermesPath + "hermes-debug.aar")
releaseImplementation files(hermesPath + "hermes-release.aar")
} else {
implementation jscFlavor
}
}


apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
project.ext.vectoricons = [
iconFontNames: [ 'MaterialIcons.ttf', 'MaterialCommunityIcons.ttf' ]
]
apply from: "../../node_modules/react-native-vector-icons/fonts.gradle"

安卓/build.gradle
allprojects {
repositories {
mavenLocal()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url("$rootDir/../node_modules/react-native/android")
}
maven {
// Android JSC is installed from npm
url("$rootDir/../node_modules/jsc-android/dist")
}

google()
jcenter()
maven { url 'https://jitpack.io' }
}
}

proguard-rules.pro
# Add any project specific keep options here:
-keep class com.furry.BuildConfig { *; }

package.json 中的依赖关系
"dependencies": {
"@react-native-community/masked-view": "^0.1.6",
"@react-navigation/native": "^5.0.7",
"@react-navigation/stack": "^5.0.8",
"axios": "^0.19.2",
"libphonenumber-js": "^1.7.44",
"react": "16.9.0",
"react-native": "0.61.5",
"react-native-bootsplash": "^1.2.1",
"react-native-config": "^0.12.0",
"react-native-gesture-handler": "^1.6.0",
"react-native-reanimated": "^1.7.0",
"react-native-safe-area-context": "^0.7.3",
"react-native-screens": "^2.0.0-beta.10",
"react-native-sms-retriever": "^1.1.1",
"react-native-svg": "^11.0.1",
"react-native-vector-icons": "^6.6.0",
"realm": "4.0.0-beta.0",
"recyclerlistview": "2.0.13-alpha.1"
},

最佳答案

好吧!,所以我已经尝试了很多小时来解决这些问题,结果发现有一个简单的答案, matchingFallbacks .

出现此问题是因为我正在添加一个新的构建变体 stagingrelease到我的应用程序的build.gradle而正在使用的 native 库在其 build.gradle 中没有相同的匹配变体因此在构建过程中找不到相应的库。

stagingrelease {
initWith release
matchingFallbacks = ['debug', 'release'] // Addded this
}

关于android - React Native 构建在构建除调试/发布之外的新构建类型时失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60407756/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com