2017-03-06 134 views
0

因爲我已經升級到反應母語0.42.0,我不能運行我的應用程序了。反應原生運行Android的失敗

我有一個奇怪的問題,其中不但得不到反應,從本土node_modules,gradle這個會得到Maven倉庫舊版本0.21。我試圖凍結版本,抑制一切都建立或高速緩存相關的,我甚至通過僅複製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" 
     } 
    } 
} 

任何線索?

+0

是您之前使用的是什麼版本?如果它只有幾個版本,那麼可能會發生突變。 –

+0

我已經作出更改日誌中列出的所有變化。我認爲它在Android Studio中打開之前運行過一次或兩次。 – PhilipGarnero

回答

0

發現了問題:

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" 
     } 
    } 
} 

你必須創建爲要添加的每個網址行家部分。 它甚至從來沒有拋出,當你指定它像我一樣第一次,它簡單地忽略第一個網址的錯誤。
時間丟失,因爲伐木不當...

0

嘗試檢查的package.json,看看裏面有什麼了。

如果發現舊版本在那裏,你可以改變它,然後運行npm install或只是運行npm install --save [email protected]<the-desired-version>

如果你得到你需要升級的錯誤反應,那麼運行 npm install --save [email protected]<needed-version>

在我的案例我不得不使用這種替代方法,因爲標準的(基於git)不起作用。

更多關於這家另類,這裏的標準一個細節: https://facebook.github.io/react-native/docs/upgrading.html

+0

我已經得到了正確的版本在我packages.json也是一樣的反應。我可以在我的node_modules中看到它,但在構建時不會使用它。 – PhilipGarnero