出于某种原因,当我打电话时react-native link
,它会添加重复的包含android/settings.gradle
,然后将重复的导入添加到android/app/src/main/com/
.
它并不总是如此.当我手动添加一个特定的包时,它开始这样做,因为有些东西不起作用,但我不记得是哪一个.
我的预感是react-native link
假设按某种顺序列出的包 - 它看起来像反向字母 - 但由于npm包名称不一定与包含项目名称settings.gradle
不匹配的导入名称MainApplication.java
,我有很难弄清楚如何重新排序它们settings.gradle
以阻止这种行为.或者它可能完全是另一回事.
{ // ... "dependencies": { "events": "^1.1.1", "flux": "^3.1.2", "react": "~15.4.1", "react-native": "0.42.0", "react-native-datepicker": "^1.4.4", "react-native-fs": "^2.1.0-rc.1", "react-native-navigation": "^1.0.30", "react-native-push-notification": "^2.2.1", "react-native-sound": "^0.9.1", "react-native-vector-icons": "^4.0.0", "redux": "^3.6.0" }, "devDependencies": { "babel-jest": "19.0.0", "babel-preset-react-native": "1.9.1", "jest": "19.0.2", "react-test-renderer": "~15.4.1" }, "jest": { "preset": "react-native" } }
这是文件应该是什么......
rootProject.name = //include ':react-native-vector-icons' project(':react-native-vector-icons').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-vector-icons/android') include ':react-native-sound' project(':react-native-sound').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-sound/android') include ':react-native-push-notification' project(':react-native-push-notification').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-push-notification/android') include ':react-native-navigation' project(':react-native-navigation').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-navigation/android/app') include ':react-native-fs' project(':react-native-fs').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-fs/android') include ':app'
package // com.; import android.app.Application; import com.facebook.react.ReactApplication; import com.oblador.vectoricons.VectorIconsPackage; import com.zmxv.RNSound.RNSoundPackage; import com.dieam.reactnativepushnotification.ReactNativePushNotificationPackage; import com.reactnativenavigation.RnnPackage; import com.rnfs.RNFSPackage; import com.facebook.react.ReactNativeHost; import com.facebook.react.ReactPackage; import com.facebook.react.shell.MainReactPackage; import com.facebook.soloader.SoLoader; import java.util.Arrays; import java.util.List; public class MainApplication extends Application implements ReactApplication { private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) { @Override public boolean getUseDeveloperSupport() { return BuildConfig.DEBUG; } @Override protected List getPackages() { return Arrays. asList( new MainReactPackage(), new VectorIconsPackage(), new RNSoundPackage(), new ReactNativePushNotificationPackage(), new RnnPackage(), new RNFSPackage(), ); } }; @Override public ReactNativeHost getReactNativeHost() { return mReactNativeHost; } @Override public void onCreate() { super.onCreate(); SoLoader.init(this, /* native exopackage */ false); } }
运行后react-native link
,文件变为:
rootProject.name = //include ':react-native-vector-icons' project(':react-native-vector-icons').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-vector-icons/android') include ':react-native-sound' project(':react-native-sound').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-sound/android') include ':react-native-push-notification' project(':react-native-push-notification').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-push-notification/android') include ':react-native-navigation' project(':react-native-navigation').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-navigation/android/app') include ':react-native-fs' project(':react-native-fs').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-fs/android') include ':react-native-vector-icons' project(':react-native-vector-icons').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-vector-icons/android') include ':react-native-sound' project(':react-native-sound').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-sound/android') include ':react-native-push-notification' project(':react-native-push-notification').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-push-notification/android') include ':react-native-navigation' project(':react-native-navigation').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-navigation/android/app') include ':react-native-fs' project(':react-native-fs').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-fs/android') include ':app'
// ... import com.facebook.react.ReactApplication; import com.oblador.vectoricons.VectorIconsPackage; import com.zmxv.RNSound.RNSoundPackage; import com.dieam.reactnativepushnotification.ReactNativePushNotificationPackage; import com.reactnativenavigation.RnnPackage; import com.rnfs.RNFSPackage; import com.oblador.vectoricons.VectorIconsPackage; import com.zmxv.RNSound.RNSoundPackage; import com.dieam.reactnativepushnotification.ReactNativePushNotificationPackage; import com.reactnativenavigation.RnnPackage; import com.rnfs.RNFSPackage; import com.facebook.react.ReactNativeHost; import com.facebook.react.ReactPackage; import com.facebook.react.shell.MainReactPackage; import com.facebook.soloader.SoLoader; import java.util.Arrays; import java.util.List; public class MainApplication extends Application implements ReactApplication { private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) { @Override public boolean getUseDeveloperSupport() { return BuildConfig.DEBUG; } @Override protected ListgetPackages() { return Arrays. asList( new MainReactPackage(), new VectorIconsPackage(), new RNSoundPackage(), new ReactNativePushNotificationPackage(), new RnnPackage(), new RNFSPackage(), new VectorIconsPackage(), new RNSoundPackage(), new ReactNativePushNotificationPackage(), new RnnPackage(), new RNFSPackage(), ); } }; // ...
如果我react-native-link
再次运行,它会添加第三个包的副本.
有没有人对如何react-native link
运作有任何见解?