如何手动链接npm包“ react native reanimated”

时间:2019-05-30 07:13:26

标签: android react-native npm manual npm-link

任何人都可以告诉我如何手动链接

  

本机复活

因为自动cli链接无法正常工作并导致本机应用崩溃

1 个答案:

答案 0 :(得分:1)

在Android中,将以下行添加到android / settings.gradle

include ':react-native-reanimated' project(':react-native-reanimated').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-reanimated/android')

将编译行添加到android / app / build.gradle中的依赖项

implementation project(':react-native-reanimated')

在MainApplication.java中导入并链接包

import com.swmansion.reanimated.ReanimatedPackage;

protected List<ReactPackage> getPackages() {
  return Arrays.<ReactPackage>asList(
         new ReanimatedPackage(), );// <-- add this line
}
}

在android / build.gradle中

ext {
compileSdkVersion           = 25
targetSdkVersion            = 25
buildToolsVersion           = "25.0.2"
googlePlayServicesVersion   = "12.0.1"
supportLibVersion           = "27.0.0"
 }