RN一般问题

https://www.npmjs.com

命令:

react-native init Test 创建一个Test项目
npm install :安装依赖库
react-native run-android:运行项目

内网
node :7.8.0
Gradle : distributionUrl=https://services.gradle.org/distributions/gradle-2.14.1-all.zip
compile 'com.github.barteksc:android-pdf-viewer:2.7.0'

WebStorm 卡在 react-native-pdf-view没反应。

react-native-pdf-view的Android版本降低

// compile 'com.github.barteksc:android-pdf-viewer:+'
compile 'com.github.barteksc:android-pdf-viewer:2.7.0'

npm config set registryhttps://registry.npm.taobao.org 一直卡着。

可以先升级node.js的最新版,sudo -n 。npm install 升级后再改回7.8.0.

Resolving dependencies ':react-native-pdf-view:_debugPublish'卡住

可以直接单独下载react-native-pdf-view

 Suggestion: use tools:overrideLibrary="com.facebook.react" to force usage

解决:``` xmlns:tools="http://schemas.android.com/tools"
package="com.evergrandecaptcha" >

#### 报错

:react-native-pdf-view:processDebugResources
ERROR: In FontFamilyFont, unable to find attribute android:font
ERROR: In FontFamilyFont, unable to find attribute android:fontStyle
ERROR: In FontFamilyFont, unable to find attribute android:fontVariationSettings
ERROR: In FontFamilyFont, unable to find attribute android:fontWeight
ERROR: In FontFamilyFont, unable to find attribute android:ttcIndex
ERROR: In GradientColor, unable to find attribute android:endX
ERROR: In GradientColor, unable to find attribute android:endY
ERROR: In GradientColor, unable to find attribute android:startX
ERROR: In GradientColor, unable to find attribute android:startY
ERROR: In GradientColorItem, unable to find attribute android:offset

解决

def DEFAULT_GOOGLE_PLAY_SERVICES_VERSION = "15.0.1"
compile "com.google.android.gms:play-services-gcm:$googlePlayServicesVersion"

#### ``` /Users/liuyong/reactnative/evergrande-material/node_modules/react-native-evergrandecaptcha/android/src/androidTest/java/com/fei/ExampleInstrumentedTest.java:4: 错误: 程序包android.support.test不存在
import android.support.test.InstrumentationRegistry;

解决 :直接删掉

A problem occurred configuring project ':app'.
> java.lang.NullPointerException (no error message)

解决
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
可以在打包命令后面添加--stacktrace,控制台会输出更多问题信息。
打包添加更多日志 : gradle assembleRelease --stacktrace
最后发现是没配置NDK。在项目的local.properties的文件中添加NDK的路径。

如何将当前版本的ReactNative 降级 ?

npm install --save [email protected]

node 的版本安装

确保nvm安装
nvm install 7.8.0
nvm use 7.8.0
要外围
sodu n 8.3.0

刷新页面

adb shell input keyevent 82

手机热加载

ip:8081

查询console日志

adb logcat *:S ReactNative:V ReactNativeJS:V

react-native bundle --platform android --dev false --entry-file index.android.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res/
测试

react-native run-android --flavor=Flavors_testDebug -- appId=com.evergrande.qms.test

生产

react-native run-android --flavor=Flavors_defaultDebug

打生产包

gradle assembleRelease

Build file '/Users/liuyong/reactnative/evergrande-material/node_modules/jpush-react-native/android/build.gradle' line: 19

和下面的类似

'/Users/liuyong/reactnative/evergrande-material/node_modules/jcore-react-native/android/build.gradle' line: 23
 implementation fileTree(dir: 'libs', include: ['*.jar'])

解决compile fileTree(dir: 'libs', include: ['*.jar'])
build.gradle文件修改
compileSdkVersion safeExtGet('compileSdkVersion', 27)
buildToolsVersion "23.0.1"

react-native-device-info

ERROR: In  FontFamilyFont, unable to find attribute android:font
ERROR: In  FontFamilyFont, unable to find attribute android:fontStyle
ERROR: In  FontFamilyFont, unable to find attribute android:fontVariationSettings
ERROR: In  FontFamilyFont, unable to find attribute android:fontWeight
ERROR: In  FontFamilyFont, unable to find attribute android:ttcIndex
ERROR: In  GradientColor, unable to find attribute android:endX
ERROR: In  GradientColor, unable to find attribute android:endY
ERROR: In  GradientColor, unable to find attribute android:startX
ERROR: In  GradientColor, unable to find attribute android:startY

解决

:react-native-pdf-view

ERROR: In FontFamilyFont, unable to find attribute android:font
ERROR: In FontFamilyFont, unable to find attribute android:fontStyle
ERROR: In FontFamilyFont, unable to find attribute android:fontVariationSettings
ERROR: In FontFamilyFont, unable to find attribute android:fontWeight
ERROR: In FontFamilyFont, unable to find attribute android:ttcIndex
ERROR: In GradientColor, unable to find attribute android:endX
ERROR: In GradientColor, unable to find attribute android:endY
ERROR: In GradientColor, unable to find attribute android:startX
ERROR: In GradientColor, unable to find attribute android:startY
ERROR: In GradientColorItem, unable to find attribute android:offset

  • 将react-native-pdf-view 的compileSdkVersion,buildToolsVersion,buildToolsVersion,targetSdkVersion设置和主工程相同
  • 并修改主工程的,设置相同的版本编译库,防止其他库使用的版本不同。
    android 目录下
   configurations.all {
        resolutionStrategy.eachDependency { DependencyResolveDetails details ->
            def requested = details.requested
            if (requested.group == 'com.android.support') {
                if (requested.name.startsWith("appcompat-v7")) {
                    details.useVersion '23.0.1'
                }
            }
        }
    }
Provided schema version 220 is less than last set version 222

修改realm的schemaVersion: 222

react-native-evergrandecaptcha

Suggestion: use tools:overrideLibrary="com.facebook.react" to force usage
修改 minSdkVersion 15 为 minSdkVersion 16

还有个测试方法报错

直接删掉

buildToolsVersion is not specified.

解决: ` compileSdkVersion safeExtGet('compileSdkVersion', 27)
buildToolsVersion safeExtGet('buildToolsVersion', '26.0.2')

defaultConfig {
    minSdkVersion safeExtGet('minSdkVersion', 16)
    targetSdkVersion safeExtGet('targetSdkVersion', 27)
    versionCode 1
    versionName "1.0"
}
lintOptions {
    abortOnError false
    warning 'InvalidPackage'
}
sourceSets.main {
    jniLibs.srcDirs = ['libs']
}`

Jack is required to support java 8 language features. Either enable Jack or remove

 defaultConfig {
        applicationId "com.jmessage.sdk"                          //在此替换你的applicationId
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        versionCode 1
        versionName "1.0"
        manifestPlaceholders = [
                JPUSH_APPKEY: "129c21dc4cb5e6f6de194003",         //在此替换你的APPKey
                JPUSH_CHANNEL: "default"                          //在此替换你的channel
        ]
        jackOptions {
            enabled true
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

依赖包多了很慢加载很久。

 Resolving dependencies ':app:_flavors_defaultDebugApk' >

1、修改加载慢的包中的react-native 版本。

 compile "com.facebook.react:react-native:0.44.0"  // From node_modules

2、 可能的原因是项目的下载依赖库有问题,有些仓库地址访问不到,删除掉。

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

你可能感兴趣的:(RN一般问题)