react native打包apk時配置gradle阿里雲maven倉庫加速依賴下載
阿新 • • 發佈:2018-12-27
前言
使用react native進行打包apk時,因為maven倉庫的原因會導致某些依賴和包沒有新增成功,會導致一些問題。所以做法就是將gradle中的倉庫地址進行配置。而且配置過程中有一些注意事項要注意。
問題詳解
進入android目錄下,找到buid.gradle檔案,對下面兩部分進行修改:
buildscript { repositories { maven{ url 'http://maven.aliyun.com/nexus/content/groups/public/'} //阿里雲maven倉庫 jcenter() } dependencies { classpath 'com.android.tools.build:gradle:2.2.3' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } }
repositories { maven { // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm url "$rootDir/../node_modules/react-native/android" //不要註釋或刪除這段maven倉庫 } mavenLocal() maven { url 'http://maven.aliyun.com/nexus/content/groups/public/'} //阿里雲maven倉庫 jcenter() }
注意:不要刪除上面註釋標註的那段maven倉庫,不然會導致打包生成apk的時候facebook的一些包無法匯入而報錯。