本人碰到的RN项目的坑

1.路径问题

路径不能含有中文

2.下载jar\aar包超时问题

* What went wrong:
A problem occurred configuring project ':react-native-safe-area-context'.
> Could not resolve all files for configuration ':react-native-safe-area-context:classpath'.
   > Could not download kotlin-gradle-plugin-1.6.20.jar (org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.20)
      > Could not get resource 'https://repo.maven.apache.org/maven2/org/jetbrains/kotlin/kotlin-gradle-plugin/1.6.20/kotlin-gradle-plugin-1.6.20.jar'.
         > Read timed out
   > Could not download kotlin-compiler-embeddable-1.6.20.jar (org.jetbrains.kotlin:kotlin-compiler-embeddable:1.6.20)
      > Could not get resource 'https://repo.maven.apache.org/maven2/org/jetbrains/kotlin/kotlin-compiler-embeddable/1.6.20/kotlin-compiler-embeddable-1.6.20.jar'.
         > Read timed out

手动下载:任意位置新建个文件夹,然后点击超时的jar包链接跳转到浏览器后下载到这个文件夹内,返回报错的地方找到报错的包名(com或者org开头的),然后去这个路径下找到对应的包名

C:\Users\22560\.gradle\caches\modules-2\files-2.1

例如包名为(org.jetbrains.kotlin:kotlin-reflect:1.6.0)
那么路径如下:

C:\Users\22560\.gradle\caches\modules-2\files-2.1\org.jetbrains.kotlin\kotlin-reflect\1.6.0\秘钥文件名\粘贴刚刚下载的jar\aar包

当有多个秘钥命名的文件夹时,不知道放到那一个里面,建议每个里面都粘贴一下jar\arr文件

还有个是关于node依赖包的pom文件下载超时的解决办法,具体可以参考这个链接https://blog.csdn.net/u010537398/article/details/120309048

3.报错

再次运行项目出现了以下报错

Execution failed for task ':app:installDebug'.
> java.util.concurrent.ExecutionException: com.android.builder.testing.api.DeviceException: com.android.ddmlib.InstallException: INSTALL_FAILED_VERSION_DOWNGRADE     

* 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

错误消息表明应用程序的安装存在问题。具体而言,它表明应用程序已安装在设备上,其签名与您尝试安装的签名不同。如果您尝试安装与设备上当前安装的签名不同的新版本的应用程序,则可能会发生这种情况。

🌟要解决此问题,使用下面的步骤:

1.从设备上卸载现有版本的应用。您可以通过转到设备的设置,选择“应用”,在列表中找到该应用,然后选择“卸载”来执行此操作。

2.在Android Studio中清理和重建应用程序。为此,请点击“Build”>“Clean Project”,然后转到“Build”>“Rebuild Project”。

3.在设备上再次运行应用程序。这应该安装具有正确签名的新版本应用程序。

再次运行项目报错

warn Failed to connect to development server using "adb reverse": Command failed: D:\Android\Sdk\platform-tools\adb -s

意思是你当前手机的端口和需要的端口号不一致,就会出现那个异常,那就得想办法弄成一致的,目前解决是需要刷机,然后执行如下命令:
执行以下命令

adb kill-server
adb start-server
//上面两个命令本人这里没用上,本人直接用下面这个命令直接可以用了(不放心的话可以依次执行这三个命令)
adb reverse tcp:8081 tcp:8081

如果没有权限,则会报如下异常:

adb.exe: error: closed

成功了!!!

错误
Requiring unknown module ‘12’ if you are sure the module exists, try restarting Metro . you may also want to run
解决方式:将终端关闭,安卓应用关闭,重启项目即可

关闭模拟器警告

在index.js加入以下代码即可

import { LogBox } from 'react-native';

LogBox.ignoreAllLogs(true); // 关闭全部黄色警告
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

萧寂173

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值