Giter Site home page Giter Site logo

reactnativecn / react-native-website Goto Github PK

View Code? Open in Web Editor NEW

This project forked from facebook/react-native-website

216.0 11.0 327.0 510.91 MB

React Native 中文网

Home Page: https://reactnative.cn

License: MIT License

JavaScript 56.21% CSS 4.94% HTML 2.09% SCSS 30.27% TypeScript 0.52% MDX 5.96%

react-native-website's Introduction

reactnativecn/react-native/

This repo contains a clone and a Chinese translated version of offcial React Native website.

Sync with official repo

facebook:main -> production

This repo contains the website configuration and documentation powering the React Native website.

If you are looking for the source code of the React Native Archive website select the archive branch.

Contents

✈️ Getting started

Prerequisites

  1. Git.
  2. Node (version 12 or greater).
  3. Yarn (version 1.5 or greater).
  4. A fork of the repo (for any contributions).
  5. A clone of the react-native-website repo.

Installation

  1. cd react-native-website to go into the project root.
  2. Run yarn to install the website's workspace dependencies.

Running locally

  1. cd website to go into the website portion of the project.
  2. yarn start to start the development server (powered by Docusaurus).
  3. Open http://localhost:3000/ site in your favorite browser.

📖 Overview

If you would like to contribute an edit or addition to the docs, read through our style guide before you write anything. Almost all our content is generated from markdown files you can find in the docs, website/architecture and website/contributing directories.

To edit the internals of how the site is built, you may want to get familiarized with how the site is built. The React Native website is a static site generated using Docusaurus. The website configuration can be found in the website directory. Visit the Docusaurus website to learn more about all the available configuration options.

Directory Structure

The following is a high-level overview of relevant files and folders.

react-native-website/
├── docs/
│   ├── [BASE VERSIONED DOC FILES]
│   └── ...
└── website/
    ├── architecture/
    │   ├── [ARCHITECTURE DOC FILES]
    │   └── ...
    ├── blog/
    │   ├── [BLOG POSTS]
    │   └── ...
    ├── contributing/
    │   ├── [CONTRIBUTING DOC FILES]
    │   └── ...
    ├── core/
    │   ├── [CUSTOM COMPONENTS]
    │   └── ...
    ├── src/
    │   ├── css/
    │   │   ├── [CUSTOM STYLES]
    │   │   └── ...
    │   ├── pages/
    │   │   ├── [STATIC PAGES]
    │   │   └── ...
    │   └── theme/
    │   │   ├── [SWIZZLED COMPONENTS]
    │   │   └── ...
    ├── static/
    │   ├── blog/
    │   │   └── assets/
    │   ├── docs/
    │   │   └── assets/
    │   └── img/
    ├── versioned_docs/
    │   ├── [GENERATED VERSIONED DOC FILES]
    │   └── ...
    ├── versioned_sidebars/
    │   ├── [GENERATED VERSIONED SIDEBARS]
    │   └── ...
    ├── docusaurus.config.js
    ├── package.json
    ├── showcase.json
    ├── sidebars.json
    ├── sidebarsArchitecture.json
    ├── sidebarsContributing.json
    └── versions.json

Documentation sources

As mentioned above, the docs folder contains the source files for docs from "Guides", "Components" and "APIs" tabs on the React Native website (versioned docs). The doc files for the "Architecture" and "Contribution" tabs are located inside website in the respective directories (unversioned/static docs). In most cases, you will only want to edit the files within those directories.

If you're adding a new doc or you need to alter the order the docs appear in the sidebar, take a look at the sidebars.json, sidebarsArchitecture.json and sidebarsContributing.json files in the website directory. The sidebar files contain a list of document ids that should match those defined in the header metadata (aka frontmatter) of the docs markdown files.

Versioned docs

Part of the React Native website is versioned to allow users to go back and see the Guides or API reference documentation for any given release. A new version of the website is generally generated whenever there is a new React Native release. When this happens, any changes made to the docs and website/sidebars.json files will be copied over to the corresponding location within website/versioned_docs and website/versioned_sidebars.

Note: Do not edit the auto-generated files within versioned_docs or versioned_sidebars unless you are sure it is necessary. Edits made to older versions will not be propagated to newer versions of the versioned docs.

Docusaurus keeps track of the list of versions for the site in the website/versions.json file. The ordering of versions in this file should be in reverse chronological order.

Cutting a new version

After RC

The React Native website lints and typechecks documents in "next". The version of React Native used by the linter should be updated before a release for consistency and to catch any documents/examples where APIs have changed.

This can be done by updating the package.json and configuration files in script/lint-examples the same way a React Native application would be updated. The diff of these files can be seen using a tool like React Native Upgrade Helper.

After Release
  1. cd react-native-website to go into the project root.
  2. cd website to go into the website portion of the project.
  3. Run yarn version:cut <newVersion> where <newVersion> is the new version being released.

🔧 Website configuration

The main config file for the website can be found at website/docusaurus.config.js. This file tells Docusaurus how to build the website. Edits to this file are rarely necessary.

The core subdirectory contains JavaScript and React components that are the core part of the website.

The src/pages subdirectory contains the React components that make up the non-documentation pages of the site, such as the homepage.

The src/theme subdirectory contains the swizzled React components from the Docusaurus theme.

The showcase.json file contains the list of users that are highlighted in the React Native showcase.

👏 Contributing

