Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use new architecture #181

Closed
wants to merge 29 commits into from
Closed

use new architecture #181

wants to merge 29 commits into from

Conversation

tohsaka888
Copy link

已知问题:

playback-error {"code": "playback", "message": "AudioTrack init failed 0 Config(11025, 4, 5512)"}

暂时不知道咋修复。。。

tohsaka888 and others added 29 commits January 8, 2023 13:30
新版这个文件的命名是_BUCK
@lyswhut
Copy link
Owner

lyswhut commented Jan 9, 2023

昨晚我花了一晚上去尝试用新架构运行,最终在踩了一堆坑后还是构建失败了,这玩意对windows环境极其不友好,等rn0.71正式版出来再看看情况吧,0.71又改了挺多东西的,新架构升级没那么简单的,涉及原生模块,一堆问题

@tohsaka888
Copy link
Author

昨晚我花了一晚上去尝试用新架构运行,最终在踩了一堆坑后还是构建失败了,这玩意对windows环境极其不友好,等rn0.71正式版出来再看看情况吧,0.71又改了挺多东西的,新架构升级没那么简单的,涉及原生模块,一堆问题

你可以试试clone一下我的那条分支试试,主要rn目前的升级指南写的究极烂,我今天改了半天,发现要改的不是android/app/src/main/java/cn/toside/music/mobile/MainApplication.javaandroid/app/src/main/java/cn/toside/music/mobile/MainActivity.java反而改的是android/app/src/main/java/cn/toside/music/mobile/newarchitecture这个文件夹的内容。

我举个例子:

以前添加package是在android/app/src/main/java/cn/toside/music/mobile/MainApplication.java

 @Override
        protected List<ReactPackage> getPackages() {
          @SuppressWarnings("UnnecessaryLocalVariable")
          List<ReactPackage> packages = new PackageList(this).getPackages();
          // Packages that cannot be autolinked yet can be added manually here, for example:
          // packages.add(new MyReactNativePackage());
          packages.add(new GzipPackage());
          packages.add(new CachePackage());
          packages.add(new UtilsPackage());
          packages.add(new LyricPackage());
          return packages;
        }

启用新架构之后是在android/app/src/main/java/cn/toside/music/mobile/newarchitecture/MainApplicationReactNativeHost.java

 @Override
  protected List<ReactPackage> getPackages() {
    List<ReactPackage> packages = new PackageList(this).getPackages();
    // Packages that cannot be autolinked yet can be added manually here, for example:
    //     packages.add(new MyReactNativePackage());
    // TurboModules must also be loaded here providing a valid TurboReactPackage implementation:
    //     packages.add(new TurboReactPackage() { ... });
    // If you have custom Fabric Components, their ViewManagers should also be loaded here
    // inside a ReactPackage.
    packages.add(new GzipPackage());
    packages.add(new CachePackage());
    packages.add(new UtilsPackage());
    packages.add(new LyricPackage());
    return packages;
  }

关键官方文档里升级它又不写清楚。。。

还有个大坑是不仅要改原生,连jni文件夹里的C++文件也需要更改:

android/app/src/main/jni/MainApplicationTurboModuleManagerDelegate.h

// Adapt it to the package you used for your Java class.
  static constexpr auto kJavaDescriptor =
      "Lcn/toside/music/mobile/newarchitecture/modules/MainApplicationTurboModuleManagerDelegate;";

我没了解过C++就光试这个路径估计都踩了一两个小时的坑,开头Lcn是真的坑。。。。

@lyswhut
Copy link
Owner

lyswhut commented Jan 9, 2023

我现在没有环境试,要周末才行,MainApplicationReactNativeHost.java在rn0.71已经被删了,整个目录都删了,我还是觉得等rn0.71出来了再看看,现在改了到时候又要再大改,现在已经RC.5了,应该快转正式版了,RN0.71进行了一些构建优化与修复:

@tohsaka888
Copy link
Author

我现在没有环境试,要周末才行,MainApplicationReactNativeHost.java在rn0.71已经被删了,整个目录都删了,我还是觉得等rn0.71出来了再看看,现在改了到时候又要再大改,现在已经RC.5了,应该快转正式版了,RN0.71进行了一些构建优化与修复:

好的👌

@tohsaka888 tohsaka888 closed this Jan 9, 2023
@tohsaka888
Copy link
Author

@lyswhut
Copy link
Owner

lyswhut commented Jan 15, 2023

RNN在新版RN上还有其他的问题(DrawerLayoutAndroid组件在使用RNN导航到其他屏幕再返回会无法弹出),我打算从RNN迁移到React Navigation,直接创建一个空白RN项目,再将代码复制过去,然后清空现有项目,迁移完成再把代码复制回来。

由于现在在开发v1.0.0版本,旧的代码全部重构,现在这套代码已经打算弃用了,所以你先不用折腾它先,等v1.0.0出来再说

@tohsaka888
Copy link
Author

好耶,RNN从来没用过,一直用的React Navigation

@lyswhut
Copy link
Owner

lyswhut commented Jan 17, 2023

都差不多的,尝试切换到React Navigation后DrawerLayoutAndroid还是有问题,一旦切到二级页面再回来,侧栏就弹不出来了,这看起来是DrawerLayoutAndroid的bug,由于RNN支持动画分享,我现在又切回RNN了,DrawerLayoutAndroid的问题通过用研究出的 hack 方式解决了

v1.0.0将加密库切换到了react-native-quick-crypto,现在它也不支持RN0.71,看来升级到RN0.71还要等一段时间看看了:(

@tohsaka888
Copy link
Author

都差不多的,尝试切换到React Navigation后DrawerLayoutAndroid还是有问题,一旦切到二级页面再回来,侧栏就弹不出来了,这看起来是DrawerLayoutAndroid的bug,由于RNN支持动画分享,我现在又切回RNN了,DrawerLayoutAndroid的问题通过用研究出的 hack 方式解决了

v1.0.0将加密库切换到了react-native-quick-crypto,现在它也不支持RN0.71,看来升级到RN0.71还要等一段时间看看了:(

1.0版本还没有开源吧,想看看源码是怎么写的

@lyswhut
Copy link
Owner

lyswhut commented Jan 18, 2023

与PC2.0一样,打算完善好功能再把代码推到主仓库

@lyswhut
Copy link
Owner

lyswhut commented Mar 5, 2023

移动端v1.0.0的代码已推到dev分支,已经启用了新架构 )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants