gpt4 book ai didi

react-native - react 原生 : Task :react-native-maps:compileDebugRenderscript FAILED

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

我正在尝试实现 React Native MapView对于安卓。我确实关注了github installation指令,但当我尝试使用 react-native run-android 运行时遇到编译错误命令。

Task :react-native-maps:compileDebugRenderscript FAILED



FAILURE:构建失败并出现异常。


  • 什么地方出了错:
    无法解析配置“:react-native-maps:debugCompileClasspath”的所有文件。
    无法解析 com.android.support:support-compat:26.1.0。
    要求:
    项目:react-native-maps
    找不到满足版本约束的“com.android.support:support-compat”版本:
    依赖路径 'MapViewDemo:react-native-maps:unspecified' --> 'com.facebook.react:react-native:0.59.0' --> 'com.android.support:appcompat-v7:28.0.0' -
    -> 'com.android.support:support-compat:28.0.0'
    依赖路径 'MapViewDemo:react-native-maps:unspecified' --> 'com.facebook.react:react-native:0.59.0' --> 'com.android.support:appcompat-v7:28.0.0' -
    -> 'com.android.support:support-core-utils:28.0.0' --> 'com.android.support:support-compat:28.0.0'
    依赖路径 'MapViewDemo:react-native-maps:unspecified' --> 'com.facebook.react:react-native:0.59.0' --> 'com.android.support:appcompat-v7:28.0.0' -
    -> 'com.android.support:support-fragment:28.0.0' --> 'com.android.support:support-compat:28.0.0'
    依赖路径 'MapViewDemo:react-native-maps:unspecified' --> 'com.facebook.react:react-native:0.59.0' --> 'com.android.support:appcompat-v7:28.0.0' -
    -> 'com.android.support:support-vector-drawable:28.0.0' --> 'com.android.support:support-compat:28.0.0'
    依赖路径 'MapViewDemo:react-native-maps:unspecified' --> 'com.google.android.gms:play-services-base:16.0.1' --> 'com.google.android.gms:play-serv
    ices-basement:16.0.1' --> 'com.android.support:support-v4:26.1.0' --> 'com.android.support:support-compat:26.1.0'
    依赖路径 'MapViewDemo:react-native-maps:unspecified' --> 'com.facebook.react:react-native:0.59.0' --> 'com.android.support:appcompat-v7:28.0.0' -
    -> 'com.android.support:support-core-utils:28.0.0' --> 'com.android.support:loader:28.0.0' --> 'com.android.support:support-compat:28.0 .0'
    'com.android.support:support-annotations' 严格来说是 '26.1.0' 因为以下原因
    儿子:debugRuntimeClasspath 使用版本 26.1.0
    约束路径 'MapViewDemo:react-native-maps:unspecified' --> 'com.android.support:support-annotations' 严格来说是 '26.1.0' 因为以下原因
    儿子:debugRuntimeClasspath 使用版本 26.1.0

  • 尝试:
    使用 --stacktrace 选项运行以获取堆栈跟踪。使用 --info 或 --debug 选项运行以获得更多日志输出。运行 --scan 以获得完整的见解。
  • https://help.gradle.org 获得更多帮助

  • 5 秒内构建失败
    8 个可操作的任务:8 个已执行
    错误 无法在设备上安装应用程序,请阅读上面的错误以了解详细信息。
    确保您有一个正在运行的 Android 模拟器或连接的设备,并且有
    设置您的 Android 开发环境:
    https://facebook.github.io/react-native/docs/getting-started.html
    错误命令失败:gradlew.bat app:installDebug

    应用级分级
    apply plugin: "com.android.application"

    import com.android.build.OutputFile

    project.ext.react = [
    entryFile: "index.js"
    ]

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


    def enableSeparateBuildPerCPUArchitecture = false

    /**
    * Run Proguard to shrink the Java bytecode in release builds.
    */
    def enableProguardInReleaseBuilds = false

    android {
    compileSdkVersion rootProject.ext.compileSdkVersion

    compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
    }

    defaultConfig {
    applicationId "com.mapviewdemo"
    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"
    }
    }
    buildTypes {
    release {
    minifyEnabled enableProguardInReleaseBuilds
    proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
    }
    }
    // applicationVariants are e.g. debug, release
    applicationVariants.all { variant ->
    variant.outputs.each { output ->
    // For each separate APK per architecture, set a unique version code as described here:
    // http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
    def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86-64": 4]
    def abi = output.getFilter(OutputFile.ABI)
    if (abi != null) { // null for the universal-debug, universal-release variants
    output.versionCodeOverride =
    versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
    }
    }
    }
    }

    dependencies {
    implementation project(':react-native-maps')
    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
    implementation "com.facebook.react:react-native:+" // From node_modules

    implementation(project(':react-native-maps')) {
    exclude group: 'com.google.android.gms', module: 'play-services-base'
    exclude group: 'com.google.android.gms', module: 'play-services-maps'
    }
    implementation 'com.google.android.gms:play-services-base:16.1.0'
    implementation 'com.google.android.gms:play-services-maps:16.1.0'


    }

    // Run this once to be able to run the application with BUCK
    // puts all compile dependencies into folder libs for BUCK to use
    task copyDownloadableDepsToLibs(type: Copy) {
    from configurations.compile
    into 'libs'
    }

    configurations.all {
    resolutionStrategy {
    force 'com.android.support:support-v4:28.0.0'
    force 'com.android.support:appcompat-v7:28.0.0'
    }
    }

    项目级毕业
    // Top-level build file where you can add configuration options common to all sub-projects/modules.

    buildscript {
    ext {
    buildToolsVersion = "28.0.3"
    minSdkVersion = 20
    compileSdkVersion = 28
    targetSdkVersion = 28
    supportLibVersion = "28.0.0"
    }
    repositories {
    google()
    jcenter()
    }
    dependencies {
    classpath 'com.android.tools.build:gradle:3.3.2'

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
    }
    }

    allprojects {
    repositories {
    mavenLocal()
    google()
    jcenter()
    maven {
    // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
    url "$rootDir/../node_modules/react-native/android"
    }
    }
    }

    包.json
    {
    "name": "MapViewDemo",
    "version": "0.0.1",
    "private": true,
    "scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start",
    "test": "jest"
    },
    "dependencies": {
    "react": "16.8.3",
    "react-native": "0.59.0",
    "react-native-maps": "^0.23.0"
    },
    "devDependencies": {
    "@babel/core": "7.3.4",
    "@babel/runtime": "7.3.4",
    "babel-jest": "24.5.0",
    "jest": "24.5.0",
    "metro-react-native-babel-preset": "0.53.0",
    "react-test-renderer": "16.8.3"
    },
    "jest": {
    "preset": "react-native"
    }
    }

    最佳答案

    经过两天的挣扎,我自己找到了解决方案。真正的问题是我的项目使用 compileSdkVersion = 28react-native-maps node_module 使用不同版本的 compileSdkVersion .

    要解决这个问题需要更新react-native-maps节点模块 compileSdkVersion版本。

    project_name>node_modules>react-native-maps>lib>android>build.gradle

     ext {
    buildToolsVersion = "28.0.3"
    minSdkVersion = 20
    compileSdkVersion = 28
    targetSdkVersion = 28
    supportLibVersion = "28.0.0"
    }

    模块编译 SDK 版本和支持库版本应与项目编译 SDK 版本和支持库版本相同。

    关于react-native - react 原生 : Task :react-native-maps:compileDebugRenderscript FAILED,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55156193/

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