Create a branch

  1. git checkout main from any folder in your local react-native-website repository.
  2. git pull origin main to ensure you have the latest main code.
  3. git checkout -b the-name-of-my-branch to create a branch.

    replace the-name-of-my-branch with a suitable name, such as update-animations-page

Make the change

  1. Follow the "Running locally" instructions.
  2. Save the files and check in the browser.
  3. Some changes may require a server restart to generate new files. (Pages in docs always do!)
  4. Edits to pages in docs will only be visible in the latest version of the documentation, called "Next", located under the docs/next path.

Visit http://localhost:3000/docs/next/YOUR-DOCS-PAGE to see your work.

Visit http://localhost:3000/versions to see the list of all versions of the docs.

Test the change

If possible, test any visual changes in all latest versions of the following browsers:

  • Chrome and Firefox on the desktop.
  • Chrome and Safari on mobile.

Push it

  1. Run yarn prettier and yarn language:lint in ./website directory to ensure your changes are consistent with other files in the repo.
  2. git add -A && git commit -m "My message" to stage and commit your changes.

    replace My message with a commit message, such as Fixed header logo on Android

  3. git push my-fork-name the-name-of-my-branch
  4. Go to the react-native-website repo and you should see recently pushed branches.
  5. Follow GitHub's instructions.
  6. Describe briefly your changes (in case of visual changes, please include screenshots).

📄 License

React Native is MIT licensed.

React Native documentation is Creative Commons licensed.

react-native-website's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

react-native-website's Issues

iOS打包总是卡在最后不动

iOS打包总是卡在最后一点就不动了,是不是缺少什么东西,项目Libraries目录下为空是正常的吗,用的是0.62版本的rn。
Snipaste_2020-04-14_19-09-16
Snipaste_2020-04-14_19-26-33

原生嵌套RN,如何集成 react-navigation?

我原生嵌套RN,然后集成react-navigation3X 4X版本都有一个link的操作,但是原生集成RN,是没有继承reactActivity类的,然后 RN添加 如下配置
"react-native-gesture-handler": "^1.6.1",
"react-native-reanimated": "^1.7.1",
"react-native-safe-area-context": "^0.7.3",
"react-native-screens": "^2.4.0",
"react-navigation": "^4.3.6"

会把我原生里面的
image
这个版本从60.5变成20.0导致,方法找不到报错;
image
此处也指定版本了,

react native如何使用Fetch下载图片

后端使用xsrf-token验证,使用RNFetblob下载图片后,将xsrf-token保存到global,下个接口取出来使用iOS报403错误,Android正常。求助一下这个问题该如何解决

初始化项目红屏(能访问localhost:8081但不能访问bundle,卸载watchman后正常)

作为一个初学者,红屏问题搞了半天始终不解,请教各位大佬

按照最新的react native 中文网搭建环境,该装的工具都装上了,初始化项目也完成了,iOS的pod 安装也通过国内镜像安装上了。就是在运行起来的时候,报了红屏错误。

**_Could not connect to development server.

Ensure the following:

  • Node server is running and available on the same network - run 'npm start' from react-native root
  • Node server URL is correctly set in AppDelegate
  • WiFi is enabled and connected to the same network as the Node Server

URL: http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false

RCTFatal
__28-[RCTCxxBridge handleError:]_block_invoke
_dispatch_call_block_and_release
_dispatch_client_callout
_dispatch_main_queue_callback_4CF
CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE
_CFRunLoopRun
CFRunLoopRunSpecific
GSEventRunModal
UIApplicationMain
main
**

根据这个错误,查看服务确实是启动的,网络环境也是同一个环境,AppDelegate.m网上查找问题说在这个文件下需要配置自己的IP地址,不过好像新版本的,代码有改动,已经没有一个叫jsCodeLocation的了。IP也尝试了手动去设置,也没有效果。

求教下各位大佬,是哪里有问题么,还是我需要配置什么东西

对AsyncStorage的getItem方法进行封装后,在别的组件中调用时得到的值总是[Object object]

RN版本为3.3
如果在图1的then函数中打印输出jsonValue的值,可以看到数据,但在别的组件调用这个方法时,返回的却是Object。我理解的then函数就是等待它前面的方法执行完毕,然后根据前面方法返回的值做操作,我查了半天资料认为就是then没处理好,但具体错在哪又不知

1-先上AsyncStorage代码:
10000000

2-在另一个组件中调用:
20000000000000

3-调用后返回的结果:
300000

搭建开发环境 页面优化提议

目前在从0开始运行一个已有的RN项目,按照目前的指引操作发现运行react-native run-android会提示react-native 命令找不到。仔细查看了文档并没有相关说明只有“如果你之前全局安装过旧的react-native-cli命令行工具,请使用npm uninstall -g react-native-cli卸载掉它以避免一些冲突。”希望可以加入添加react-native-cli的指导。

RN 0.59.10 启动出错:Module `AccessibilityInfo` does not exist in the Haste module map

通过 yarn start 启动的时候发现异常:

Loading dependency graph, done.
BUNDLE [dev] ./index.js ░░░░░░░░░░░░░░░░ 0.0% (0/1)::1 - - [02/Apr/2020:13:34:24 +0000] "GET /index.bundle HTTP/1.1" 500 - "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36"
error: bundling failed: Error: Unable to resolve module AccessibilityInfo from /Users/coolqi/GitHubCode/AwesomeProject/node_modules/react-native/Libraries/react-native/react-native-implementation.js: Module AccessibilityInfo does not exist in the Haste module map

