因为我升级到了react原生0.42.0,我不能再运行我的应用程序了。
我遇到了一个奇怪的问题,在这里,gradle将从maven存储库获得旧版本0.21,而不是从node_modules中获得响应。我试着冻结版本,关闭所有与构建或缓存相关的内容,甚至只复制js文件就开始了。但是,我仍然会遇到与gradle相关的错误,在node_modules中找不到react原生的。
这是我的settings.gradle:
rootProject.name = 'My App'
include ':app'
include ':react-native-google-analytics-bridge'
project(':react-native-google-analytics-bridge').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-google-analytics-bridge/android')还有我的应用程序的build.gradle依赖关系:
dependencies {
compile fileTree(dir: "libs", include: ["*.jar"])
compile "com.android.support:appcompat-v7:23.0.1"
compile "com.facebook.react:react-native:0.42.0" // From node_modules
compile "com.facebook.fresco:animated-gif:0.11.0"
compile project(':react-native-google-analytics-bridge')
}最后是项目build.gradle:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
}
}
allprojects {
repositories {
mavenLocal()
jcenter()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
url "http://private-repos"
}
}
}有线索吗?
发布于 2017-03-07 10:19:34
找出了问题:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
}
}
allprojects {
repositories {
mavenLocal()
jcenter()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
maven {
url "http://private-repos"
}
}
}您必须为要添加的每个url创建一个maven部分。它甚至不会抛出一个错误,当您指定它时,就像我首先做的那样,它只是忽略了第一个url。
因为伐木不当而浪费了几个小时..。
发布于 2017-03-07 00:45:44
试着检查package.json,看看里面有什么.
如果您在那里找到旧版本,您可以更改它,然后运行npm install或只运行npm install --save react-native@<the-desired-version>。
如果遇到需要升级的错误,请运行npm install --save react@<needed-version>
在我的例子中,我不得不使用这个替代方案,因为标准的选项(基于git)不起作用。
有关此选项和标准选项的更多详细信息如下:https://facebook.github.io/react-native/docs/upgrading.html
https://stackoverflow.com/questions/42637077
复制相似问题