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'
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章