标签: react-native-android

反应原生 gradlew assembleRelease 构建失败。任务 ':app:mergeReleaseResources' 执行失败

我在运行时遇到了这个错误./gradlew assembleRelease。我已经修修补补了几个小时。请帮助。它曾经成功构建,但是在我尝试清除某些内容并从我的 git 历史记录中组合不同的文件夹之后,没有任何东西可以挽救。


FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:mergeReleaseResources'.
> [raw/app] /home/horhi/code/projects/ankilan/android/app/src/main/res/raw/app.json [raw/app] /home/horhi/code/projects/ankilan/android/app/build/generated/res/react/release/raw/app.json: Error: Duplicate resources
  [raw/node_modules_reactnativevectoricons_glyphmaps_materialcommunityicons] /home/horhi/code/projects/ankilan/android/app/src/main/res/raw/node_modules_reactnativevectoricons_glyphmaps_materialcommunityicons.json[raw/node_modules_reactnativevectoricons_glyphmaps_materialcommunityicons] /home/horhi/code/projects/ankilan/android/app/build/generated/res/react/release/raw/node_modules_reactnativevectoricons_glyphmaps_materialcommunityicons.json: Error: Duplicate resources
  [raw/node_modules_reactnativevectoricons_glyphmaps_fontawesome5free_meta] /home/horhi/code/projects/ankilan/android/app/src/main/res/raw/node_modules_reactnativevectoricons_glyphmaps_fontawesome5free_meta.json[raw/node_modules_reactnativevectoricons_glyphmaps_fontawesome5free_meta] /home/horhi/code/projects/ankilan/android/app/build/generated/res/react/release/raw/node_modules_reactnativevectoricons_glyphmaps_fontawesome5free_meta.json: Error: Duplicate resources
  [raw/node_modules_reactnativevectoricons_glyphmaps_fontawesome] /home/horhi/code/projects/ankilan/android/app/src/main/res/raw/node_modules_reactnativevectoricons_glyphmaps_fontawesome.json[raw/node_modules_reactnativevectoricons_glyphmaps_fontawesome] /home/horhi/code/projects/ankilan/android/app/build/generated/res/react/release/raw/node_modules_reactnativevectoricons_glyphmaps_fontawesome.json: Error: Duplicate resources
  [raw/node_modules_reactnativevectoricons_glyphmaps_fontisto] /home/horhi/code/projects/ankilan/android/app/src/main/res/raw/node_modules_reactnativevectoricons_glyphmaps_fontisto.json   [raw/node_modules_reactnativevectoricons_glyphmaps_fontisto] /home/horhi/code/projects/ankilan/android/app/build/generated/res/react/release/raw/node_modules_reactnativevectoricons_glyphmaps_fontisto.json: Error: Duplicate resources
  [raw/node_modules_reactnativevectoricons_glyphmaps_feather] /home/horhi/code/projects/ankilan/android/app/src/main/res/raw/node_modules_reactnativevectoricons_glyphmaps_feather.json[raw/node_modules_reactnativevectoricons_glyphmaps_feather] /home/horhi/code/projects/ankilan/android/app/build/generated/res/react/release/raw/node_modules_reactnativevectoricons_glyphmaps_feather.json: Error: Duplicate resources
  [raw/node_modules_reactnativevectoricons_glyphmaps_entypo] /home/horhi/code/projects/ankilan/android/app/src/main/res/raw/node_modules_reactnativevectoricons_glyphmaps_entypo.json   [raw/node_modules_reactnativevectoricons_glyphmaps_entypo] /home/horhi/code/projects/ankilan/android/app/build/generated/res/react/release/raw/node_modules_reactnativevectoricons_glyphmaps_entypo.json: Error: Duplicate resources
  [raw/node_modules_reactnativevectoricons_glyphmaps_ionicons] /home/horhi/code/projects/ankilan/android/app/src/main/res/raw/node_modules_reactnativevectoricons_glyphmaps_ionicons.json   [raw/node_modules_reactnativevectoricons_glyphmaps_ionicons] /home/horhi/code/projects/ankilan/android/app/build/generated/res/react/release/raw/node_modules_reactnativevectoricons_glyphmaps_ionicons.json: Error: Duplicate resources
  [raw/node_modules_reactnativevectoricons_glyphmaps_fontawesome5free] /home/horhi/code/projects/ankilan/android/app/src/main/res/raw/node_modules_reactnativevectoricons_glyphmaps_fontawesome5free.json   [raw/node_modules_reactnativevectoricons_glyphmaps_fontawesome5free] /home/horhi/code/projects/ankilan/android/app/build/generated/res/react/release/raw/node_modules_reactnativevectoricons_glyphmaps_fontawesome5free.json: Error: Duplicate …
