Hata: Geçerli karakter belirlenemedi, android için reat-native'de bir dize, sayı, dizi veya nesne değil


10

Ben emülatör çalışırken tutarken tepki yerli çalıştırmak-android çalıştırmak, bu hatayı alıyorum. reakt -native run-ios tamamen iyi sonuç verir.

Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081
:ReactNative:Failed to parse React Native CLI configuration: groovy.json.JsonException: Unable to determine the current character, it is not a string, number, array, or object

The current character read is 'E' with an int value of 69
Unable to determine the current character, it is not a string, number, array, or object
line number 1
index number 0
Error: Invalid attribute nameLine: 16Column: 18Char: .    at error (/Users/yashatreya/Desktop/Realyze/Realyze/node_modules/sax/lib/sax.js:651:10)    at strictFail (/Users/yashatreya/Desktop/Realyze/Realyze/node_modules/sax/lib/sax.js:677:7)    at SAXParser.write (/Users/yashatreya/Desktop/Realyze/Realyze/node_modules/sax/lib/sax.js:1313:13)    at new XmlDocument (/Users/yashatreya/Desktop/Realyze/Realyze/node_modules/xmldoc/lib/xmldoc.js:261:15)    at readManifest (/Users/yashatreya/Desktop/Realyze/Realyze/node_modules/@react-native-community/cli-platform-android/build/config/readManifest.js:38:10)    at Object.projectConfig (/Users/yashatreya/Desktop/Realyze/Realyze/node_modules/@react-native-community/cli-platform-android/build/config/index.js:59:46)    at Object.get project [as project] (/Users/yashatreya/Desktop/Realyze/Realyze/node_modules/react-native/node_modules/@react-native-community/cli/build/tools/config/index.js:114:50)    at /Users/yashatreya/Desktop/Realyze/Realyze/node_modules/react-native/node_modules/@react-native-community/cli/build/commands/config/config.js:8:452    at Array.forEach (<anonymous>)    at _objectSpread (/Users/yashatreya/Desktop/Realyze/Realyze/node_modules/react-native/node_modules/@react-native-community/cli/build/commands/config/config.js:8:392)
^

FAILURE: Build failed with an exception.

* Where:
Script '/Users/yashatreya/Desktop/Realyze/Realyze/node_modules/@react-native-community/cli-platform-android/native_modules.gradle' line: 201

* What went wrong:
A problem occurred evaluating script.
> Failed to parse React Native CLI configuration. Expected running 'npx --quiet --no-install react-native config' command from '/Users/yashatreya/Desktop/Realyze/Realyze' directory to output valid JSON, but it didn't. This may be caused by npx resolving to a legacy global react-native binary. Please make sure to uninstall any global 'react-native' binaries: 'npm uninstall -g react-native react-native-cli' and try again

* 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

Hata mesajında ​​belirtildiği gibi çalışmayı denedim npm uninstall -g react-native react-native-cliama işe yaramadı.

Çevrem hakkında bilgi:

System:
    OS: macOS 10.15
    CPU: (4) x64 Intel(R) Core(TM) i5-7360U CPU @ 2.30GHz
    Memory: 29.68 MB / 8.00 GB
    Shell: 3.2.57 - /bin/bash
  Binaries:
    Node: 12.13.0 - /usr/local/bin/node
    Yarn: 1.19.1 - /usr/local/bin/yarn
    npm: 6.12.0 - /usr/local/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  SDKs:
    iOS SDK:
      Platforms: iOS 13.0, DriverKit 19.0, macOS 10.15, tvOS 13.0, watchOS 6.0
  IDEs:
    Android Studio: 3.5 AI-191.8026.42.35.5977832
    Xcode: 11.0/11A420a - /usr/bin/xcodebuild
  npmPackages:
    react: 16.9.0 => 16.9.0 
    react-native: ^0.61.4 => 0.61.4 
  npmGlobalPackages:
    react-native-cli: 2.0.1

android / app / build.gradle aşağıda:

apply plugin: "com.android.application"

import com.android.build.OutputFile
project.ext.react = [
    entryFile: "index.js",
    enableHermes: false,  // clean and rebuild if changing
]

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

def enableSeparateBuildPerCPUArchitecture = false
def enableProguardInReleaseBuilds = false

def jscFlavor = 'org.webkit:android-jsc:+' 

def enableHermes = project.ext.react.get("enableHermes", false);

