Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failing to load libhermes.so on Chromebooks #53

Closed
asleepace opened this issue Nov 19, 2019 · 5 comments
Closed

Failing to load libhermes.so on Chromebooks #53

asleepace opened this issue Nov 19, 2019 · 5 comments

Comments

@asleepace
Copy link

asleepace commented Nov 19, 2019

Description

Recently we started using SoLoader version 0.8.0 to fix an issue with the hermes engine not loading on some phones like the Oppo. However after this fix we are seeing a new error that seems to only be affecting Chromebooks running our react native application.

Fatal Exception: java.lang.UnsatisfiedLinkError
couldn't find DSO to load: libhermes.so caused by: APK was built for a different platform

com.facebook.soloader.SoLoader.doLoadLibraryBySoName (SoLoader.java:789)
com.facebook.soloader.SoLoader.loadLibraryBySoName (SoLoader.java:639)
com.facebook.soloader.SoLoader.loadLibrary (SoLoader.java:577)
com.facebook.soloader.SoLoader.loadLibrary (SoLoader.java:525)
com.facebook.hermes.reactexecutor.HermesExecutor.<clinit> (HermesExecutor.java:20)
com.facebook.hermes.reactexecutor.HermesExecutorFactory.create (HermesExecutorFactory.java:27)
com.facebook.react.ReactInstanceManager$5.run (ReactInstanceManager.java:949)

Platforms

Although we are unable to reproduce the error it appears to happen on android versions 5-9 and only on Chromebooks with the majority being the Google Chromebook 11 Model 3180.

Gradle

ext {
    buildToolsVersion = "28.0.3"
    minSdkVersion = 19
    compileSdkVersion = 28
    targetSdkVersion = 28
    supportLibVersion = "28.0.0"
    playServicesVersion = "17.0.0"
    googlePlayServicesAuthVersion = "16.0.1" // <--- use this version or newer
}


buildscript {
    repositories {
        google()
        jcenter()
        maven {
            url 'https://maven.google.com/'
            name 'Google'
        }
        maven {
            url 'https://maven.fabric.io/public'
        }
        google()
    }
    dependencies {
        classpath('com.android.tools.build:gradle:3.4.2')
        classpath("com.google.gms:google-services:4.0.1")
        classpath("com.jaredsburrows:gradle-license-plugin:0.8.41")
        classpath("embrace-io:embrace-swazzler:3.4.1")
        classpath('io.fabric.tools:gradle:1.28.1')
        classpath('com.google.firebase:perf-plugin:1.3.1')
    }
}

allprojects {
    repositories {
        mavenLocal()
        google()
        jcenter()
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url("$rootDir/../node_modules/react-native/android")
        }
        maven {
            // Android JSC is installed from npm
            url("$rootDir/../node_modules/jsc-android/dist")
        }
        maven {
            url 'https://maven.google.com/'
            name 'Google'
        }
        configurations.all {
            resolutionStrategy {
                force "com.facebook.soloader:soloader:0.8.0"
            }
            resolutionStrategy.eachDependency { DependencyResolveDetails details ->
                def requested = details.requested
                // Note: order matters here, start with the most generic library, in this case the
                // android gms, and then change more specific packages below.
                if (requested.group == 'com.google.android.gms') {
                    details.useVersion rootProject.ext.playServicesVersion
                }
                if (requested.name == 'firebase-iid') {
                    details.useVersion '20.0.1'
                }
                if (requested.name == 'play-services-vision') {
                    details.useVersion '17.0.2'
                }
                if (requested.name == 'play-services-vision-common') {
                    details.useVersion '17.0.2'
                }
                if (requested.name == 'play-services-vision-image-label') {
                    details.useVersion '17.0.2'
                }
                if (requested.group == 'com.android.support') {
                    if (!requested.name.startsWith("multidex")) {
                        details.useVersion "${rootProject.ext.supportLibVersion}"
                    }
                }
            }
        }
    }
}

subprojects {
    afterEvaluate {project ->
        if (project.hasProperty("android")) {
            android {
                compileSdkVersion rootProject.ext.compileSdkVersion
                buildToolsVersion rootProject.ext.buildToolsVersion
            }
        }
    }
}
    packagingOptions {
        pickFirst '**/armeabi-v7a/libc++_shared.so'
        pickFirst '**/x86/libc++_shared.so'
        pickFirst '**/arm64-v8a/libc++_shared.so'
        pickFirst '**/x86_64/libc++_shared.so'
        pickFirst '**/x86/libjsc.so'
        pickFirst '**/armeabi-v7a/libjsc.so'
    }
        def hermesPath = "../../node_modules/hermes-engine/android/"
        debugImplementation files(hermesPath + "hermes-debug.aar")
        releaseImplementation files(hermesPath + "hermes-release.aar")

Library Versions

Note we have already looked into other similar PRs such as this, however we are building our app as an apk and not bundling.

  • SoLoader 0.8.0
  • react-native 0.60.5
  • hermes-engine ^0.1.1
@asleepace
Copy link
Author

Interestingly enough when side-loading the application directly onto the Chromebook via

./gradlew installRelease

The application runs as expected, it only seems to be a problem when directly downloading from the Play Store.

@ilydnic
Copy link

ilydnic commented Jul 14, 2020

@asleepace any updates on if you were able to resolve this? Currently also seeing this issue in production.

@noumantahir
Copy link

@asleepace were you able to fix the issue, I am also experiencing the same issue in my app... any suggestions?

@asleepace
Copy link
Author

@noumantahir I'm not sure my solution is still relevant, but maybe try the following in the project's .gradle file:

allprojects {
    repositories {
        mavenLocal()
        jcenter()
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url("$rootDir/../../node_modules/react-native/android")
        }
        maven {
            // Android JSC is installed from npm
            url("$rootDir/../../node_modules/jsc-android/dist")
        }
        google()
        maven {
            url 'https://maven.google.com/'
            name 'Google'
        }
        maven {
            // All of Detox' artifacts are provided via the npm module
            url "$rootDir/../../node_modules/detox/Detox-android"
        }
        maven { url 'https://www.jitpack.io' }
        configurations.all {
            resolutionStrategy {
                force "com.facebook.soloader:soloader:0.9.0+"
            }
            resolutionStrategy.eachDependency { DependencyResolveDetails details ->
                // We used to use this section to override support libraries in different
                // modules, however this is not an ideal strategy and we should opt to exclude
                // certain libraries in the App gradle dependencies (see nearby for example)
                // or here https://docs.gradle.org/current/userguide/dependency_downgrade_and_exclude.html
                // see version prior to 120.0 for actual implementation here.
            }
        }
    }
}

Specifically this line

resolutionStrategy {
  force "com.facebook.soloader:soloader:0.9.0+"
}

We also now use ./gradlew bundleRelease when releasing out application.

Hope this helps, it's been quite a while so I can't really remember 😅

@simpleton
Copy link
Member

Version 0.10.3 has been released which includes this fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants