App crashes after adding webview in react native

Viewed 760
Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x20 in tid 30951 (RenderThread), pid 30839 (example.myapp)

This is the log I'm getting in the Android studio logcat. After adding webview in our project, it crashes often with this error message. This crash happens only on android devices especially on the real devices. In emulator its working good.

So I tried finding solution for this problem and one solution worked..(i.e, changing the android:hardwareAccelerated from true to false in manifest file..By doing so, the problem got solved, But I can feel the difference in performance that the app is bit laggy. The app's size is more than 40mb and I need the same performance as before)

This is my app / build.gradle

    buildscript {
    repositories {
    maven { url 'https://maven.fabric.io/public' }
    }

    dependencies {

    }
    }
    apply plugin: "com.android.application"
    apply plugin: 'com.huawei.agconnect'
    //apply plugin: 'io.fabric'

    repositories {
    maven {url 'https://maven.fabric.io/public'}
    }

    import com.android.build.OutputFile


    project.ext.react = [
    entryFile: "index.js",
    enableHermes: true,
    ]

    def jscFlavor = 'org.webkit:android-jsc:+'

    def enableHermes = project.ext.react.get("enableHermes", false)


    apply from: "../../node_modules/react-native/react.gradle"

  
    def enableSeparateBuildPerCPUArchitecture = false


    def enableProguardInReleaseBuilds = false

    android {
    compileSdkVersion 30
    buildToolsVersion '30.0.3'

    defaultConfig {
    applicationId "com.example.app"
    minSdkVersion 21
    targetSdkVersion 30
  
    versionCode 2        //HUAWEI
    versionName "1.0.1"   //HUAWEI
    multiDexEnabled true
    vectorDrawables.useSupportLibrary = true
    lintOptions{
    checkReleaseBuilds false
    abortOnError false
    }

    testBuildType System.getProperty('testBuildType', 'debug')
    testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
    }

    compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
    }

    signingConfigs {
    release {
    if (project.hasProperty('MYAPP_RELEASE_STORE_FILE')) {
    storeFile file(MYAPP_RELEASE_STORE_FILE)
    storePassword MYAPP_RELEASE_STORE_PASSWORD
    keyAlias MYAPP_RELEASE_KEY_ALIAS
    keyPassword MYAPP_RELEASE_KEY_PASSWORD
    }
    }
    }

    splits {
    abi {
    reset()
    enable enableSeparateBuildPerCPUArchitecture
    universalApk false  // If true, also generate a universal APK
    include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
    }
    }

    buildTypes {
    debug {
    minifyEnabled true
    proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro", "devsupport.pro"
    }
    release {
    crunchPngs false // or true
    minifyEnabled enableProguardInReleaseBuilds
    proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
    signingConfig signingConfigs.release
    proguardFile "${rootProject.projectDir}/../node_modules/detox/android/detox/proguard-rules-app.pro"
    }

    }
    applicationVariants.all { variant ->
    variant.outputs.each { output ->

    def versionCodes = ["armeabi-v7a":1, "x86":2, "arm64-v8a": 3, "x86_64": 4]
    def abi = output.getFilter(OutputFile.ABI)
    if (abi != null) { 
    output.versionCodeOverride =
        versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
    }
    }
    }

    packagingOptions {
    pickFirst 'lib/x86/libc++_shared.so'
    pickFirst 'lib/arm64-v8a/libc++_shared.so'
    pickFirst 'lib/x86_64/libc++_shared.so'
    pickFirst 'lib/armeabi-v7a/libc++_shared.so'
    exclude "lib/arm64-v8a/libgnustl_shared.so"
    }
    }

    dependencies {
    implementation project(':react-native-play-install-referrer')
    implementation project(':react-native-i18n')
    implementation project(':react-native-document-picker')
    implementation project(':react-native-image-crop-picker')
    implementation project(':react-native-safe-area-context')
    implementation project(':react-native-svg')
    implementation project(':react-native-view-shot')
    implementation project(':@react-native-community_viewpager')
    implementation project(':@mokriya_react-native-zoom-us-bridge')
    implementation project(':react-native-launch-application')
    implementation project(':react-native-vector-icons')
    implementation project(':rn-fetch-blob')
    implementation project(':react-native-localize')
    implementation project(':react-native-reanimated')
    implementation project(':react-native-gesture-handler')
    implementation project(':react-native-screens')
    implementation project(':@react-native-community_datetimepicker')
    implementation project(':react-native-vector-icons')
    implementation project(':react-native-cardview')
    implementation project(':@react-native-community_async-storage')
    implementation project(':react-native-date-picker')
    implementation project(':react-native-webview')
    implementation project(':@react-native-community_geolocation')
    implementation project(':@react-native-community_netinfo')
    implementation project(':react-native-maps')
    implementation project(':react-native-linear-gradient')
    implementation project(':react-native-share')
    implementation project(':react-native-image-picker')
    implementation project(':react-native-device-info')
    implementation project(':react-native-android-location-enabler')
    implementation project(':react-native-payu')
    implementation project(':react-native-fs')
    //implementation project (':react-native-trackflow')
    implementation project(':@react-native-community_progress-bar-android')
    implementation project(path: ':react-native-pdf')
    implementation project(path: ':@react-native-community_progress-view')
    implementation project(':react-native-video')
    implementation project(':react-native-version-check')
    implementation project(':react-native-in-app-review')
    implementation project(':react-native-html-to-pdf-custom')
    implementation project(':react-native-permissions')
    implementation project(path: ':@react-native-firebase_app')
    implementation project(path: ':@react-native-firebase_messaging')
    implementation project(path: ':@react-native-firebase_crashlytics')
    implementation project(path: ':@react-native-firebase_analytics')
    implementation project(path: ':@react-native-community_masked-view')

    implementation 'com.google.android.gms:play-services-maps:17.0.1'
    implementation 'com.google.android.gms:play-services-base:17.6.0'
    implementation "com.google.android.gms:play-services-location:18.0.0"
    implementation "com.google.firebase:firebase-auth:21.0.1"
    implementation 'com.google.firebase:firebase-common:20.0.0'
    implementation 'com.google.firebase:firebase-core:19.0.1'
    implementation 'com.google.firebase:firebase-messaging:22.0.0'
    implementation 'com.google.firebase:firebase-analytics:19.0.1'
    implementation platform('com.google.firebase:firebase-bom:28.0.1')
    implementation("com.google.firebase:firebase-iid")
    implementation 'com.nineoldandroids:library:2.4.0'

    implementation 'androidx.appcompat:appcompat:1.3.1'
    implementation 'androidx.vectordrawable:vectordrawable-animated:1.1.0'
    implementation 'androidx.media:media:1.4.1'
    implementation 'androidx.recyclerview:recyclerview:1.2.1'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation "androidx.annotation:annotation:1.2.0"
    testImplementation 'androidx.test.ext:junit:1.1.3'
    implementation 'com.github.bumptech.glide:glide:4.12.0'
    implementation(platform("com.squareup.okhttp3:okhttp-bom:4.4.1"))
    implementation("com.squareup.okhttp3:okhttp")              // No version!
    implementation("com.squareup.okhttp3:okhttp-urlconnection") // No version!

    implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.1.0"
    implementation 'com.google.android.flexbox:flexbox:3.0.0'
    implementation 'androidx.multidex:multidex:2.0.1'

    implementation 'com.facebook.react:react-native:+'
    implementation fileTree(dir: "libs", include: ["*.jar"])
    androidTestImplementation 'junit:junit:4.13.1'


    if (enableHermes) {
    def hermesPath = "../../node_modules/hermes-engine/android/"
    debugImplementation files(hermesPath + "hermes-debug.aar")
    releaseImplementation files(hermesPath + "hermes-release.aar")
    } else {
    implementation jscFlavor
    }
    }


    task copyDownloadableDepsToLibs(type: Copy) {
    from configurations.compile
    into 'libs'
    }
    apply from: "../../node_modules/react-native-vector-icons/fonts.gradle"
    apply plugin: 'com.google.gms.google-services'
    apply plugin: 'com.google.firebase.crashlytics'