This might be related to facebook/react-native#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 (/Users/coolqi/GitHubCode/AwesomeProject/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js:183:15)
    at ResolutionRequest.resolveDependency (/Users/coolqi/GitHubCode/AwesomeProject/node_modules/metro/src/node-haste/DependencyGraph/ResolutionRequest.js:52:18)
    at DependencyGraph.resolveDependency (/Users/coolqi/GitHubCode/AwesomeProject/node_modules/metro/src/node-haste/DependencyGraph.js:283:16)
    at Object.resolve (/Users/coolqi/GitHubCode/AwesomeProject/node_modules/metro/src/lib/transformHelpers.js:261:42)
    at /Users/coolqi/GitHubCode/AwesomeProject/node_modules/metro/src/DeltaBundler/traverseDependencies.js:399:31
    at Array.map ()
    at resolveDependencies (/Users/coolqi/GitHubCode/AwesomeProject/node_modules/metro/src/DeltaBundler/traverseDependencies.js:396:18)
    at /Users/coolqi/GitHubCode/AwesomeProject/node_modules/metro/src/DeltaBundler/traverseDependencies.js:269:33
    at Generator.next ()
    at asyncGeneratorStep (/Users/coolqi/GitHubCode/AwesomeProject/node_modules/metro/src/DeltaBundler/traverseDependencies.js:87:24)

RN0.61.5使用SwipeableFlatList报错,使用FlatList正常。

使用SwipeableFlatList报错,使用FlatList正常。
1.Invariant Violation: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.

Check the render method of ManageAccount.
2.已经导入组件 SwipeableFlatList
3.RN0.61.5

react-native自定义的一个组件内部部分内容onPress无效

自己写了一个下拉组件。
Screenshot_2020-03-17-13-52-32-954_com awesomepro

问题

组件的头部是已选择的option,添加了点击事件可以正常触发,下部的options采用的是position:"absolute"定位,但是列表添加的点击事件没有反应。

我的解决方法(有些奇怪)

如果设置组件的整体高度height增加到能够容纳options的高度,则option的点击事件才可以正常出发。
所以一个组件内的onPress事件必须是组件内的元素在组件的宽高区域范围内才能触发吗?

求助,初始化项目运行报错undefined is not an object (evaluating 'warnings.length')

这是配置的环境
image

初始化项目的react native 版本是0.57.8
系统是win10 64

报错截图
image
image

根据错误提示找到报错的位置
image

不是很明白为什么报错了,项目是初始化的,没加其他的代码进去,之前在另一台电脑用react native开发也没出现过这个问题,现在新配的环境运行就报错,奇怪的是我初始化最新版的react native 0.61.5又没有报这个错误,想问下有没有人遇到过这个问题。

[新手必读]RN环境搭建/入门学习的一些注意事项

一切非官方博客、教程、讨论仅供参考,请始终以官方文档(请思考什么是官方?)为准


避免在用户名、目录名、文件名、变量名等处使用中文、空格等特殊字符

工具链中任意一处对特殊字符处理不好就会导致莫名其妙且难以察觉的错误。不要挖这样的坑。请不要使用和核心模块同名的目录名(如react,react-native等,父目录也不行)。也请不要单独使用编程语言中常见的关键字作为目录名(如class, native, new, package等等)


完整原生环境 VS 简易沙盒环境(CRNA / Expo)

推荐配置完整原生环境,虽然,比较麻烦😓
沙盒环境依赖于国外网络环境,不能直接发布应用,
也不能安装国内所常用的原生依赖库。不建议国内用户使用。


我只有Windows电脑,可以同时编写两个平台的代码吗?

可以。RN代码在逻辑层上是直接复用的,只是在不同平台上编译不同的原生“壳子”。注意事项:

  • 不要直接复制、移动项目,务必使用git管理和分发项目,不要上传node_modules目录。
  • 不要使用仅支持单平台的组件。

可以把代码移植到网页/小程序/……上吗?

官方并不直接支持其他平台。但github上可能有其他个人或组织提供了各种方案,
react-native-web, react-native-dom, reactXP, taro等等, 具体是否符合你的需求,需要你自己调研和评估。


推荐什么(免费)工具XX上网?

所有工具其实都是免费公开下载的,尽管其技术实现各有差异,但基本的原理都是依靠外面的服务器实现代理上网。然而服务器显然没有理由白白贡献给谁用,所谓的免费工具常常遭遇定时断开、限流、广告等也不难理解。要想获得稳定的网络,自己购买服务器,自己(学习)搭建代理是第一选择。请仅用于学习工作,不要用于非法用途。


为什么我使用了工具,网页也能打开,还是安装失败?

代理工具本身都需要对系统的网络配置进行介入和修改。这一过程有的可以自动配置,有的不能,有的甚至需要特定的工具或者协议转换。所以不代表所有工具都能自动让所有程序稳定访问代理(常见的例子是有的工具默认对浏览器做了配置,但命令行却没有生效)。相关知识和配置请自行研究学习。


关于版本选择

如果没有特殊需求,建立新项目始终选择默认的最新版本

  • RN仍然处于高速迭代中,并没有人建立全面的测试场景和标准,也没有人去做不同版本的评测,而官方基本只维护最新版本。

谨慎选择编译工具链版本

  • 所谓编译工具链是指JDK、Node、Xcode、Android Studio、Gradle、Python等编译RN时所依赖的底层工具,建议选择文档所要求的最低版本

