rn一些知识点

最近配合前端开发rn,下面是一些常用的命令及错误。不足之处多见谅

1,常用命令

(1)创建npm,每个项目都需要此命令:npm install

(2)启动rn
react-native run-android
(3)adb掉了:也就是显示8080.   adb reverse tcp:8081 tcp:8081
(4)react-native log-android        打印log
(5)打包:进入安卓所在的目录: gradlew assembleRelease

2,如果rn的版本是2.3.3,as是3.0。在下面
(1)E:\WorkNotes\flyAndroid\android\gradle.properties里面添加
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
(2)E:\WorkNotes\flyAndroid\android\build.gradle里面添加参数
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'


// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}


allprojects {
repositories {
google()
mavenLocal()
jcenter()
maven {
url 'https://maven.google.com'
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
}
}


3,版本过高的问题
A problem occurred configuring project ':react-native-linear-gradient'.
> Could not resolve all files for configuration ':react-native-linear-gradient:c
lasspath'.
   > Could not find com.android.tools.build:gradle:3.0.0.
     Searched in the following locations:
         https://jcenter.bintray.com/com/android/tools/build/gradle/3.0.0/gradle
-3.0.0.pom
         https://jcenter.bintray.com/com/android/tools/build/gradle/3.0.0/gradle
-3.0.0.jar
     Required by:
         project :react-native-linear-gradient


方法:react-native-linar-gradient里面的build.gradle
版本改一下。


4,打包错误
Error:Execution failed for task ':app:transformDexWithDexForRelease'.
> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536
compile 'com.android.support:multidex:1.0.1'

defaultConfig {
   ...
    multiDexEnabled true

compile 'com.android.support:multidex:1.0.1'

猜你喜欢

转载自blog.csdn.net/qq_30299243/article/details/81047496