[英]react-native run-android fails
由於我已經升級到react-native 0.42.0,因此無法運行我的應用程序。
我有一個奇怪的問題,那就是gradle將從maven存儲庫中獲取舊版本0.21,而不是從node_modules獲得react-native。 我嘗試凍結該版本,禁止所有與構建或緩存相關的事情,甚至還只復制了js文件就重新開始了。 但是我仍然遇到與gradle不在node_modules中尋找react-native相關的錯誤。
這是我的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"
}
}
}
有什么線索嗎?
嘗試檢查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
發現問題:
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。
由於記錄不當而浪費了數小時...
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.