【问题标题】:React-Native- Failed to notify project evaluation listenerReact-Native-无法通知项目评估监听器
【发布时间】:2018-04-17 17:09:21
【问题描述】:

使用 gradle 4.3 在 Windows 7 上构建 react-native 应用程序,我收到以下错误,不确定问题是什么,我们将不胜感激。

C:\Users\username\AwesomeProject>react-native run-android
Scanning folders for symlinks in C:\Users\username\AwesomeProject\node_modules (62ms)
Starting JS server...
Building and installing the app on the device (cd android && gradlew.bat installDebug)...
Starting a Gradle Daemon (subsequent builds will be faster)
Download https://jcenter.bintray.com/com/facebook/react/react-native/maven-metadata.xml

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':app'.
> Failed to notify project evaluation listener.
   > com.android.build.gradle.tasks.factory.AndroidJavaCompile.setDependencyCacheDir(Ljava/io/File;)V

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

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

BUILD FAILED in 1m 0s
Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/android-setup.html

【问题讨论】:

    标签: android android-studio gradle react-native


    【解决方案1】:

    升级你的 build.gradle 项目文件; com.android.tools.build:gradle 版本从 2.2.3 使用如下:

    buildscript {
        repositories {
            jcenter()
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:2.3.3'
    
            // NOTE: Do not place your application dependencies here; they belong
            // in the individual module build.gradle files
        }
    }
    

    您可能会也可能不会遇到此问题,请更新您的构建工具。

    The SDK Build Tools revision (23.0.1) is too low for project ':app'. Minimum required is 25.0.0
    

    解决方案:在您的项目中更新 /app/build.gradle 如下:

    android {
        compileSdkVersion 25
        buildToolsVersion "25.0.1"
    

    【讨论】:

    • 在哪里添加代码android { ?在 buildscript 或所有项目的块中?还是作为一个独立的块?
    • @TerrySmith android 块应该已经存在 - 该块在 app/build.gradle 文件中。
    • 非常感谢!也为我工作,但谁能解释为什么会这样?
    • 对我来说 classpath 'com.android.tools.build:gradle:3.1.2' 和 app/build.gradle android { compileSdkVersion 27 buildToolsVersion "27.0.3" 工作正常
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-01-18
    • 1970-01-01
    • 2017-10-20
    • 2018-05-02
    • 2016-09-27
    • 2022-01-17
    相关资源
    最近更新 更多