谨慎对待这些工具的更新提示,谨慎使用macOS的自动更新和brew的upgrade命令。如果不是相关领域的专家,请勿主动尝试新版本,尤其是大版本更新。

如果你的所有版本都符合文档要求,仍然遭遇错误,请不要犹豫,去issue区提出问题。


请分辨可靠的信息来源

信息可靠度排序(同时请结合考虑版本、修改时间等因素):

  • Github官方仓库源码
  • 官方网站文档、官方博客
  • 官方网站文档翻译版
  • Github官方仓库issue版块的讨论

——————以下资料来源,如果没有官方出处,都不可靠

  • StackOverflow,专业论坛,博客, QQ群,贴吧,知道……

请使用Markdown语法

请任意找一篇教程熟悉md语法,例如 https://www.jianshu.com/p/191d1e21f7ed
提问时,请务必将你的代码用markdown语法扩起来,否则格式紊乱,难以阅读。
最基本的用法就是用三个撇号(数字1键左边)上下把代码包起来,像下面这样

f857e0c9-e558-42b5-a283-f7ac978d78f6-image


这样代码就会自动排版且带有语法高亮

使用fetch访问http网页报TypeError: Network request failed错误

我使用expo构建项目,
android虚拟机版本10,
文档中提到了
**默认情况下,iOS 会阻止所有 http 的请求,以督促开发者使用 https。如果你仍然需要使用 http 协议,那么首先需要添加一个 App Transport Security 的例外,详细可参考这篇帖子。

从 Android9 开始,也会默认阻止 http 请求,请参考相关配置**
我根据官方提供的文档https://blog.csdn.net/qq_40347548/article/details/86766932想对android进行配置,但在expo的目录下没发现相关的文件夹(如下图)
image请问我该如何配置android端。

这是我的代码:
image

报错信息:
image

初始化项目时出错了

按照官网进行初始化项目报错,请帮我解决问题,谢谢!
步骤:
sudo gem install cocoapods -v 1.8.4
cd app/ios
pod install
屏幕快照 2020-04-26 上午10 27 53
这是我的配置参数:
屏幕快照 2020-04-26 上午10 29 38

0.61版本启动报错

报错内容如下:
Connection to localhost port 8081 [tcp/sunproxyadmin] succeeded!
Port 8081 already in use, packager is either not running or not running correctly
Command /bin/sh failed with exit code 2

是0.61版本的项目,请问有什么好的解决办法嘛?

导入的方法超过64K

The number of method references in a .dex file cannot exceed 64K.
百度原因为安卓限制方法数在64K一下,按照安卓的解决方法,配置dex分区,无法解决。

build release fail : failed linking references.

用了 react-native-qq,打包 release 的时候出现这个错误

Execution failed for task ':react-native-qq:verifyReleaseResources'.
> 1 exception was raised by workers:
  com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource linking failed
  error: resource android:style/TextAppearance.Material.Widget.Button.Borderless.Colored not found.
  error: resource android:style/TextAppearance.Material.Widget.Button.Colored not found.
  D:\Dev\qqPorject\node_modules\react-native-qq\android\build\intermediates\res\merged\release\values-v26\values-v26.xml:7: error: resource android:attr/colorE
rror not found.
  D:\Dev\qqPorject\node_modules\react-native-qq\android\build\intermediates\res\merged\release\values-v26\values-v26.xml:11: error: resource android:attr/color
Error not found.
  D:\Dev\qqPorject\node_modules\react-native-qq\android\build\intermediates\res\merged\release\values-v26\values-v26.xml:15: error: style attribute 'android:at
tr/keyboardNavigationCluster' not found.
  D:\Dev\qqPorject\node_modules\react-native-qq\android\build\intermediates\res\merged\release\values-v28\values-v28.xml:7: error: resource android:attr/dialog
CornerRadius not found.
  D:\Dev\qqPorject\node_modules\react-native-qq\android\build\intermediates\res\merged\release\values-v28\values-v28.xml:11: error: resource android:attr/dialo
gCornerRadius not found.
  D:\Dev\qqPorject\node_modules\react-native-qq\android\build\intermediates\res\merged\release\values\values.xml:2740: error: resource android:attr/fontStyle n
ot found.
  D:\Dev\qqPorject\node_modules\react-native-qq\android\build\intermediates\res\merged\release\values\values.xml:2741: error: resource android:attr/font not fo
und.
  D:\Dev\qqPorject\node_modules\react-native-qq\android\build\intermediates\res\merged\release\values\values.xml:2742: error: resource android:attr/fontWeight
not found.
  D:\Dev\qqPorject\node_modules\react-native-qq\android\build\intermediates\res\merged\release\values\values.xml:2743: error: resource android:attr/fontVariati
onSettings not found.
  D:\Dev\qqPorject\node_modules\react-native-qq\android\build\intermediates\res\merged\release\values\values.xml:2744: error: resource android:attr/ttcIndex no
t found.
  D:\Dev\qqPorject\node_modules\react-native-qq\android\build\intermediates\res\merged\release\values\values.xml:2908: error: resource android:attr/startX not
found.
  D:\Dev\qqPorject\node_modules\react-native-qq\android\build\intermediates\res\merged\release\values\values.xml:2911: error: resource android:attr/startY not
found.
  D:\Dev\qqPorject\node_modules\react-native-qq\android\build\intermediates\res\merged\release\values\values.xml:2914: error: resource android:attr/endX not fo
und.
  D:\Dev\qqPorject\node_modules\react-native-qq\android\build\intermediates\res\merged\release\values\values.xml:2917: error: resource android:attr/endY not fo
