React-Native CodePush Build Failure -没有找到匹配的项目配置:react-native-code-push

8ulbf1ek  于 2023-03-24  发布在  React
关注(0)|答案(1)|浏览(213)

我正在尝试在我的react原生应用程序中启用codepush。使用repo https://github.com/microsoft/react-native-code-push,我在以下环境中遇到构建失败

Environment:
=============
react-native-code-push version:7.0.4
react-native version:0.65.0
Gradle version: 6.9
Does this reproduce on a debug build or release build? : both
Does this reproduce on a simulator, or only on a physical device?: during build, can't run it yet.
Hardware/OS: MacOS (M1 chipset), MacOS Monterey v12.0.1

根据https://github.com/microsoft/react-native-code-push/blob/master/docs/setup-android.md#plugin-installation-and-configuration-for-react-native-060-version-and-above-android,我正在执行以下步骤

  1. npm install --保存react-native-code-push
    1.在android/settings.gradle文件中,在文件末尾添加以下内容:
    (一)
...
apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)
include ':app', ':react-native-code-push'
project(':react-native-code-push').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-code-push/android/app')

还尝试在最后一行之前添加(尽管文档要求在文件末尾添加)
(B)

...
include ':app', ':react-native-code-push'
project(':react-native-code-push').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-code-push/android/app')
apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)

1.在你的android/app/build.gradle文件中,添加codepush.gradle文件作为react.gradle下面的额外构建任务定义:

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

1.通过MainApplication.java以下更改更新www.example.com文件以使用CodePush:

...
// 1. Import the plugin class.
import com.microsoft.codepush.react.CodePush;

public class MainApplication extends Application implements ReactApplication {

    private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
        ...

        // 2. Override the getJSBundleFile method in order to let
        // the CodePush runtime determine where to get the JS
        // bundle location from on each app start
        @Override
        protected String getJSBundleFile() {
            return CodePush.getJSBundleFile();
        }
    };
}

1.将Deployment键添加到strings.xml:

<resources>
    <string name="app_name">AppName</string>
    <string moduleConfig="true" name="CodePushDeploymentKey">XXXXXXXX</string>
</resources>

使用步骤-2(a)构建输出:

> Task :react-native-code-push:generateReleaseRFile FAILED
Dependency resolved to an incompatible version: Dependency(fromArtifactVersion=ArtifactVersion(groupId=com.nimbusds, artifactId=nimbus-jose-jwt, version=5.1), toArtifact=Artifact(groupId=net.minidev, artifactId=json-smart), toArtifactVersionString=[1.3.1,2.3])
Dependency resolved to an incompatible version: Dependency(fromArtifactVersion=ArtifactVersion(groupId=com.nimbusds, artifactId=nimbus-jose-jwt, version=5.1), toArtifact=Artifact(groupId=net.minidev, artifactId=json-smart), toArtifactVersionString=[1.3.1,2.3])

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':react-native-code-push:generateReleaseRFile'.
> Failed to notify dependency resolution listener.
   > In project 'App' a resolved Google Play services library dependency depends on another at an exact version (e.g. "[1
     .3.1,2.3]", but isn't being resolved to that version. Behavior exhibited by the library will be unknown.

     Dependency failing: com.nimbusds:nimbus-jose-jwt:5.1 -> net.minidev:json-smart@[1.3.1,2.3], but json-smart version was 2
     .3.

     The following dependencies are project dependencies that are direct or have transitive dependencies that lead to the art
     ifact with the issue.
     -- Project 'App' depends on project 'react' which depends onto net.minidev:json-smart@{strictly 2.3}
     -- Project 'App' depends on project 'react' which depends onto com.nimbusds:nimbus-jose-jwt@{strictly 5.1}
     -- Project 'App' depends on project 'react' which depends onto com.nimbusds:nimbus-jose-jwt@5.1

     For extended debugging info execute Gradle from the command line with ./gradlew --info :App:assembleDebug to see the
      dependency paths to the artifact. This error message came from the google-services Gradle plugin, report issues at http
     s://github.com/google/play-services-plugins and disable by adding "googleServices { disableVersionCheck = false }" to yo
     ur build.gradle file.
   > In project 'app' a resolved Google Play services library dependency depends on another at an exact version (e.g. "[1.3.1
     ,2.3]", but isn't being resolved to that version. Behavior exhibited by the library will be unknown.

     Dependency failing: com.nimbusds:nimbus-jose-jwt:5.1 -> net.minidev:json-smart@[1.3.1,2.3], but json-smart version was 2
     .3.

     The following dependencies are project dependencies that are direct or have transitive dependencies that lead to the art
     ifact with the issue.
     -- Project 'app' depends on project 'react' which depends onto net.minidev:json-smart@{strictly 2.3}
     -- Project 'app' depends on project 'react' which depends onto com.nimbusds:nimbus-jose-jwt@{strictly 5.1}
     -- Project 'app' depends on project 'react' which depends onto com.nimbusds:nimbus-jose-jwt@5.1

     For extended debugging info execute Gradle from the command line with ./gradlew --info :app:assembleDebug to see the dep
     endency paths to the artifact. This error message came from the google-services Gradle plugin, report issues at https://
     github.com/google/play-services-plugins and disable by adding "googleServices { disableVersionCheck = false }" to your b
     uild.gradle file.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.9/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 2m 48s

使用步骤-2(b)构建输出:

FAILURE: Build failed with an exception.

* What went wrong:
Could not determine the dependencies of task ':app:compileReleaseJavaWithJavac'.
> Could not resolve all task dependencies for configuration ':app:releaseCompileClasspath'.
   > Could not resolve project :react-native-code-push.
     Required by:
         project :app
      > No matching configuration of project :react-native-code-push was found. The consumer was configured to find an API of a component, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'release', attribute 'react-native-camera' with value 'mlkit', attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm' but:
          - None of the consumable configurations have attributes.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.9/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 1m 7s
bvjveswy

bvjveswy1#

你可以尝试的第一件事是1. npm start -- --reset-cache如果这不起作用尝试2. ./gradlew clean在你的android文件夹的根项目。如果这也不起作用我会建议你升级你的react-native版本和代码推送版本在react-native〉0. 71我们不需要apply from: "../../node_modules/react-native/react.gradle"apply from: "../../node_modules/react-native-code-push/android/codepush.gradle"删除它,并尝试运行您的应用程序

相关问题