我有一个现有的react本地应用程序,尽管我在android/ app /build.gradle中配置了hermes,并且使用了Pro卫兵规则,但这是行不通的。
我的意思是,当我在运行时检查时,它说hermes没有运行。
const isHermes = () => !!global.HermesInternal;
console.log('hermes: ', isHermes()); <==== logs false
在我能看到的日志里
not allowing consideration of lib/armeabi-v7a/libhermes-executor-common-debug.so: deferring to libdir
not allowing consideration of lib/armeabi-v7a/libhermes-executor-common-release.so: deferring to libdir
not allowing consideration of lib/armeabi-v7a/libhermes-executor-debug.so: deferring to libdir
not allowing consideration of lib/armeabi-v7a/libhermes-executor-release.so: deferring to libdir
not allowing consideration of lib/armeabi-v7a/libhermes-inspector.so: deferring to libdir
not allowing consideration of lib/armeabi-v7a/libhermes.so: deferring to libdir
在卫兵规则中。
# hermes
-keep class com.facebook.hermes.unicode.** { *; }
-keep class com.facebook.jni.** { *; }
应用程序/build.gradle
apply plugin: "com.android.application"
apply plugin: "com.bugsnag.android.gradle"
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.google.firebase.crashlytics'
//react-native-config (https://github.com/luggit/react-native-config#android-1)
project.ext.envConfigFiles = [
dev: ".env.dev",
staging: ".env.staging",
beta: ".env.production",
release: ".env.production"
]
apply from: project(':react-native-config').projectDir.getPath() + "/dotenv.gradle"
//!react-native-config
apply plugin: "com.google.firebase.firebase-perf"
import com.android.build.OutputFile
project.ext.react = [
// clean and rebuild if changing,
entryFile: "index.js",
enableHermes: true
]
apply from: "../../node_modules/react-native/react.gradle"
apply from: "../../node_modules/react-native-code-push/android/codepush.gradle"
/**
* Set this to true to create two separate APKs instead of one:
* - An APK that only works on ARM devices
* - An APK that only works on x86 devices
* The advantage is the size of the APK is reduced by about 4MB.
* Upload all the APKs to the Play Store and people will download
* the correct one based on the CPU architecture of their device.
*/
def enableSeparateBuildPerCPUArchitecture = false
/**
* Run Proguard to shrink the Java bytecode in release builds.
*/
def enableProguardInReleaseBuilds = true
/**
* The preferred build flavor of JavaScriptCore.
*
* For example, to use the international variant, you can use:
* `def jscFlavor = 'org.webkit:android-jsc-intl:+'`
*
* The international variant includes ICU i18n library and necessary data
* allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that
* give correct results when using with locales other than en-US. Note that
* this variant is about 6MiB larger per architecture than default.
*/
def jscFlavor = 'org.webkit:android-jsc:+'
/**
* Whether to enable the Hermes VM.
*
* This should be set on project.ext.react and mirrored here. If it is not set
* on project.ext.react, JavaScript will not be compiled to Hermes Bytecode
* and the benefits of using Hermes will therefore be sharply reduced.
*/
def enableHermes = project.ext.react.get("enableHermes", true);
logger.warn('enableHermes: {}', enableHermes)
/**
* Architectures to build native code for in debug.
*/
def nativeArchitectures = project.getProperties().get("reactNativeDebugArchitectures")
android {
ndkVersion rootProject.ext.ndkVersion
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
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'
pickFirst '**/x86_64/libjsc.so'
pickFirst '**/arm64-v8a/libjsc.so'
pickFirst "lib/armeabi-v7a/libc++_shared.so"
pickFirst "lib/arm64-v8a/libc++_shared.so"
pickFirst "org/bouncycastle/x509/CertPathReviewerMessages_de.properties"
pickFirst "org/bouncycastle/x509/CertPathReviewerMessages.properties"
pickFirst "lib/x86/libc++_shared.so"
pickFirst "lib/x86_64/libc++_shared.so"
exclude "**/libjsc.so"
}
compileSdkVersion rootProject.ext.compileSdkVersion
defaultConfig {
applicationIdSuffix ""
applicationId "XXX.YYY"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1038160033
vectorDrawables.useSupportLibrary = true
versionName "5.8.130"
resConfigs "fr", "FR"
if (nativeArchitectures) {
ndk {
abiFilters nativeArchitectures.split(',')
}
}
resValue "string", "build_config_package", "XXX.YYY"
//fix for codepush not being able to install downloaded package
//https://github.com/microsoft/react-native-code-push/issues/1961#issuecomment-710698621
resValue 'string', "CODE_PUSH_APK_BUILD_TIME", String.format("\"%d\"", System.currentTimeMillis())
}
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"
}
}
bugsnag {
uploadReactNativeMappings = true // enables upload of React Native source maps
}
buildTypes {
//note that config name that contain 'release' will be build with DEV turned off for React Native
//all other will have DEV set to true. Look for the Note in the android section of this page
//https://learn.microsoft.com/en-us/appcenter/distribution/codepush/rn-deployment#android
//!!!!! don't modify the version via versionNameSuffix, else code push will not find the version anymore
debug {
manifestPlaceholders = [excludeSystemAlertWindowPermission: "false",
DOMAIN:"XXX",
FIREBASE_DOMAIN:'XXX',
brandTestMode:"true",
BUGSNAG_KEY:"XXX"]
applicationIdSuffix ".debug"
debuggable true
signingConfig signingConfigs.release
firebaseCrashlytics {
nativeSymbolUploadEnabled false
}
resValue "string", "CodePushDeploymentKey", '"xxxx"'
}
dev {
initWith debug
manifestPlaceholders = [excludeSystemAlertWindowPermission: "false",
DOMAIN:"xxx",
FIREBASE_DOMAIN:'xxx',
brandTestMode:"true",
BUGSNAG_KEY:"xxxx"]
matchingFallbacks = ['debug']
applicationIdSuffix ".debug"
firebaseCrashlytics {
nativeSymbolUploadEnabled false
}
//disable codepush in dev builds
resValue "string", "CodePushDeploymentKey", '""' // '"xxxx"'
}
staging {
initWith debug
manifestPlaceholders = [excludeSystemAlertWindowPermission: "false",
DOMAIN:"xxxco",
FIREBASE_DOMAIN:'xxxx',
brandTestMode:"true",
BUGSNAG_KEY:"xxxxx"]
matchingFallbacks = ['debug']
applicationIdSuffix ".debug"
firebaseCrashlytics {
nativeSymbolUploadEnabled false
}
resValue "string", "CodePushDeploymentKey", '"xxxxx"'
}
beta {
initWith release
manifestPlaceholders = [excludeSystemAlertWindowPermission: "true",
DOMAIN:"xxx",
FIREBASE_DOMAIN:'fbxxx',
brandTestMode:"false",
BUGSNAG_KEY:"xxxx"]
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
signingConfig signingConfigs.release
matchingFallbacks = ['release']
applicationIdSuffix ".beta"
shrinkResources true
firebaseCrashlytics {
nativeSymbolUploadEnabled false
}
resValue "string", "CodePushDeploymentKey", '"xxxx"'
}
release {
manifestPlaceholders = [excludeSystemAlertWindowPermission: "true",
DOMAIN:"xxxx",
FIREBASE_DOMAIN:'xxx',
brandTestMode:"false",
BUGSNAG_KEY:"xxxxx"]
minifyEnabled false
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
signingConfig signingConfigs.release
firebaseCrashlytics {
nativeSymbolUploadEnabled false
}
resValue "string", "CodePushDeploymentKey", '"xxxxx"'
}
}
}
ext.abiCodes = ['armeabi-v7a':'1', 'arm64-v8a':'2', 'mips':'3', 'x86':'4', 'x86_64':'5']
// For each APK output variant, override version code of outputs based on ABI codes
// ex) 'mips' -> 3xxx
// ex) 'x86' -> 4xxx
android.applicationVariants.all { variant ->
variant.outputs.each { output ->
def baseVersionCode = project.ext.abiCodes.get(output.getFilter(OutputFile.ABI))
if (baseVersionCode != null) {
output.versionCodeOverride = Integer.valueOf(baseVersionCode + variant.versionCode)
}
}
}
dependencies {
implementation "com.google.firebase:firebase-messaging:22"
implementation 'com.google.firebase:firebase-appcheck-safetynet:16.0.0-beta01'
// To enable the Google Advertising ID for adjust
// https://help.adjust.com/en/article/get-started-android-sdk#add-google-play-services
implementation 'com.google.android.gms:play-services-location:18.0.0'
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation ("com.facebook.react:react-native:+") { force = true
}
implementation 'org.chromium:v8-android:9.93.+'
debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
exclude group:'com.facebook.flipper'
exclude group:'com.squareup.okhttp3', module:'okhttp'
}
debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") {
exclude group:'com.facebook.flipper'
}
debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") {
exclude group:'com.facebook.fbjni'
}
implementation 'com.squareup.okhttp3:okhttp:4.9.0'
implementation("com.squareup.okhttp3:okhttp-urlconnection:4.4.1")
implementation 'com.instabug.library:instabug-apm-okhttp-interceptor:10.4.0'
implementation ('com.facebook.fresco:fresco:2.4.0') {
exclude module: 'nativeimagefilters'
exclude module: 'nativeimagetranscoder'
}
// implementation project(':react-native-fast-image')
// For animated GIF support
implementation 'com.facebook.fresco:animated-gif:2.4.0'
implementation 'com.google.android.gms:play-services-wallet:18.1.2'
// For WebP support, including animated WebP
implementation 'com.facebook.fresco:animated-webp:2.4.0'
implementation 'com.facebook.fresco:webpsupport:2.4.0'
implementation 'com.facebook.android:facebook-core:9.1.0'
implementation project(':react-native-check-app-install')
implementation "com.stripe:stripe-3ds2-android:5.3.1"
implementation 'com.braintreepayments.api:braintree:3.17.3'
implementation 'com.braintreepayments.api:three-d-secure:3.17.3'
implementation 'com.google.android.gms:play-services-ads-identifier:17.0.0'
implementation 'com.android.installreferrer:installreferrer:2.2'
implementation 'com.google.android.gms:play-services-auth:18.1.0'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
implementation project(':tipsi-stripe')
implementation 'me.leolin:ShortcutBadger:1.1.22@aar' // <-- Add this line if you wish to use badge on Android
implementation('com.eightbitlab:blurview:1.6.6') {
force = true
}
logger.warn('enableHermes 3: {}', enableHermes)
if (enableHermes) {
logger.warn('enableHermes 4')
def hermesPath = "../../node_modules/hermes-engine/android/";
debugImplementation files(hermesPath + "hermes-debug.aar")
releaseImplementation files(hermesPath + "hermes-release.aar")
} else {
implementation jscFlavor
}
}
// 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.implementation
into 'libs'
}
project.ext.vectoricons = [
iconFontNames: [ 'Ionicons.ttf' ] // Name of the font files you want to copy
]
apply from: "../../node_modules/react-native-vector-icons/fonts.gradle"
apply plugin: 'com.google.gms.google-services'
googleServices { disableVersionCheck = true }
apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle");
applyNativeModulesAppBuildGradle(project)
发布于 2022-02-09 16:23:39
原来这个项目已经为安卓系统配置了V8。一旦我删除了V8,问题就消失了。
https://stackoverflow.com/questions/70941815
复制相似问题