und.
  D:\Dev\qqPorject\node_modules\react-native-qq\android\build\intermediates\res\merged\release\values\values.xml:2925: error: resource android:attr/offset not
found.
  error: failed linking references.

环境:

"react": "16.9.0",
"react-native": "0.61.5",
"react-native-qq": "^2.0.5",

运行ios模拟器XCode报错找不到YogaKit.modulemap,

Showing Recent Issues
Module map file '/Users/dj/Library/Developer/Xcode/DerivedData/AwesomeProject-dpvrawzwepqesyboeiienbjfwzxb/Build/Products/Debug-iphonesimulator/YogaKit/YogaKit.modulemap' not found

但是我根据路径去找是有看到YogaKit.modulemap,这个问题是出在哪呢

React Native 配置 -ObjC 之后与 SDL 冲突

因为项目要集成 SDL,如果配置了-ObjC 的话就会报错:

Undefined symbols for architecture arm64:
"_SDL_main", referenced from:
-[SDLUIKitDelegate postFinishLaunch] in libSDL2.a(SDL_uikitappdelegate.o)
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

而删除 -ObjC 的话 React Native 就会报错:

Undefined symbols for architecture arm64:
"OBJC_CLASS$_RCTReconnectingWebSocket", referenced from:
objc-class-ref in libReact.a(RCTPackagerConnection.o)
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

不知道哪位大佬能帮忙解决一下?多谢!

请教一个安卓打包的问题

最近被一个奇葩的问题困扰。
我本地有个项目,运行 react-native run-android 打包出来的 .apk 文件是60多M;
然后我将该项目进行分发,如上传至svn,再拉取下来,一样的代码,执行npm install
再执行react-naitve run-android,结果打包出来的.apk文件只有40多M了。经排查,
项目中引用的安卓原生代码模块功能有些缺失。项目集成了一个百度语音输入,通过
Native Module引入桥接,诡异的是javascript中能输出该模块的方法、属性,但功能
就是不正常,而且打包出来的安装包体积变小。疑似android\app\src\main\jniLibs目录
下一些自己添加的文件没有正常打包。如图一中jniLibs为集成百度语音输入的一些依赖
文件,打包出来的.apk文件大小差额差不多就是这个文件夹的大小。
图一
不懂安卓原生,查了一些文档,最终也没解决这个问题,不知道您有什么指导思路可以
提供一下吗?

Mac端真机调试报错

按照官网的教程连接真机调试报错,在ios文件夹内pod install也不行。

