在将本机反应从0.57.8升级到0.59.10之后,当我们尝试调用警报时,我们在android上崩溃了。
赞:
import { Alert } from 'react-native';
...
componentDidMount() {
// following line will crash on android only
Alert.alert('Did mount', 'Your component has mounted!');
}
我遵循了升级路径 https://react-native-community.github.io/upgrade-helper/?from=0.57.8&to=0.59.10
这是我收到的错误
android studio debug log:
--------- beginning of crash
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.debitoor.android, PID: 4837
java.lang.NoSuchMethodError: No virtual method isStateSaved()Z in class Landroid/support/v4/app/FragmentManager; or its super classes (declaration of 'android.support.v4.app.FragmentManager' appears in /data/app/com.debitoor.android-_akDnIP_mfHNd_jFi1g9WA==/split_lib_dependencies_apk.apk)
at com.facebook.react.modules.dialog.DialogModule$FragmentManagerHelper.showNewAlert(DialogModule.java:132)
at com.facebook.react.modules.dialog.DialogModule$1.run(DialogModule.java:258)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
--------- beginning of system
I/Process: Sending signal. PID: 4837 SIG: 9
Disconnected from the target VM, address: 'localhost:8600', transport: 'socket'
android/app/build.gradle:
apply plugin: "com.android.application"
apply plugin: "io.fabric"
import com.android.build.OutputFile
project.ext.react = [
entryFile: "index.js"
]
apply from: "../../node_modules/react-native/react.gradle"
apply from: "../../node_modules/react-native-vector-icons/fonts.gradle"
def enableProguardInReleaseBuilds = false
android {
compileSdkVersion rootProject.ext.compileSdkVersion
flavorDimensions "debitoorApi", "test", "devMode"
def versionPropsFile = file('version.properties')
def Properties versionProps = new Properties()
if (versionPropsFile.canRead()) {
versionProps.load(new FileInputStream(versionPropsFile))
}
else {
versionProps['VERSION_CODE']='0'
}
def code = versionProps['VERSION_CODE'].toInteger()
defaultConfig {
applicationId "com.debitoor.android"
multiDexEnabled true
minSdkVersion 19
targetSdkVersion 28
versionCode code
versionName "5.4.4"
missingDimensionStrategy "minReactNative", "minReactNative46" // required for detox test
testBuildType System.getProperty('testBuildType', 'debug') // required for detox test
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" // required for detox test
missingDimensionStrategy 'react-native-camera', 'general'
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
signingConfigs {
release {
...
}
}
dexOptions {
jumboMode true
javaMaxHeapSize "4g"
}
splits {
abi {
reset()
enable enableSeparateBuildPerCPUArchitecture
universalApk false // If true, also generate a universal APK
include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
}
}
buildTypes {
release {
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
signingConfig signingConfigs.release
}
}
productFlavors {
local {
...
}
staging {
...
}
production {
...
}
noTest {
...
}
devModeOn {
...
}
devModeOff {
...
}
}
// applicationVariants are e.g. debug, release
applicationVariants.all { variant ->
variant.outputs.each { output ->
// For each separate APK per architecture, set a unique version code as described here:
// http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
def versionCodes = ["armeabi-v7a":1, "x86":2, "arm64-v8a": 3, "x86_64": 4]
def abi = output.getFilter(OutputFile.ABI)
if (abi != null) { // null for the universal-debug, universal-release variants
output.versionCodeOverride =
versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
}
}
}
configurations.all {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
def requested = details.requested
if (requested.group == 'com.android.support') {
if (!requested.name.startsWith("multidex")) {
details.useVersion '25.3.0'
}
}
}
resolutionStrategy {
force 'com.google.android.gms:play-services-gcm:16.1.0'
force 'com.google.firebase:firebase-core:16.0.8'
force 'com.google.firebase:firebase-analytics:16.0.1'
}
}
}
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
implementation project(':@react-native-community_netinfo')
implementation project(':@react-native-community_async-storage')
implementation project(':react-native-firebase')
implementation project(':@debitoor_react-native-sumup')
implementation project(':react-native-cookies')
implementation project(':react-native-document-picker')
implementation project(':react-native-branch')
implementation project(':react-native-touch-id')
implementation project(':react-native-pdf')
implementation project(':react-native-fetch-blob')
implementation project(':react-native-contacts')
implementation project(':react-native-open-settings')
implementation project(':react-native-share')
implementation project(':react-native-navigation')
implementation project(':react-native-build-config')
implementation project(':react-native-logentries')
implementation project(':react-native-intercom')
implementation project(':react-native-vector-icons')
implementation (project(':react-native-camera')) {
exclude group: "com.google.android.gms"
}
implementation ("com.google.android.gms:play-services-vision:10.2.0") {
force = true;
}
implementation project(':react-native-fbsdk')
implementation project(':react-native-orientation')
implementation project(':react-native-print')
implementation project(':react-native-push-notification')
implementation project(':react-native-locale')
implementation project(':react-native-mixpanel')
implementation project(':react-native-fabric')
implementation project(':react-native-image-resizer')
implementation project(':react-native-image-picker')
implementation project(':react-native-fs')
implementation project(':react-native-device-info')
implementation project(':react-native-linear-gradient')
implementation('com.crashlytics.sdk.android:crashlytics:2.8.0@aar') {
transitive = true;
}
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation 'com.android.support:multidex:1.0.3'
implementation "com.android.support:appcompat-v7:26.0.2"
implementation 'com.android.installreferrer:installreferrer:1.0'
implementation 'com.facebook.react:react-native:0.59.10'
// required for detox test
androidTestImplementation(project(path: ":detox"))
androidTestImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test:rules:1.0.2'
// Firebase
implementation "com.google.android.gms:play-services-base:16.1.0"
implementation "com.google.firebase:firebase-core:16.0.8"
implementation "com.google.firebase:firebase-analytics"
}
// Run this once to be able to run the application with BUCK
// puts all compile dependencies into folder libs for BUCK to use
task copyDownloadableDepsToLibs(type: Copy) {
from configurations.compile
into 'libs'
}
apply plugin: 'com.google.gms.google-services'
---
android/build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlinVersion = '1.3.10' // Your app's version
ext.detoxKotlinVersion = ext.kotlinVersion // Detox' version: should be 1.1.0 or higher!
repositories {
jcenter()
maven {
url 'https://maven.fabric.io/public'
}
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.0'
classpath 'io.fabric.tools:gradle:1.+'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
classpath 'com.google.gms:google-services:4.2.0'
}
}
ext {
compileSdkVersion = 28
buildToolsVersion = '28.0.3'
supportLibVersion = "28.0.0"
}
subprojects { subproject ->
afterEvaluate{
if((subproject.plugins.hasPlugin('android') || subproject.plugins.hasPlugin('android-library'))) {
android {
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion
}
}
}
}
allprojects {
repositories {
mavenLocal()
maven {
url "https://maven.google.com"
}
jcenter()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
google()
maven {
url "https://jitpack.io"
}
maven {
url 'https://maven.sumup.com/releases'
}
}
}
最后是我们的依赖项列表:
"bignumber.js": "4.0.0",
"dateformat": "2.0.0",
"deep-equal": "1.0.1",
"dot-prop-immutable": "1.3.1",
"express": "4.16.3",
"fbjs": "0.8.16",
"lodash": "4.17.4",
"moment": "2.18.1",
"murmurhash": "0.0.2",
"prop-types": "15.6.0",
"query-string": "4.3.2",
"react": "16.8.3",
"react-addons-pure-render-mixin": "15.6.2",
"react-native": "0.59.10",
"react-native-branch": "2.3.0",
"react-native-build-config": "github:ismaeldcom/react-native-build-config#fb4e89e",
"react-native-camera": "2.11.0",
"react-native-communications": "2.2.1",
"react-native-contacts": "2.2.0",
"react-native-cookies": "3.3.0",
"react-native-device-info": "2.3.2",
"react-native-dismiss-keyboard": "1.0.0",
"react-native-document-picker": "git+ssh://git@github.com:debitoor/react-native-document-picker.git#0283de71ad3823125abb8ff66dbc916cf6ca914d",
"react-native-env": "git+ssh://git@github.com/debitoor/react-native-env.git#c5a1e2b",
"react-native-fabric": "0.5.1",
"react-native-fbsdk": "0.10.1",
"react-native-fetch-blob": "0.10.8",
"react-native-firebase": "5.2.3",
"react-native-firebase-analytics": "3.0.5",
"react-native-fs": "2.10.14",
"react-native-image-picker": "github:debitoor/react-native-image-picker#54555a4",
"react-native-image-resizer": "1.0.1",
"react-native-image-zoom-viewer": "2.2.13",
"react-native-in-app-utils": "git+ssh://git@github.com/debitoor/react-native-in-app-utils.git#9f1f3bf",
"react-native-intercom": "10.2.0",
"react-native-linear-gradient": "2.4.0",
"react-native-locale": "0.0.18",
"react-native-logentries": "1.0.1",
"react-native-map-link": "2.1.1",
"react-native-material-ripple": "0.8.0",
"react-native-mixpanel": "1.1.1",
"react-native-navigation": "git+ssh://git@github.com/debitoor/react-native-navigation#modalfix",
"react-native-open-settings": "1.0.1",
"react-native-orientation": "3.1.0",
"react-native-pdf": "3.0.8",
"react-native-permissions": "1.0.6",
"react-native-print": "git+https://github.com/debitoor/react-native-print.git#74f776e",
"react-native-push-notification": "3.0.2",
"react-native-quick-actions": "0.2.1",
"react-native-search-api": "git+ssh://git@github.com/gundlev/react-native-search-api.git#ffa18bb",
"react-native-share": "1.0.27",
"react-native-snap-carousel": "3.7.5",
"react-native-swipeout": "2.3.1",
"react-native-touch-id": "4.0.4",
"react-native-user-avatar": "1.0.3",
"react-native-userdefaults-ios": "git+ssh://git@github.com/debitoor/react-native-userdefaults-ios.git#3a62243",
"react-native-vector-icons": "4.5.0",
"react-redux": "5.0.6",
"redux": "3.7.2",
"redux-debounced": "0.4.0",
"redux-devtools-extension": "2.13.2",
"redux-logger": "2.8.1",
"redux-persist": "4.4.0",
"redux-persist-filesystem-storage": "1.2.0",
"redux-thunk": "2.2.0",
"safe-json-stringify": "1.2.0",
"throttle-debounce": "1.0.1",
"traverse": "0.6.6",
"util": "0.10.3",
"uuid": "3.0.1"
从错误消息com.facebook.react.modules.dialog.DialogModule
看来,我们似乎缺少sdk或未正确升级。但我只是无法指出。
我尝试过
rm -rf node_modules && ./scripts/clean-build-cache.sh && watchman watch-del-all && rm -rf $TMPDIR/react-*
,然后再次yarn install
... 答案 0 :(得分:0)
更新到0.59后,在本机模块(例如Alert,Toast,DatePickerAndroid等)中出现问题是很常见的。 我在ToastAndroid(“ my messsage”)中遇到了类似的问题,发现这是因为缺少第二个参数'duration'。但是在以前的版本中,它没有“持续时间”。
因此提供完整的参数将起作用。
Botan::unlock
答案 1 :(得分:0)
答案在于我们的解决策略。删除后
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
def requested = details.requested
if (requested.group == 'com.android.support') {
if (!requested.name.startsWith("multidex")) {
details.useVersion '25.3.0'
}
}
}
再次工作