gpt4 book ai didi

android - Appcenter Codepush 集成。无法将任务 'bundleDebugJsAndAssets' 添加为具有该名称的任务已存在

转载 作者:行者123 更新时间:2023-12-03 22:53:09 25 4
gpt4 key购买 nike

重现步骤

  • yarn add react-native-codepush
  • 将以下内容添加到 android/app/build.gradle
  • apply from: "../../node_modules/react-native/react.gradle"
    apply from: "../../node_modules/react-native-code-push/android/codepush.gradle"
  • 将以下内容添加到 MainApplication.java

  • ...
    import com.microsoft.codepush.react.CodePush;
    ...
    @Override
    protected String getJSBundleFile() {
    return CodePush.getJSBundleFile();
    }
  • 将以下内容添加到 strings.xml
  •     <string name="CodePushDeploymentKey" moduleConfig="true">MYKEY</string>

    预期行为

    构建应该成功

    实际行为

    实际发生了什么?
     $ react-native run-android
    info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
    Jetifier found 998 file(s) to forward-jetify. Using 4 workers...
    info JS server already running.
    info Installing the app...

    > Configure project :app
    WARNING: BuildType(debug): resValue 'react_native_dev_server_port' value is being replaced: 8081 -> 8081
    WARNING: BuildType(debug): resValue 'react_native_inspector_proxy_port' value is being replaced: 8081 -> 8081
    WARNING: BuildType(release): resValue 'react_native_dev_server_port' value is being replaced: 8081 -> 8081
    WARNING: BuildType(release): resValue 'react_native_inspector_proxy_port' value is being replaced: 8081 -> 8081

    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.0.1/userguide/command_line_interface.html#sec:command_line_warnings

    FAILURE: Build failed with an exception.

    * Where:
    Script '/Users/user/Desktop/project/app/native/node_modules/react-native/react.gradle' line: 118

    * What went wrong:
    A problem occurred configuring project ':app'.
    > Cannot add task 'bundleDebugJsAndAssets' as a task with that name already exists.

    * 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

    BUILD FAILED in 4s

    error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup. Run CLI with --verbose flag for more details.
    Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081

    FAILURE: Build failed with an exception.

    * Where:
    Script '/Users/user/Desktop/project/app/native/node_modules/react-native/react.gradle' line: 118

    * What went wrong:
    A problem occurred configuring project ':app'.
    > Cannot add task 'bundleDebugJsAndAssets' as a task with that name already exists.

    * 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

    BUILD FAILED in 4s

    at makeError (/Users/user/Desktop/project/app/native/node_modules/execa/index.js:174:9)
    at /Users/user/Desktop/project/app/native/node_modules/execa/index.js:278:16
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at async runOnAllDevices (/Users/user/Desktop/project/app/native/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.js:94:5)
    at async Command.handleAction (/Users/user/Desktop/project/app/native/node_modules/@react-native-community/cli/build/index.js:186:9)
    error Command failed with exit code 1.
    info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.


    环境
  • react-native-code-push 版本:^6.2.1
  • react 原生版本:0.62.2
  • iOS/Android/Windows 版本:未知
  • 这会在调试版本或发布版本上重现吗?仅在调试时检查
  • 这是在模拟器上重现,还是仅在物理设备上重现?构建错误

  • 外部 SDK

    我在 build.gradle 中有一个外部 SDK .我不知道这是否是此错误的原因。
    buildscript {
    repositories {
    maven { url 'https://plugins.gradle.org/m2/' } // Gradle Plugin Portal
    }
    dependencies {
    classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:[0.12.6, 0.99.99]'
    }
    }

    apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'
    apply plugin: "com.android.application"
    apply from: "../../node_modules/react-native/react.gradle"
    apply from: "../../node_modules/react-native-code-push/android/codepush.gradle"

    ....
    apply plugin: 'com.google.gms.google-services'

    我试过了。

    我将两个声明移到 app/build.gradle 的底部.但错误仍然相同
    // puts all compile dependencies into folder libs for BUCK to use
    task copyDownloadableDepsToLibs(type: Copy) {
    from configurations.compile
    into 'libs'
    }

    apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
    apply from: "../../node_modules/react-native/react.gradle"
    apply from: "../../node_modules/react-native-code-push/android/codepush.gradle"


    某些文章状态删除行 apply from: "../../node_modules/react-native/react.gradle" .但是新的错误是
    yarn run v1.22.4
    $ react-native run-android
    info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
    Jetifier found 998 file(s) to forward-jetify. Using 4 workers...
    info JS server already running.
    info Installing the app...

    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.0.1/userguide/command_line_interface.html#sec:command_line_warnings

    FAILURE: Build failed with an exception.

    * What went wrong:
    Could not determine the dependencies of task ':app:mergeDebugAssets'.
    > Could not resolve all task dependencies for configuration ':app:debugRuntimeClasspath'.
    > Could not resolve project :react-native-code-push.
    Required by:
    project :app
    > Unable to find a matching configuration of project :react-native-code-push:
    - 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

    BUILD FAILED in 3s

    error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup. Run CLI with --verbose flag for more details.
    Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081

    FAILURE: Build failed with an exception.

    * What went wrong:
    Could not determine the dependencies of task ':app:mergeDebugAssets'.
    > Could not resolve all task dependencies for configuration ':app:debugRuntimeClasspath'.
    > Could not resolve project :react-native-code-push.
    Required by:
    project :app
    > Unable to find a matching configuration of project :react-native-code-push:
    - 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

    BUILD FAILED in 3s

    at makeError (/Users/user/Desktop/project/app/native/node_modules/execa/index.js:174:9)
    at /Users/user/Desktop/project/app/native/node_modules/execa/index.js:278:16
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at async runOnAllDevices (/Users/user/Desktop/project/app/native/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.js:94:5)
    at async Command.handleAction (/Users/user/Desktop/project/app/native/node_modules/@react-native-community/cli/build/index.js:186:9)
    error Command failed with exit code 1.
    info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

    我删除了这两行(实际上没有任何意义)错误是
    yarn run v1.22.4
    $ react-native run-android
    info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
    Jetifier found 998 file(s) to forward-jetify. Using 4 workers...
    info JS server already running.
    info Installing the app...

    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.0.1/userguide/command_line_interface.html#sec:command_line_warnings

    FAILURE: Build failed with an exception.

    * What went wrong:
    Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'.
    > Could not resolve all task dependencies for configuration ':app:debugCompileClasspath'.
    > Could not resolve project :react-native-code-push.
    Required by:
    project :app
    > Unable to find a matching configuration of project :react-native-code-push:
    - 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

    BUILD FAILED in 4s

    error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup. Run CLI with --verbose flag for more details.
    Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081

    FAILURE: Build failed with an exception.

    * What went wrong:
    Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'.
    > Could not resolve all task dependencies for configuration ':app:debugCompileClasspath'.
    > Could not resolve project :react-native-code-push.
    Required by:
    project :app
    > Unable to find a matching configuration of project :react-native-code-push:
    - 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

    BUILD FAILED in 4s

    at makeError (/Users/user/Desktop/project/app/native/node_modules/execa/index.js:174:9)
    at /Users/user/Desktop/project/app/native/node_modules/execa/index.js:278:16
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at async runOnAllDevices (/Users/user/Desktop/project/app/native/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.js:94:5)
    at async Command.handleAction (/Users/user/Desktop/project/app/native/node_modules/@react-native-community/cli/build/index.js:186:9)
    error Command failed with exit code 1.
    info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

    最佳答案

    实际上有两个错误:

  • android/app/build.gradle 中实际上存在一行这是apply from: "../../node_modules/react-native/react.gradle" .您不需要添加此行,而是需要添加 apply from: "../../node_modules/react-native-code-push/android/codepush.gradle"在它下面。最后添加这个可以解决一些用户的问题,但不能解决所有用户的问题。在适当的地方添加它。
  • 如果有一个 gradle 错误,那是由于 multidex。为所有支持启用 multidex。添加 multiDexEnable trueandroid > defaultConfig .请参阅此引用 https://developer.android.com/studio/build/multidex#mdex-gradle
  • 关于android - Appcenter Codepush 集成。无法将任务 'bundleDebugJsAndAssets' 添加为具有该名称的任务已存在,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62264946/

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