CompileC /Users/ykk/Library/Developer/Xcode/DerivedData/AwesomeProject-czhnrdedsnmsxpcstdgrpapbjuwt/Build/Intermediates.noindex/AwesomeProject.build/Debug-iphoneos/AwesomeProject.build/Objects-normal/arm64/AwesomeProject_vers.o /Users/ykk/Library/Developer/Xcode/DerivedData/AwesomeProject-czhnrdedsnmsxpcstdgrpapbjuwt/Build/Intermediates.noindex/AwesomeProject.build/Debug-iphoneos/AwesomeProject.build/DerivedSources/AwesomeProject_vers.c normal arm64 c com.apple.compilers.llvm.clang.1_0.compiler (in target 'AwesomeProject' from project 'AwesomeProject')
cd /Users/ykk/AwesomeProject/ios
export LANG=en_US.US-ASCII
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -x c -target arm64-apple-ios9.0 -fmessage-length=0 -fdiagnostics-show-note-include-stack -fmacro-backtrace-limit=0 -std=gnu99 -fmodules -gmodules -fmodules-cache-path=/Users/ykk/Library/Developer/Xcode/DerivedData/ModuleCache.noindex -fmodules-prune-interval=86400 -fmodules-prune-after=345600 -fbuild-session-file=/Users/ykk/Library/Developer/Xcode/DerivedData/ModuleCache.noindex/Session.modulevalidation -fmodules-validate-once-per-build-session -Wnon-modular-include-in-framework-module -Werror=non-modular-include-in-framework-module -Wno-trigraphs -fpascal-strings -O0 -fno-common -Wno-missing-field-initializers -Wno-missing-prototypes -Werror=return-type -Wunreachable-code -Werror=deprecated-objc-isa-usage -Werror=objc-root-class -Wno-missing-braces -Wparentheses -Wswitch -Wunused-function -Wno-unused-label -Wno-unused-parameter -Wunused-variable -Wunused-value -Wempty-body -Wuninitialized -Wconditional-uninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wconstant-conversion -Wint-conversion -Wbool-conversion -Wenum-conversion -Wno-float-conversion -Wnon-literal-null-conversion -Wobjc-literal-conversion -Wshorten-64-to-32 -Wpointer-sign -Wno-newline-eof -DDEBUG=1 -DCOCOAPODS=1 -DFB_SONARKIT_ENABLED=1 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.4.sdk -fstrict-aliasing -Wdeprecated-declarations -g -Wno-sign-conversion -Winfinite-recursion -Wcomma -Wblock-capture-autoreleasing -Wstrict-prototypes -Wno-semicolon-before-method-body -index-store-path /Users/ykk/Library/Developer/Xcode/DerivedData/AwesomeProject-czhnrdedsnmsxpcstdgrpapbjuwt/Index/DataStore -iquote /Users/ykk/Library/Developer/Xcode/DerivedData/AwesomeProject-czhnrdedsnmsxpcstdgrpapbjuwt/Build/Intermediates.noindex/AwesomeProject.build/Debug-iphoneos/AwesomeProject.build/AwesomeProject-generated-files.hmap -I/Users/ykk/Library/Developer/Xcode/DerivedData/AwesomeProject-czhnrdedsnmsxpcstdgrpapbjuwt/Build/Intermediates.noindex/AwesomeProject.build/Debug-iphoneos/AwesomeProject.build/AwesomeProject-own-target-headers.hmap -I/Users/ykk/Library/Developer/Xcode/DerivedData/AwesomeProject-czhnrdedsnmsxpcstdgrpapbjuwt/Build/Intermediates.noindex/AwesomeProject.build/Debug-iphoneos/AwesomeProject.build/AwesomeProject-all-target-headers.hmap -iquote /Users/ykk/Library/Developer/Xcode/DerivedData/AwesomeProject-czhnrdedsnmsxpcstdgrpapbjuwt/Build/Intermediates.noindex/AwesomeProject.build/Debug-iphoneos/AwesomeProject.build/AwesomeProject-project-headers.hmap -I/Users/ykk/Library/Developer/Xcode/DerivedData/AwesomeProject-czhnrdedsnmsxpcstdgrpapbjuwt/Build/Products/Debug-iphoneos/include -I/Users/ykk/AwesomeProject/ios/Pods/Headers/Public -I/Users/ykk/AwesomeProject/ios/Pods/Headers/Public/CocoaAsyncSocket -I/Users/ykk/AwesomeProject/ios/Pods/Headers/Public/CocoaLibEvent -I/Users/ykk/AwesomeProject/ios/Pods/Headers/Public/DoubleConversion -I/Users/ykk/AwesomeProject/ios/Pods/Headers/Public/FBLazyVector -I/Users/ykk/AwesomeProject/ios/Pods/Headers/Public/FBReactNativeSpec -I/Users/ykk/AwesomeProject/ios/Pods/Headers/Public/Flipper -I/Users/ykk/AwesomeProject/ios/Pods/Headers/Public/Flipper-DoubleConversion -I/Users/ykk/AwesomeProject/ios/Pods/Headers/Public/Flipper-Folly -I/Users/ykk/AwesomeProject/ios/Pods/Headers/Public/Flipper-Glog -I/Users/ykk/AwesomeProject/ios/Pods/Headers/Public/Flipper-PeerTalk -I/Users/ykk/AwesomeProject/ios/Pods/Headers/Public/Flipper-RSocket -I/Users/ykk/AwesomeProject/ios/Pods/Headers/Public/FlipperKit -I/Users/ykk/AwesomeProject/ios/Pods/Headers/Public/OpenSSL-Universal -I/Users/ykk/AwesomeProject/ios/Pods/Headers/Public/RCTRequired -I/Users/ykk/AwesomeProject/ios/Pods/Headers/Public/RCTTypeSafety -I/Users/ykk/AwesomeProject/ios/Pods/Headers/Public/React-Core -I/Users/ykk/AwesomeProject/ios/Pods/Headers/Public/React-RCTText -I/Users/ykk/AwesomeProject/ios/Pods/Headers/Public/React-cxxreact -I/Users/ykk/AwesomeProject/ios/Pods/Headers/Public/React-jsi -I/Users/ykk/AwesomeProject/ios/Pods/Headers/Public/React-jsiexecutor -I/Users/ykk/AwesomeProject/ios/Pods/Headers/Public/React-jsinspector -I/Users/ykk/AwesomeProject/ios/Pods/Headers/Public/ReactCommon -I/Users/ykk/AwesomeProject/ios/Pods/Headers/Public/Yoga -I/Users/ykk/AwesomeProject/ios/Pods/Headers/Public/YogaKit -I/Users/ykk/AwesomeProject/ios/Pods/Headers/Public/glog -I/Users/ykk/AwesomeProject/ios/Pods/Headers/Private/React-Core -I/Users/ykk/Library/Developer/Xcode/DerivedData/AwesomeProject-czhnrdedsnmsxpcstdgrpapbjuwt/Build/Intermediates.noindex/AwesomeProject.build/Debug-iphoneos/AwesomeProject.build/DerivedSources-normal/arm64 -I/Users/ykk/Library/Developer/Xcode/DerivedData/AwesomeProject-czhnrdedsnmsxpcstdgrpapbjuwt/Build/Intermediates.noindex/AwesomeProject.build/Debug-iphoneos/AwesomeProject.build/DerivedSources/arm64 -I/Users/ykk/Library/Developer/Xcode/DerivedData/AwesomeProject-czhnrdedsnmsxpcstdgrpapbjuwt/Build/Intermediates.noindex/AwesomeProject.build/Debug-iphoneos/AwesomeProject.build/DerivedSources -F/Users/ykk/Library/Developer/Xcode/DerivedData/AwesomeProject-czhnrdedsnmsxpcstdgrpapbjuwt/Build/Products/Debug-iphoneos -fmodule-map-file=/Users/ykk/Library/Developer/Xcode/DerivedData/AwesomeProject-czhnrdedsnmsxpcstdgrpapbjuwt/Build/Products/Debug-iphoneos/YogaKit/YogaKit.modulemap -fmodule-map-file=/Users/ykk/AwesomeProject/ios/Pods/Headers/Public/FlipperKit/FlipperKit.modulemap -fmodule-map-file=/Users/ykk/AwesomeProject/ios/Pods/Headers/Public/yoga/Yoga.modulemap -MMD -MT dependencies -MF /Users/ykk/Library/Developer/Xcode/DerivedData/AwesomeProject-czhnrdedsnmsxpcstdgrpapbjuwt/Build/Intermediates.noindex/AwesomeProject.build/Debug-iphoneos/AwesomeProject.build/Objects-normal/arm64/AwesomeProject_vers.d --serialize-diagnostics /Users/ykk/Library/Developer/Xcode/DerivedData/AwesomeProject-czhnrdedsnmsxpcstdgrpapbjuwt/Build/Intermediates.noindex/AwesomeProject.build/Debug-iphoneos/AwesomeProject.build/Objects-normal/arm64/AwesomeProject_vers.dia -c /Users/ykk/Library/Developer/Xcode/DerivedData/AwesomeProject-czhnrdedsnmsxpcstdgrpapbjuwt/Build/Intermediates.noindex/AwesomeProject.build/Debug-iphoneos/AwesomeProject.build/DerivedSources/AwesomeProject_vers.c -o /Users/ykk/Library/Developer/Xcode/DerivedData/AwesomeProject-czhnrdedsnmsxpcstdgrpapbjuwt/Build/Intermediates.noindex/AwesomeProject.build/Debug-iphoneos/AwesomeProject.build/Objects-normal/arm64/AwesomeProject_vers.o