This is my manifest.xml

    <?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="com.ssivixlab.MYCLNQ">

    <uses-permission android:name="com.google.android.finsky.permission.BIND_GET_INSTALL_REFERRER_SERVICE"/>
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.DISABLE_KEYGUARD"/>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"
    tools:ignore="ScopedStorage" />
    <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.CAMERA" />

    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
    <uses-permission android:name="android.permission.WAKE_LOCK" />

    <uses-feature android:name="android.hardware.camera" />
    <uses-feature android:name="android.hardware.camera.autofocus" />
    <uses-permission android:name="android.permission.DOWNLOAD_WITHOUT_NOTIFICATION"/>

    <uses-permission android:name="android.permission.BIND_TELECOM_CONNECTION_SERVICE"
    tools:ignore="ProtectedPermissions" />
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
    <uses-permission android:name="android.permission.CALL_PHONE" />

    <supports-screens
    android:anyDensity="true"
    android:largeScreens="false"
    android:normalScreens="true"
    android:resizeable="true"
    android:smallScreens="true"
    android:xlargeScreens="false" />

    <application
    android:name=".MainApplication"
    android:allowBackup="false"
    android:hardwareAccelerated="true"
    android:icon="@drawable/ic_launcher_radius"
    android:launchMode="singleTop"
    android:label="@string/app_name"
    android:largeHeap="true"
    android:requestLegacyExternalStorage="true"
    android:roundIcon="@drawable/ic_launcher_radius"
    android:theme="@style/AppTheme"
    android:usesCleartextTraffic="true"
    tools:targetApi="28"
    android:appComponentFactory="whateverString"
    tools:replace="android:usesCleartextTraffic,android:appComponentFactory">

    <meta-data
    android:name="com.google.android.geo.API_KEY"
    android:value="@string/map_api_key" />
    <meta-data
    android:name="io.fabric.ApiKey"
    android:value="2f914cacc5583670f4cb1165fc3c1b17dcf745c4" />

    <activity
    android:name=".MainActivity"
    android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
    android:exported="true"
    android:label="@string/app_name"
    android:launchMode="singleTop"
    android:screenOrientation="portrait"
    android:theme="@style/SplashTheme"
    android:windowSoftInputMode="adjustResize"
    android:excludeFromRecents="false"
    tools:ignore="LockedOrientationActivity">
    <intent-filter>
    <action android:name="android.intent.action.MAIN" />
    <category android:name="android.intent.category.LAUNCHER" />
    <action android:name="android.intent.action.DOWNLOAD_COMPLETE" />
    </intent-filter>
    <intent-filter>
    <action android:name="android.intent.action.VIEW" />
    <category android:name="android.intent.category.DEFAULT" />
    <category android:name="android.intent.category.BROWSABLE" />
    <data
    android:host="openapp"
    android:scheme="myclnq" />
    <data
    android:host="register"
    android:scheme="myclnq" />
    </intent-filter>
    </activity>
    <activity
    android:exported="false"
    android:name="com.facebook.react.devsupport.DevSettingsActivity" />
    <provider
    android:name="androidx.core.content.FileProvider"
    android:authorities="com.ssivixlab.MYCLNQ"
    android:exported="false"
    android:grantUriPermissions="true"
    tools:replace="android:authorities">
    <meta-data
    android:name="android.support.FILE_PROVIDER_PATHS"
    android:resource="@xml/paths" />
    </provider>

    <service android:name="io.invertase.firebase.messaging.ReactNativeFirebaseMessagingService" />
    <receiver
    android:name="io.invertase.firebase.messaging.ReactNativeFirebaseMessagingReceiver"
    android:exported="true">
    <intent-filter>
    <action android:name="io.invertase.firebase.notifications.BackgroundAction"/>
    </intent-filter>
    </receiver>
    <service
    android:name="io.invertase.firebase.messaging.ReactNativeFirebaseMessagingHeadlessService"/>

    <uses-library
    android:name="org.apache.http.legacy"
    android:required="false" />
    </application>

    </manifest>
0 Answers
Related