gpt4 book ai didi

android - 找不到变量:在构建时 react

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

我正在尝试构建我的React应用程序,但是我要处理一些错误,以下是我遇到的第一个危险信号!

enter image description here

我已经在每个文件中导入了React。

buildscript {
ext {
buildToolsVersion = "28.0.3"
minSdkVersion = 16
compileSdkVersion = 28
targetSdkVersion = 28
supportLibVersion = "28.0.0"
}
repositories {
google()
jcenter()
maven {
url 'https://maven.fabric.io/public'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.2'
classpath 'com.google.gms:google-services:4.2.0'
classpath 'com.google.firebase:perf-plugin:1.2.1'
classpath 'io.fabric.tools:gradle:1.28.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://jitpack.io" }
maven { url "https://maven.google.com" }
}
}

subprojects {
project.configurations.all {
resolutionStrategy.eachDependency { details ->
if (details.requested.group == 'com.android.support'
&& !details.requested.name.contains('multidex') ) {
details.useVersion "27.1.1"
}
}
}
afterEvaluate {
android {
compileSdkVersion 28
buildToolsVersion "28.0.3"

defaultConfig {
targetSdkVersion 28
}
}
}
}
apply plugin: "com.android.application"
apply plugin: "com.google.firebase.firebase-perf"
apply plugin: 'io.fabric'

import com.android.build.OutputFile

project.ext.react = [
entryFile: "index.js",

bundleInDebug: project.hasProperty("bundleInDebug") ? project.getProperty("bundleInDebug") : false,
]

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


def enableSeparateBuildPerCPUArchitecture = false
def enableProguardInReleaseBuilds = false

android {
compileSdkVersion rootProject.ext.compileSdkVersion

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

defaultConfig {
applicationId "com.motowektor.pojazdy"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
versionName "1.0"

// Needed to support API<21, though there is a small chance proguard shrinks things sufficiently
multiDexEnabled true
}
splits {
abi {
reset()
enable enableSeparateBuildPerCPUArchitecture
universalApk false // If true, also generate a universal APK
include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
}
}
signingConfigs {
release {
if (project.hasProperty('MYAPP_UPLOAD_STORE_FILE')) {
storeFile file(MYAPP_UPLOAD_STORE_FILE)
storePassword MYAPP_UPLOAD_STORE_PASSWORD
keyAlias MYAPP_UPLOAD_KEY_ALIAS
keyPassword MYAPP_UPLOAD_KEY_PASSWORD
}
}
}
buildTypes {
release {
minifyEnabled enableProguardInReleaseBuilds
matchingFallbacks = ['release', 'debug']
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
signingConfig signingConfigs.release
}
}
// 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-mail')
implementation project(':react-native-splash-screen')
implementation project(':react-native-fetch-blob')
implementation project(':mapbox-react-native-mapbox-gl')
implementation project(':@react-native-community_async-storage')
implementation project(':react-native-device-info')
implementation project(':react-native-camera-kit')
implementation project(':react-native-vector-icons')
implementation project(':react-native-gesture-handler')
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "com.facebook.react:react-native:+" // From node_modules

implementation project(path: ':react-native-firebase')

implementation "com.google.firebase:firebase-core:16.0.9"
implementation "com.google.android.gms:play-services-base:16.1.0"


implementation('com.google.firebase:firebase-ads:15.0.1') {
exclude group: 'com.android.support', module: 'customtabs'
}

implementation "com.google.firebase:firebase-auth:17.0.0"
implementation "com.google.firebase:firebase-analytics:16.5.0"
implementation "com.google.firebase:firebase-perf:17.0.0"
implementation "com.google.firebase:firebase-config:17.0.0"
implementation "com.google.firebase:firebase-storage:17.0.0"
implementation "com.google.firebase:firebase-dynamic-links:17.0.0"
implementation "com.google.firebase:firebase-database:17.0.0"
implementation "com.google.firebase:firebase-functions:17.0.0"
implementation "com.google.firebase:firebase-firestore:19.0.2"
implementation "com.google.firebase:firebase-messaging:18.0.0"
implementation('com.crashlytics.sdk.android:crashlytics:2.9.9@aar') {
transitive = true
}

implementation "com.android.support:multidex:1.0.3"
implementation "com.android.support:customtabs:27.1.1"
implementation 'me.leolin:ShortcutBadger:1.1.22@aar'
}
task copyDownloadableDepsToLibs(type: Copy) {
from configurations.compile
into 'libs'
}

apply plugin: 'com.google.gms.google-services'

那么我该如何解决呢?

我试图创建一个新项目,安装所有插件并复制MainActivity.java和我的所有React组件,但是它不起作用!

最佳答案

将特定文件的这一行放在react native中。

import React, {Component} from 'react';

关于android - 找不到变量:在构建时 react ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58201935/

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