gpt4 book ai didi

react-native - 评估项目 ':app'时发生问题。可能是build.gradle问题

转载 作者:行者123 更新时间:2023-12-03 05:34:28 25 4
gpt4 key购买 nike

我不断收到此错误:

A problem occurred configuring project ':app'.



每当我做react-native run-android时。我的怀疑是我在两个build.gradle之一中搞砸了

错误日志:(cmd)
FAILURE: Build completed with 2 failures.

1: Task failed with an exception.
-----------
* Where: Build file 'D:\Programs\reactnative\tokobangun\android\app\build.gradle' line:
103

* What went wrong: A problem occurred evaluating project ':app'.
Could not find method android() for arguments [build_52alt8ebvpuajag0a3orrbaix$_run_closure1@36f24a11] on project
':app' of type org.gradle.api.Project.
==============================================================================

2: Task failed with an exception.
-----------
* What went wrong: A problem occurred configuring project ':app'.
Failed to notify project evaluation listener.
Could not get unknown property 'android' for project ':app' of type org.gradle.api.Project.
Could not get unknown property 'android' for project ':app' of type org.gradle.api.Project.

我试过了:
  • react-native run-android
  • gradlew清洁

  • 两者都给我相同的结果。

    android / app / build.gradle
    buildscript {
    repositories {
    maven { url 'https://plugins.gradle.org/m2/' } // Gradle Plugin Portal
    }
    dependencies {
    classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:[0.12.1, 0.99.99]'
    }
    }

    apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'

    /** . . . */

    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.tokobangun"
    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-onesignal')
    implementation project(':react-native-webview')
    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
    implementation "com.facebook.react:react-native:+" // From node_modules
    }

    // 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'
    }

    android / build.gradle
    // Top-level build file where you can add configuration options common to all sub-projects/modules.

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

    // 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"
    }
    }
    }

    我确实认为我在某个地方搞砸了android / build.gradle,并且尝试将其恢复为没有错误但无济于事的状态。有任何想法吗?

    哦,如果您发现我的问题格式不够,请告诉我,我将尽我所能进行调整。在此先感谢。

    最佳答案

    在android / build.gradle中,将classpath(“com.android.tools.build:gradle:3.4.0”)更改为classpath'com.android.tools.build:gradle:3.3.0',然后重试

    关于react-native - 评估项目 ':app'时发生问题。可能是build.gradle问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57294538/

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