美文网首页
RN一般问题

RN一般问题

作者: taijielan | 来源:发表于2019-04-28 11:10 被阅读0次

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

解决:``` <manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.evergrandecaptcha" >
<uses-sdk tools:overrideLibrary="com.facebook.react"/>
</manifest>

#### 报错

:react-native-pdf-view:processDebugResources
ERROR: In <declare-styleable> FontFamilyFont, unable to find attribute android:font
ERROR: In <declare-styleable> FontFamilyFont, unable to find attribute android:fontStyle
ERROR: In <declare-styleable> FontFamilyFont, unable to find attribute android:fontVariationSettings
ERROR: In <declare-styleable> FontFamilyFont, unable to find attribute android:fontWeight
ERROR: In <declare-styleable> FontFamilyFont, unable to find attribute android:ttcIndex
ERROR: In <declare-styleable> GradientColor, unable to find attribute android:endX
ERROR: In <declare-styleable> GradientColor, unable to find attribute android:endY
ERROR: In <declare-styleable> GradientColor, unable to find attribute android:startX
ERROR: In <declare-styleable> GradientColor, unable to find attribute android:startY
ERROR: In <declare-styleable> 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 react-native@0.44

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 <declare-styleable> FontFamilyFont, unable to find attribute android:font
ERROR: In <declare-styleable> FontFamilyFont, unable to find attribute android:fontStyle
ERROR: In <declare-styleable> FontFamilyFont, unable to find attribute android:fontVariationSettings
ERROR: In <declare-styleable> FontFamilyFont, unable to find attribute android:fontWeight
ERROR: In <declare-styleable> FontFamilyFont, unable to find attribute android:ttcIndex
ERROR: In <declare-styleable> GradientColor, unable to find attribute android:endX
ERROR: In <declare-styleable> GradientColor, unable to find attribute android:endY
ERROR: In <declare-styleable> GradientColor, unable to find attribute android:startX
ERROR: In <declare-styleable> GradientColor, unable to find attribute android:startY

解决

:react-native-pdf-view

ERROR: In <declare-styleable> FontFamilyFont, unable to find attribute android:font
ERROR: In <declare-styleable> FontFamilyFont, unable to find attribute android:fontStyle
ERROR: In <declare-styleable> FontFamilyFont, unable to find attribute android:fontVariationSettings
ERROR: In <declare-styleable> FontFamilyFont, unable to find attribute android:fontWeight
ERROR: In <declare-styleable> FontFamilyFont, unable to find attribute android:ttcIndex
ERROR: In <declare-styleable> GradientColor, unable to find attribute android:endX
ERROR: In <declare-styleable> GradientColor, unable to find attribute android:endY
ERROR: In <declare-styleable> GradientColor, unable to find attribute android:startX
ERROR: In <declare-styleable> GradientColor, unable to find attribute android:startY
ERROR: In <declare-styleable> 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一般问题

    https://www.npmjs.com 命令: react-native init Test 创建一个Test...

  • ReactNative中可能会遇到的问题

    一般问题 1、RN和React.js是一个东西吗?RN和React.js共用一些抽象层,但具体有很多差异,且目标平...

  • React Native 在 Xcode升级后出现的问题

    升级Xcode 版本后,RN经常会出现一些问题,一般升级RN版本就能解决,如果不能或不想升级版本就需要修改本地一些...

  • React Native - 踩坑纪录

    记录下自己在 RN 开发中遇到的一些问题。 RN 组件相关 TextInput Android 文字对齐问题 当 ...

  • RN ImageBackground 问题

    看下这个是什么问题呢? 不知道大家在用这个ImageBackground 的时候是不是也出现过同样的问题? 排查...

  • rn webview问题

    1:Error loading page Domain: WebKitErrorDomain Error Code...

  • RN问题汇总

    1.Win10上配置环境出现,module accessibilityinfo does not... 每次新建项...

  • rn环境问题

    1. CFxxx不一定是第三方库的问题,不要一报错就网上贴报错信息,一定要看日志! 该问题很多时候是因为代码出错编...

  • rn的问题

    在本文章中,Udacity 团队将告诉大家他们使用 React Native 的历程以及放弃他们的原因,也希望给一...

  • RN - 问题集合

    安卓报错error: uncompiled PNG file passed as argument. Must b...

网友评论

      本文标题:RN一般问题

      本文链接:https://www.haomeiwen.com/subject/rkfdnqtx.html