Run Code Online (Sandbox Code Playgroud)

android gradle ios react-native react-native-android

2
推荐指数
1
解决办法
2819
查看次数

TypeError: (0, _reactNavigation.default) 不是函数。反应本机

我正在使用 React Navigation 版本 4,在设置我的导航和所有屏幕并运行代码后,我面临以下问题:

TypeError: (0, _reactNavigation.default) 不是函数。

我的 Routes.Js 是 -

import React from 'react';
import createAppContainer from 'react-navigation';
import { createStackNavigator, HeaderBackButton } from 'react-navigation-stack';
import { Drawer } from './Drawer';
import LoginScreen from '../screens/LoginScreen';
import InitialScreen from '../screens/InitialScreen';
import LogoutScreen from '../screens/LogoutScreen';

const RootStack = createStackNavigator(
    {
        Drawer: { 
            screen: Drawer
        },
        LoginScreen: {
            screen: LoginScreen
        },
        LogoutScreen: {
            screen: LogoutScreen
        }
        InitialScreen: {
            screen: InitialScreen
        }
    },
    {
        initialRouteName: 'InitialScreen',
        headerMode: "none"
    }
)

const …
Run Code Online (Sandbox Code Playgroud)

reactjs react-native react-native-android react-navigation react-navigation-stack

2
推荐指数
1
解决办法
2572
查看次数

仅在使用自动链接时忽略用于 android 的本机库

0.62.2 中的 React Native 自动链接添加了来自node_modulesios 和 android 的所有 React Native 项目,通过:

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

但是有一个项目我只想在 iphone 应用程序中使用,但不清楚如何告诉 build.gradle 从 android 中排除此依赖项。即使 react native 自动链接器不直接支持这一点,也应该有一种方法来以编程方式迭代给定变体的“实现”依赖项并删除 build.gradle 中的依赖项?

android gradle autolink react-native-android

2
推荐指数
1
解决办法
1040
查看次数

react-native-webview 为什么 goBack() 方法不起作用?

我在 Expo 中有一个简单的 React Native 项目,它使用react-native-webview启动一个网站。

这是源代码:

import React from "react";
import { StyleSheet, View, SafeAreaView } from "react-native";
import { AntDesign } from "@expo/vector-icons";

import { WebView } from "react-native-webview";


export default function App() {
  const goback = () => {
    WebView.goBack();
  };

  return (
    <SafeAreaView>
      <WebView source={{ uri: "https://google.co.uk" }} />
      <View style={styles.navbar}>
        <View style={styles.forward}>
          <AntDesign name="right" size={25} color="grey" />
        </View>
        <View style={styles.back}>
          <AntDesign name="left" size={25} color="grey" onPress={goback} />
        </View>
      </View>
    </SafeAreaView>
  );
}

const styles …
Run Code Online (Sandbox Code Playgroud)

react-native react-native-android react-native-ios expo react-native-webview

2
推荐指数
1
解决办法
4267
查看次数

安装 react-native-image-crop-picker 后构建失败

我已经安装了 react-native-image-crop-picker,当我尝试开始构建时安装时收到以下错误:

* What went wrong:
Execution failed for task ':app:processDebugResources'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
   > Android resource linking failed
     D:\Parentlane\ParentlanePregnancyApp\node_modules\react-native-image-crop-picker\android\build\intermediates\library_manifest\debug\AndroidManifest.xml:10:5-14:15: AAPT: error: unexpected element <queries> found in <manifest>.