android {
    compileSdkVersion rootProject.ext.compileSdkVersion

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    defaultConfig {
        applicationId "com.realyze"
        minSdkVersion 21 
        targetSdkVersion rootProject.ext.targetSdkVersion
        versionCode 1
        versionName "1.0"
        multiDexEnabled true

    }
    // rootProject.ext.minSdkVersion
    splits {
        abi {
            reset()
            enable enableSeparateBuildPerCPUArchitecture
            universalApk false  // If true, also generate a universal APK
            include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
        }
    }
    signingConfigs {
        debug {
            storeFile file('debug.keystore')
            storePassword 'android'
            keyAlias 'androiddebugkey'
            keyPassword 'android'
        }
    }
    buildTypes {
        debug {
            signingConfig signingConfigs.debug
        }
        release {
            // Caution! In production, you need to generate your own keystore file.
            // see https://facebook.github.io/react-native/docs/signed-apk-android.
            signingConfig signingConfigs.debug
            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:
            // https://developer.android.com/studio/build/configure-apk-splits.html
            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-push-notification')
    implementation project(':react-native-sound')
    implementation project(':react-native-audio')
    implementation 'com.android.support:multidex:2.0.1'
    implementation project(':react-native-gesture-handler')
    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation "com.facebook.react:react-native:+"  // From node_modules
    implementation 'androidx.appcompat:appcompat:1.1.0-rc01'
    implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0-alpha02'
    implementation 'com.google.firebase:firebase-analytics:17.2.0'
    implementation 'com.google.firebase:firebase-auth:19.1.0'
    implementation project(path: ":@react-native-firebase_auth")
    implementation project(path: ":@react-native-firebase_messaging")
    implementation project(path: ":@react-native-firebase_database")
    implementation project(':react-native-datetimepicker')
    implementation project(path: ":@react-native-firebase_firestore")
    implementation project(path: ":@react-native-firebase_functions")
}

    if (enableHermes) {
        def hermesPath = "../../node_modules/hermes-engine/android/";
        debugImplementation files(hermesPath + "hermes-debug.aar")
        releaseImplementation files(hermesPath + "hermes-release.aar")
    } else {
        implementation jscFlavor
    }
// }

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

apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
apply plugin: 'com.google.gms.google-services'

android / build.gradle aşağıda:


buildscript {
    ext {
        buildToolsVersion = "28.0.3"
        minSdkVersion = 16
        compileSdkVersion = 28
        targetSdkVersion = 28
    }
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath "com.android.tools.build:gradle:3.4.2"
        classpath 'com.google.gms:google-services:4.3.2'
    }
}

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

        google()
        jcenter()
        maven { url 'https://jitpack.io' }
    }
}

Başlangıçta bu hatayı alıyordum: tepki-yerel yapı hatası: org.gradle.api.Project türündeki ': app' projesinde [jscFlavor] argümanları için yöntem uygulama () bulunamadı, ancak şimdi yukarı alıyorum.


Hangi işletim sistemini kullanıyorsunuz? Sorunumun android derleme klasörlerindeki dosya izinlerinden kaynaklandığını gördüm - ne olduğu hakkında hiçbir fikrim yok, ancak Windows 10 makinemde tüm uygulamalarımı (Android Studio, VS Kodu, Windows Komutu) yükseltilmiş haklarla başlattığımdan emin olmalıydım (Çalıştır yönetici olarak).
Tahir Khalid

MacOS kullanıyorum
yashatreya

CLI kullanarak projeyi yeniden oluşturdum ve çalışmaya başladı :-(
Tahir Khalid

@TahirKhalid Reat-native init kullanarak tamamen yeni bir proje başlattınız mı? Lütfen biraz ayrıntı
verebilir misiniz

Evet, projeyi yeniden oluşturdum ancak bu sefer izinlerin doğru olduğundan emin oldum. Doğru okuma / yazma erişimi sağlamak için MacOS konsolunu kullanır ve klasörleri ve dosyaları değiştiririm
Tahir Khalid

Yanıtlar:


15

ÇÖZÜM 1 (benim için çalıştı)

Benim için çözüm aşağıdaki satırı kaldırmaktı

apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)

Her yerde çıkardığınızdan emin olun. Ben build.gradle (app) ve ayrıca settings.gradle bu satırı vardı .

Bundan sonra, tekrar çalıştırın npx tepki-yerel run-android konsol gerçek hatayı görüntüleyecek, hatayı düzeltecek ve kaldırdığınız satırları geri koyacaktır.

Benim durumumda hata daha eski bir Düğüm sürümünü kullandığım için oldu ve ikinci kez oldu Projemi tekrar senkronize etmem gerekiyordu


ÇÖZÜM 2

Hata bulduğu dosyaları "Geçerli karakter değeri 69" değerine sahip "E" olarak sil

Silme

app\build\intermediates\signing_config\debug\out\signing-config.json

başkaları için de çalıştı.


ÇÖZÜM 3

Güncelleme @ tepki yerli-toplum / cli son sürüme.

İyi kodlama!


Nodejs'den doğrudan MacOS'a yükleme de benim için çalıştı, teşekkür ederim! Demleme kurulumları, kaldırma ve yeniden bağlama adımları ile bile çalışmadı. Nodejs indirmesini doğrudan vurgulamak için cevabınızı çerçevelendirmeyi ve ardından aşağıdaki geçici çözümü kullanmanızı öneririz.
Kelton.Temby

Hala sorunum vardı. Geçici çözüm, dosyamda küçük bir sözdizimi hatası görmeme yardımcı oldu android/app/src/main/AndroidManifest.xml. Şimdi düzelttikten sonra, diğer hatları tekrar açabildim.
Kelton.Temby

1
Paylaşım için teşekkürler. Cevabı daha açık hale getirmek için güncelleyeceğim!
Faustino Gagneten

@ Kelton.Temby, bahsettiğiniz gibi diğer kullanıcılar için daha açık hale getirmek için cevabımı düzenleyebilirsiniz.
Faustino Gagneten

3

Bu sorunun sadece yeni sürümde (0.61) olduğunu düşünüyorum Aynı sorunu yaşadım ve sadece eski sürümü (0.60.0) kullandım

 npx react-native init AwesomeProject --version 0.60.0

2

Sadece android içindeki inşa klasörünü kaldırdı ve android klasörüne gidin ve powershell'de ./gradlewtemiz yazıp cd..=>npx react-native run-android


1

Lütfen AndroidManifest.xml verilerinin "" değil "şeklinde uygun tırnaklarla olduğundan emin olun. Bu genellikle ateş tabanını yapılandırırken ve bağımlılıkları kopyalayarak yapıştırdığımızda olur.


lanet olsun adam kopya benim xml bazı web sitesinden yapıştırılan ve ben çok teşekkür etmedi
Shivam
Sitemizi kullandığınızda şunları okuyup anladığınızı kabul etmiş olursunuz: Çerez Politikası ve Gizlilik Politikası.
Licensed under cc by-sa 3.0 with attribution required.