标签: react-native-android

react-native:无法从''.../node_modules/window-size/index.js解析模块`tty`:模块映射中不存在模块

错误

    loading dependency graph, done.
    error: bundling failed: Error: Unable to resolve module `tty` from `/MyWorks/rnTestTrials/myCurrencySample/node_modules/window-size/index.js`: Module does not exist in the module map

    This might be related to https://github.com/facebook/react-native/issues/4968
    To resolve try the following:
      1. Clear watchman watches: `watchman watch-del-all`.
      2. Delete the `node_modules` folder: `rm -rf node_modules && npm install`.
      3. Reset Metro Bundler cache: `rm -rf /tmp/metro-bundler-cache-*` or `npm start -- --reset-cache`.  
      4. Remove haste cache: `rm -rf /tmp/haste-map-react-native-packager-*`.
        at ModuleResolver.resolveDependency (/MyWorks/rnTestTrials/myCurrencySample/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js:158:1476)
        at ResolutionRequest.resolveDependency (/MyWorks/rnTestTrials/myCurrencySample/node_modules/metro/src/node-haste/DependencyGraph/ResolutionRequest.js:92:16)
        at DependencyGraph.resolveDependency …
Run Code Online (Sandbox Code Playgroud)

reactjs react-native react-native-android react-native-ios

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

react-native-firebase - 从 Headless JS 服务打开应用程序/在后台模式下从收到的通知打开应用程序

我读

但这些不是react-native-firebase的解决方案。

我正在react-native-firebase用来处理通知。在前台,一切正常。我坚持使用后台状态。

我正在做一个聊天项目并制作一对一通话功能。当客户有电话时,我会向他们推送数据通知。在 iOS 中,我在客户端收到通知时使用了 CallKit,它运行良好。但是在 Android 中我有一个问题:我可以显示 ConnectionService UI 进行调用,但无法连接到我的 Web 套接字服务器,因为它在 Headless JS 服务上运行。所以我尝试自动打开应用程序。我想将呼叫屏幕显示为 Skype,并接受/拒绝呼叫。(Skype 可以在我有电话时启动该应用程序)

总结,成功步骤:

  • 在前台状态接收呼叫通知并显示呼叫屏幕。
  • 在后台/关闭状态下接收呼叫通知并在 iOS 上显示呼叫屏幕。
  • 在 Android 上在后台/关闭状态下接收呼叫通知。

卡在这里:

  • 在后台显示呼叫屏幕/在 Android 上关闭???

TL;DR - 如何从 Headless JS 服务启动/运行/打开 Android 应用程序?

我深入研究 react-native-firebase,它捕获通知onMessageReceived并将通知消息发送到 Headless JS 服务。

// If the app is in the background we send it to the Headless JS Service Intent headlessIntent = new Intent( this.getApplicationContext(), RNFirebaseBackgroundMessagingService.class …

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

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

React-Native:通常使用 react-native-image-crop-picker 和 Camera 使用 openCamera 时在 android 上崩溃

我在一加 6 上打开相机时遇到了 react-native-image-picker 和 react-native-image-crop-picker 的问题。使用打开相机时,打开相机的后台应用程序(我的应用程序)崩溃。它进入白屏并重新启动应用程序。此外,react-native log-android 中没有日志。我确实设法使用 android studio 和 logcat 发现一旦相机打开应用程序就会立即崩溃并留下一个死的进程。问题是我找不到任何实际的崩溃日志。尽管事先我收到了很多“访问被拒绝找到属性“vendor.debug.egl.swapinterval””,但经过一些研究,这些信息似乎并不相关。

目前这个问题只发生在我的一加 6T 上。这些问题不会发生在模拟器或 IOS 上。即使不是在我试过的 xiamoi 设备上。

我已经尝试了从在图像裁剪选择器中压缩图像(代码一)到尝试压缩图像并在 react-native-image-picker(代码二)中使用 noData 标志的所有方法。另外,100%有权限,甚至可以在应用权限=>{我的应用}中的android系统权限中看到它此外,我尝试清理我的一加6t相机的缓存,卸载-重新安装我的应用,并将开发者选项重置为默认。

