代码之家  ›  专栏  ›  技术社区  ›  Andrei

反应本机错误:已创建Android任务。Android Studio 3.3

  •  0
  • Andrei  · 技术社区  · 6 年前

    我的react原生应用程序在更新Android Studio和Gradle后无法生成。

    buildscript {
        repositories {
            jcenter()
            google()
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:3.1.4'
        }
    }
    
    allprojects {
        repositories {
            google()
            mavenLocal()
            jcenter()
            maven {
                url "$rootDir/../node_modules/react-native/android"
            }
        }
    }
    
    task clean(type: Delete) {
        delete rootProject.buildDir
    }
    subprojects {
        project.configurations.all {
            afterEvaluate {project ->
                if (project.hasProperty("android")) {
                    android {
                        compileSdkVersion 27
                        buildToolsVersion "27.0.3"
                    }
                }
            }
    
            resolutionStrategy.eachDependency { details ->
                if (details.requested.group == 'com.android.support'
                        && !details.requested.name.contains('multidex') ) {
                    details.useVersion "26.1.0"
                }
            }
        }
    }
    
    FAILURE: Build failed with an exception.
    
    * Where:
    Build file 'D:\mobileinstein.app\android\build.gradle' line: 32
    
    * What went wrong:
    A problem occurred configuring project ':app'.
    > Failed to notify project evaluation listener.
       > Android tasks have already been created.
         This happens when calling android.applicationVariants,
         android.libraryVariants or android.testVariants.
         Once these methods are called, it is not possible to
         continue configuring the model.
       > Android tasks have already been created.
         This happens when calling android.applicationVariants,
         android.libraryVariants or android.testVariants.
         Once these methods are called, it is not possible to
         continue configuring the model.
       > Android tasks have already been created.
         This happens when calling android.applicationVariants,
         android.libraryVariants or android.testVariants.
         Once these methods are called, it is not possible to
         continue configuring the model.
       > Android tasks have already been created.
         This happens when calling android.applicationVariants,
         android.libraryVariants or android.testVariants.
         Once these methods are called, it is not possible to
         continue configuring the model.
    

    错误似乎出现在“子项目”部分,但我需要它。现在不知道该怎么办。

    1 回复  |  直到 6 年前
        1
  •  0
  •   Rachid Rhafour    6 年前

    试试换单 google() 然后 jcenter() 这应该行得通

    推荐文章