Run Code Online (Sandbox Code Playgroud)

我尝试清洁,然后再次运行,但它不起作用。我也启用了 multidex 但这似乎也不起作用。

下面是我的 AndroidManifest.xml

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="com.parentlanepregnancyapp">

    <uses-permission android:name="android.permission.INTERNET" />

    <application
      android:name=".MainApplication"
      android:label="@string/app_name"
      android:icon="@mipmap/ic_launcher"
      android:roundIcon="@mipmap/ic_launcher_round"
      android:allowBackup="false"
      android:theme="@style/AppTheme">
      <activity
        android:name=".MainActivity"
        android:label="@string/app_name"
        android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode"
        android:launchMode="singleTask"
        android:windowSoftInputMode="adjustResize">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
      </activity>
      <activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
    </application>

</manifest>
Run Code Online (Sandbox Code Playgroud)

应用程序/build.gradle

apply plugin: "com.android.application"

import com.android.build.OutputFile



project.ext.react = [
    enableHermes: …
Run Code Online (Sandbox Code Playgroud)

android gradle react-native react-native-android

2
推荐指数
1
解决办法
4230
查看次数

1
推荐指数
1
解决办法
3002
查看次数

react-native:模式中的选择器未显示

当我的Picker嵌入到Modal中时,它不会出现在屏幕上(仅针对android测试)

  renderModal() {
    return (
      <Modal
        transparent={true}
        visible={this.state.showModal}
        onRequestClose={() => this.setState({ modalIsVisible: false })}
        animationType={'fade'}>
        <View
          style={{ backgroundColor:'rgba(0, 0, 0, 0.7)', flex: 1, justifyContent: 'center', padding: 20, height:100 }}>
        <View style={{ borderRadius:10, alignItems: 'center', backgroundColor: '#fff', padding: 20 }}>
          <Text>
            Choisissez la priorité de cet emplacement
          </Text>
          <Picker
            selectedValue={this.state.storagePriority}
            onValueChange={(priority) => this.setState({storagePriority: priority})}>
            <Picker.Item label="Basse" value="LOW" />
            <Picker.Item label="Normale" value="MEDIAN" />
            <Picker.Item label="Haute" value="HIGH" />
            <Picker.Item label="Réserve" value="STOCK" />
          </Picker>
        </View>
        </View>
      </Modal>
    );
  }
Run Code Online (Sandbox Code Playgroud)

有什么建议吗?

picker react-native react-native-android

1
推荐指数
1
解决办法
2426
查看次数

如何检查用户是否已在React Native Android中授予相机权限?

应用启动后,我获得了用户使用相机的许可。但是在打开摄像头之前,如果我检查用户是否已授予摄像头许可,即使允许,我也会得到响应为“ false”。

这是我的代码:

PermissionsAndroid.check('camera').then(response => {
            if (response === true){
                //Open scanner
            }
            else if (response === false){
                Alert("Please enable camera permission in device settings.")
            }
        })
Run Code Online (Sandbox Code Playgroud)

android android-camera react-native react-native-camera react-native-android

1
推荐指数
1
解决办法
2265
查看次数

如何在Visual Studio代码中调试React本机应用程序?

我正在使用Visual Studio代码IDE来开发React本机应用程序,而不是在使用EXPO库。

在此之前,我在android studio上工作,调试非常简单明了。

现在,对于React-native,我想知道如何使用Visual Studio Code IDE调试应用程序?

reactjs react-native react-native-android

1
推荐指数
1
解决办法
1519
查看次数

如何在React Native中重置Firebase身份验证密码

我想知道如何在我的本机项目中重置Firebase电子邮件身份验证密码的密码。我想发送一封电子邮件以重置密码。如何使用以下方法做到这一点

  firebase.auth().sendPasswordResetEmail 
Run Code Online (Sandbox Code Playgroud)

firebase react-native firebase-authentication react-native-android

1
推荐指数
1
解决办法
2515
查看次数