我基本上已经解决了 github 中两个库的所有问题,但没有任何效果。

ImagePicker.openCamera({
                width: 800,
                height: 600,
                compressImageMaxWidth: 640,
                compressImageMaxHeight: 480,
                compressImageQuality: 0.8
            }).then(image => {
                console.log(image);
            }).catch(e => console.log(e));
Run Code Online (Sandbox Code Playgroud)
ImagePicker.launchCamera({noData: true, maxWidth: 800, maxHeight: 600, quality: 0.8}, (response) => {
  console.log('Response = ', response);

  if (response.didCancel) {
    console.log('User cancelled image picker');
  } else if (response.error) {
    console.log('ImagePicker Error: ', response.error);
  } else if …
Run Code Online (Sandbox Code Playgroud)

react-native react-native-android react-native-image-picker

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

任务“:app:compileDebugJavaWithJavac”执行失败。> 找不到 tools.jar

执行时出现此错误

react-native run-android
Run Code Online (Sandbox Code Playgroud)

我尝试将 tools.jar 文件复制到 JRE 安装位置,重新安装 JDK 和 JRE,检查路径的环境变量。没有任何效果。

它返回以下异常

info Starting JS server...
info Building and installing the app on the device (cd android && gradlew.bat app:installDebug)...
Starting a Gradle Daemon, 1 stopped Daemon could not be reused, use --status for details
> Task :app:compileDebugJavaWithJavac FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:compileDebugJavaWithJavac'.
> Could not find tools.jar. Please check that C:\Program Files (x86)\Java\jre1.8.0_211 contains a valid JDK installation …
Run Code Online (Sandbox Code Playgroud)

reactjs react-native react-native-android

6
推荐指数
2
解决办法
3674
查看次数

React Native 中地图内容的底部,类似于谷歌地图 UI

我正在尝试在 Android 上实现类似于谷歌地图“探索”的 UI 布局,(参见gif)在 React Native 中。

在我的 UI 设计中,我在屏幕底部有应用程序导航选项卡,具有完整的页面地图背景,覆盖有来自选项卡上方的“底部工作表”,以及顶部的搜索框组件。请参阅下面的 UI 草图。

界面设计

我发现了各种看起来很有用的 react-native ui 组件,但我无法弄清楚将它们排列在我想要的布局中的样式。

我正在查看的几个底部组件,例如 rn-bottom-drawer 显示的 gifs 类似于我尝试创建的内容,例如这个动画,但我找不到该 UI 的实际代码示例创建。例如,同一个库示例仅在空屏幕上显示底部抽屉。

什么样的包装元素和样式组合可以让我创建所描述的布局?我来自 XAML 背景,这种布局很容易创建,但我无法理解如何在 React Native 中做到这一点。

react-native bottom-sheet react-native-android react-native-flexbox

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

反应原生android TransactionTooLargeException

我们最近发布了一个 ReactNative 应用程序,但我们收到了许多关于 android 的崩溃报告,其中包含java.lang.RuntimeExceptionBinder.java android.os.TransactionTooLargeException: data parcel size X(between 400k to 750k) bytes.

在我们的应用程序中,我们有一个无限滚动列表(Flatlist),它可以变得非常大(2k + 记录),这被怀疑是导致此问题的原因。我已经看到https://github.com/facebook/react-native/issues/19458打开了,但没有解决方案。还使用建议的工具(TooLargeTool)在那里指出在进入后台时会保存 0 个字节。

有没有人解决过这个问题或对如何解决它有任何意见?

谢谢

android react-native react-native-android transactiontoolargeexception

6
推荐指数
0
解决办法
363
查看次数

如何定位 React Native Picker 的下拉菜单

我正在尝试在 React Native android 应用程序中显示下拉菜单。我为此目的使用了 React Native Picker,但它在样式和下拉菜单定位方面似乎非常有限。我无法让菜单在carret(向下箭头按钮)位置下方弹出。

我尝试设置边距,希望将菜单向下推,但无济于事。

              <Picker
                // selectedValue={stateValue}
                style={{
                  height: 36,
                  width: 261,
                }}
                onValueChange={itemValue => {
                  console.log('item value ', itemValue);
                }}
              >
                <Picker.Item key={-1} label={'Search By...'} value="first" />
                {this.searchCategory.map((item, index) => (
                  <Picker.Item key={index} label={item} value={item} />
                ))}
              </Picker>
            </View>
Run Code Online (Sandbox Code Playgroud)

菜单始终覆盖 Picker 组件。我希望它出现在选择器下方。

实际行为:

实际行为

预期行为: 在此处输入图片说明

react-native react-native-android

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

当我的应用程序关闭以获取 fcm 消息时,如何修复错误“没有为密钥 RNFirebaseBackgroundMessage 注册任务”

我的 AndroidManifest 是

在此处输入图片说明

在我写的索引中 AppRegistry.registerHeadlessTask('RNFirebaseBackgroundMessage', () => firebaseBackgroundMessage);

这firebaseBackgroundMessage是一个功能如下

export async function firebaseBackgroundMessage(message: RemoteMessage) { 
let notif=message['data']; console.log(notif); return Promise.resolve();}
Run Code Online (Sandbox Code Playgroud)

我在后台和前台状态收到 fcm 消息,但是

在关闭状态没有收到任何 fcm 消息,在控制台日志中我有这个错误

 No task registered for key RNFirebaseBackgroundMessage
Run Code Online (Sandbox Code Playgroud)

任何解决方案?非常感谢您的帮助...

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

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

为什么在更新到 macOS catalina 后立即在 react-native 中出现“Watchman crawl failed”错误?

尝试react-native run-ios从 xcode运行或构建 RN 项目,一旦 Metro bundler 启动,终端中就会出现此错误:

Loading dependency graph...jest-haste-map: Watchman crawl failed. Retrying once with node crawler.
  Usually this happens when watchman isn't running. Create an empty `.watchmanconfig` file in your project's root folder or initialize a git or hg repository in your project.
  Error: Watchman error: resolve_projpath: path `/Users/vorousjames/Desktop/Development/TicTacWHOA/app/TicTacWHOA`: open: /Users/vorousjames/Desktop/Development/TicTacWHOA/app/TicTacWHOA: Operation not permitted. Make sure watchman is running for this project. See https://facebook.github.io/watchman/docs/troubleshooting.html.
events.js:183
      throw er; // Unhandled 'error' event
  ^

Error: resolve_projpath: path …
Run Code Online (Sandbox Code Playgroud)

terminal watchman react-native react-native-android react-native-ios

6
推荐指数
4
解决办法
7274
查看次数

react-native-webview 加载本地 HTML 文件但得到纯文本

我尝试加载一个依赖于其他 .js 文件的 HTML 文件。

所以我写了这样的代码,但在 webview 中得到了纯文本。

render = () => {
    let source;
    if (__DEV__) {
      source = require('./vendor/Editor/index.html');
    } else {
      source =
        Platform.OS === 'ios'
          ? require('./vendor/Editor/index.html')
          : {uri: 'file:///android_asset/vendor/Editor/index.html'};
    }

    return (
      <WebView
        startInLoadingState
        source={source}
        onMessage={this.handleMessage}
        automaticallyAdjustContentInsets={false}
        style={[
          AppStyles.container,
          styles.container,
          {height: this.state.visibleHeight},
        ]}
      />
    );
  };
Run Code Online (Sandbox Code Playgroud)

在此处输入图片说明

我像这样简化了代码,但它也不起作用。

  render = () => {
    setTimeout(() => {
      this.webview.injectJavaScript(
        'window.ReactNativeWebView.postMessage(document.body.innerHTML)',
      );
    }, 3000);

    return (
      <WebView
        source={require('./vendor/GrEditor/index.html')}
        onMessage={e => console.log('e: ', e)}
      />
    );
  };
Run Code Online (Sandbox Code Playgroud)

抱歉语法不好。

javascript reactjs react-native react-native-android react-native-webview

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