fatal error: module map file '/Users/ykk/Library/Developer/Xcode/DerivedData/AwesomeProject-czhnrdedsnmsxpcstdgrpapbjuwt/Build/Products/Debug-iphoneos/YogaKit/YogaKit.modulemap' not found
1 error generated.

启动时遇到 unable to find valid certification path to requested target

F:\App\AwesomeProject>react-native run-android
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 960 file(s) to forward-jetify. Using 8 workers...
info Starting JS server...

  • daemon not running; starting now at tcp:5037
  • daemon started successfully
    info Installing the app...
    Starting a Gradle Daemon, 1 incompatible Daemon could not be reused, use --status for details

FAILURE: Build failed with an exception.

  • What went wrong:
    A problem occurred configuring root project 'AwesomeProject'.

Could not resolve all artifacts for configuration ':classpath'.
Could not resolve com.android.tools.build:gradle:3.5.2.
Required by:
project :
> Could not resolve com.android.tools.build:gradle:3.5.2.
> Could not get resource 'https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.5.2/gradle-3.5.2.pom'.
> Could not GET 'https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.5.2/gradle-3.5.2.pom'.
> sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
> Could not resolve com.android.tools.build:gradle:3.5.2.
> Could not get resource 'https://jcenter.bintray.com/com/android/tools/build/gradle/3.5.2/gradle-3.5.2.pom'.
> Could not GET 'https://jcenter.bintray.com/com/android/tools/build/gradle/3.5.2/gradle-3.5.2.pom'.
> sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

  • 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

BUILD FAILED in 22s

error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/getting-started.html#android-development-environment. Run CLI with --verbose flag for more details.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081

FAILURE: Build failed with an exception.

  • What went wrong:
    A problem occurred configuring root project 'AwesomeProject'.

Could not resolve all artifacts for configuration ':classpath'.
Could not resolve com.android.tools.build:gradle:3.5.2.
Required by:
project :
> Could not resolve com.android.tools.build:gradle:3.5.2.
> Could not get resource 'https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.5.2/gradle-3.5.2.pom'.
> Could not GET 'https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.5.2/gradle-3.5.2.pom'.
> sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
> Could not resolve com.android.tools.build:gradle:3.5.2.
> Could not get resource 'https://jcenter.bintray.com/com/android/tools/build/gradle/3.5.2/gradle-3.5.2.pom'.
> Could not GET 'https://jcenter.bintray.com/com/android/tools/build/gradle/3.5.2/gradle-3.5.2.pom'.
> sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

  • 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

BUILD FAILED in 22s

at makeError (F:\App\AwesomeProject\node_modules\execa\index.js:174:9)
at F:\App\AwesomeProject\node_modules\execa\index.js:278:16
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at async runOnAllDevices (F:\App\AwesomeProject\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\runOnAllDevices.js:94:5)
at async Command.handleAction (F:\App\AwesomeProject\node_modules\@react-native-community\cli\build\index.js:186:9)

rn新人,运行下载的项目,出现错误提示,求大佬指点!

提示错误信息为:
bundling failed: Error: Unable to resolve module react-native/Libraries/Pressability/Pressability.js from node_modules\teaset\components\ListRow\TouchableOpacity.js: react-native/Libraries/Pressability/Pressability.js could not be found within the project.
If you are sure the module exists, try these steps:

  1. Clear watchman watches: watchman watch-del-all
  2. Delete node_modules: rm -rf node_modules and run yarn install
  3. Reset Metro's cache: yarn start --reset-cache
  4. Remove the cache: rm -rf /tmp/metro-*
    at ModuleResolver.resolveDependency (D:\MyPro\MyPro2\teaset-master\example\node_modules\metro\src\node-haste\DependencyGraph\ModuleResolution.js:186:15)
    at ResolutionRequest.resolveDependency (D:\MyPro\MyPro2\teaset-master\example\node_modules\metro\src\node-haste\DependencyGraph\ResolutionRequest.js:52:18)
    at DependencyGraph.resolveDependency (D:\MyPro\MyPro2\teaset-master\example\node_modules\metro\src\node-haste\DependencyGraph.js:282:16)
    at Object.resolve (D:\MyPro\MyPro2\teaset-master\example\node_modules\metro\src\lib\transformHelpers.js:267:42)
    at dependencies.map.result (D:\MyPro\MyPro2\teaset-master\example\node_modules\metro\src\DeltaBundler\traverseDependencies.js:426:31)
    at Array.map ()
    at resolveDependencies (D:\MyPro\MyPro2\teaset-master\example\node_modules\metro\src\DeltaBundler\traverseDependencies.js:423:18)
    at D:\MyPro\MyPro2\teaset-master\example\node_modules\metro\src\DeltaBundler\traverseDependencies.js:275:33
    at Generator.next ()
    at asyncGeneratorStep (D:\MyPro\MyPro2\teaset-master\example\node_modules\metro\src\DeltaBundler\traverseDependencies.js:87:24)

