前言
使用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的一些包无法导入而报错。