React Native:无法通知项目评估监听器。 > JAVA_LETTER_OR_DIGIT

时间:2019-11-28 19:36:50

标签: android react-native android-studio gradle

当我尝试使用react-native run-android在react native中运行android代码时出现错误。

我正在ubuntu上运行代码。

 rahul@rahul-Inspiron-15-3567  ~/Documents/reactNative/crowdalert/CrowdAlert-Mobile   master ●  react-native run-android 
Scanning folders for symlinks in /home/rahul/Documents/reactNative/crowdalert/CrowdAlert-Mobile/node_modules (8ms)
JS server already running.
Building and installing the app on the device (cd android && ./gradlew installDebug)...

> Configure project :app 
WARNING: The option 'android.enableAapt2' is deprecated and should not be used anymore.
Use 'android.enableAapt2=true' to remove this warning.
It will be removed at the end of 2018..
Reading env from: .env
WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html


FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':app'.
> Failed to notify project evaluation listener.
   > JAVA_LETTER_OR_DIGIT

* 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

在react native中运行应用程序也会显示相同的错误。这些是我的gradle和react-native版本:

react-native-cli:2.0.1 反应本机:0.51.0 摇篮4.4

项目级别的build.gradle文件。

buildscript {
    repositories {
        google()
        jcenter()
        maven {
            url 'https://maven.fabric.io/public'
        }
    mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.3'
        classpath 'com.android.tools.build:gradle:3.1.2'
        classpath 'com.google.gms:google-services:4.3.2'
        classpath 'io.fabric.tools:gradle:1.25.1'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

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

1 个答案:

答案 0 :(得分:0)

您的版本可能与RN版本和gradle不匹配。对于ReactNative 0.51,您应该使用gradle 3.5。但这不是唯一的问题。您的项目已过时。您可能无法将应用发布到Google Play商店,因为Google引入了新的发布格式(应用捆绑销售),而您的发布apk将被Play商店拒绝。在此处查看更多信息:https://developer.android.com/platform/technology/app-bundle

要使其成为可能,您需要升级到gradle 5.5,并使用React Native做到这一点,您需要升级到0.60+版本。在此处查看操作方法:https://facebook.github.io/react-native/docs/upgrading

如果您迷失了升级当前项目的方法,则可以选择初始化一个新项目,逐个链接代码的依赖关系和c / p,然后将代码调整为使用的新版本的库(如有必要)。