初始化好的项目不能跑到真机上

请PS E:\RNtest4\Demo2> yarn android
yarn run v1.22.4
$ react-native run-android
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 960 file(s) to forward-jetify. Using 8 workers...
info JS server already running.
info Installing the app...

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.0.1/userguide/command_line_interface.html#sec:command_line_warnings

FAILURE: Build failed with an exception.

  • What went wrong:
    Task 'installDebug' not found in project ':app'.

  • Try:
    Run gradlew tasks to get a list of available tasks. 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

BUILD FAILED in 2s

error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup. Run CLI with --verbose flag for more details.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081

FAILURE: Build failed with an exception.

  • What went wrong:
    Task 'installDebug' not found in project ':app'.

  • Try:
    Run gradlew tasks to get a list of available tasks. 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

BUILD FAILED in 2s

at makeError (E:\RNtest4\Demo2\node_modules\execa\index.js:174:9)
at E:\RNtest4\Demo2\node_modules\execa\index.js:278:16
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at async runOnAllDevices (E:\RNtest4\Demo2\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\runOnAllDevices.js:94:5)
at async Command.handleAction (E:\RNtest4\Demo2\node_modules\@react-native-community\cli\build\index.js:186:9)

error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

大佬求助 rn打包报错

Task :react-native-audio-android:verifyReleaseResources FAILED

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':react-native-audio-android:verifyReleaseResources'.

1 exception was raised by workers:
com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource linking failed
error: resource android:style/TextAppearance.Material.Widget.Button.Borderless.Colored not found.
error: resource android:style/TextAppearance.Material.Widget.Button.Colored not found.
d:\wy1907\myJs\NewWeilink\node_modules\react-native-audio-android\android\build\intermediates\res\merged\release\values-v26\values-v26.xml:7: error: resource android:attr/colorError not found.
d:\wy1907\myJs\NewWeilink\node_modules\react-native-audio-android\android\build\intermediates\res\merged\release\values-v26\values-v26.xml:11: error: resource android:attr/colorError not found.
d:\wy1907\myJs\NewWeilink\node_modules\react-native-audio-android\android\build\intermediates\res\merged\release\values-v26\values-v26.xml:15: error: style attribute 'android:attr/keyboardNavigationCluster' not found.
d:\wy1907\myJs\NewWeilink\node_modules\react-native-audio-android\android\build\intermediates\res\merged\release\values-v28\values-v28.xml:7: error: resource android:attr/dialogCornerRadius not found.
d:\wy1907\myJs\NewWeilink\node_modules\react-native-audio-android\android\build\intermediates\res\merged\release\values-v28\values-v28.xml:11: error: resource android:attr/dialogCornerRadius not found.
d:\wy1907\myJs\NewWeilink\node_modules\react-native-audio-android\android\build\intermediates\res\merged\release\values\values.xml:2644: error: resource android:attr/fontStyle not found.
d:\wy1907\myJs\NewWeilink\node_modules\react-native-audio-android\android\build\intermediates\res\merged\release\values\values.xml:2645: error: resource android:attr/font not found.
d:\wy1907\myJs\NewWeilink\node_modules\react-native-audio-android\android\build\intermediates\res\merged\release\values\values.xml:2646: error: resource android:attr/fontWeight not found.
d:\wy1907\myJs\NewWeilink\node_modules\react-native-audio-android\android\build\intermediates\res\merged\release\values\values.xml:2647: error: resource android:attr/fontVariationSettings not found.
d:\wy1907\myJs\NewWeilink\node_modules\react-native-audio-android\android\build\intermediates\res\merged\release\values\values.xml:2648: error: resource android:attr/ttcIndex not found.
d:\wy1907\myJs\NewWeilink\node_modules\react-native-audio-android\android\build\intermediates\res\merged\release\values\values.xml:2674: error: resource android:attr/startX not found.
d:\wy1907\myJs\NewWeilink\node_modules\react-native-audio-android\android\build\intermediates\res\merged\release\values\values.xml:2677: error: resource android:attr/startY not found.
d:\wy1907\myJs\NewWeilink\node_modules\react-native-audio-android\android\build\intermediates\res\merged\release\values\values.xml:2680: error: resource android:attr/endX not found.
d:\wy1907\myJs\NewWeilink\node_modules\react-native-audio-android\android\build\intermediates\res\merged\release\values\values.xml:2683: error: resource android:attr/endY not found.
d:\wy1907\myJs\NewWeilink\node_modules\react-native-audio-android\android\build\intermediates\res\merged\release\values\values.xml:2691: error: resource android:attr/offset not found.
error: failed linking references.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.