Kudo / react-native-v8

Opt-in V8 runtime for React Native Android
MIT License
924 stars 69 forks source link

Bundle not loading #70

Closed rohit-32 closed 3 years ago

rohit-32 commented 3 years ago

Hello I followed your instruction but i keep getting error Exception in HostFunction: Value is an object, expected a number global.nativeLoggingHook(str,log.Level) while running the app

my app/gradle file

` apply plugin: "com.android.application" apply plugin: 'kotlin-android' apply plugin: 'kotlin-android-extensions' apply plugin: 'kotlin-kapt' apply from: "../../node_modules/react-native-vector-icons/fonts.gradle"

import com.android.build.OutputFile

project.ext.react = [ enableHermes: false, // clean and rebuild if changing ]

apply from: "../../node_modules/react-native/react.gradle" apply from: "../../node_modules/react-native-code-push/android/codepush.gradle"

def enableSeparateBuildPerCPUArchitecture = false def enableProguardInReleaseBuilds = false

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

android { compileSdkVersion rootProject.ext.compileSdkVersion

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}

defaultConfig {
    applicationId "com.butlr"
    minSdkVersion rootProject.ext.minSdkVersion
    targetSdkVersion rootProject.ext.targetSdkVersion
    vectorDrawables.useSupportLibrary = true
    versionCode 6
    versionName "1.3"
    multiDexEnabled true
}
splits {
    abi {
        reset()
        enable enableSeparateBuildPerCPUArchitecture
        universalApk false  // If true, also generate a universal APK
        include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
    }
}
signingConfigs {
    debug {
        storeFile file('debug.keystore')
        storePassword 'android'
        keyAlias 'androiddebugkey'
        keyPassword 'android'
    }
    release {
        if (project.hasProperty('BUTLR_UPLOAD_STORE_FILE')) {
            storeFile file(BUTLR_UPLOAD_STORE_FILE)
            storePassword BUTLR_UPLOAD_STORE_PASSWORD
            keyAlias BUTLR_UPLOAD_KEY_ALIAS
            keyPassword BUTLR_UPLOAD_STORE_PASSWORD
        }
    }
}
buildTypes {
    debug {
        signingConfig signingConfigs.debug
        resValue "string", "CodePushDeploymentKey",'""'
    }
    releaseStaging {
        signingConfig signingConfigs.release
        minifyEnabled enableProguardInReleaseBuilds
        resValue "string", "CodePushDeploymentKey", '"fm05lgGGFYfU99Ql8uGwC3NzHSF4H2A183j3D"'
        proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
        matchingFallbacks = ['release']
    }
    release {
        // Caution! In production, you need to generate your own keystore file.
        // see https://reactnative.dev/docs/signed-apk-android.
        signingConfig signingConfigs.release
        minifyEnabled enableProguardInReleaseBuilds
        resValue "string", "CodePushDeploymentKey", '"cvhxqYFKKv6P8c-dBff1J5nU7j3m01AewQF_2"'
        proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"

    }
}

// 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:
        // https://developer.android.com/studio/build/configure-apk-splits.html
        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
        }

    }
}

packagingOptions {
    // Make sure libjsc.so does not packed in APK
    exclude "**/libjsc.so"
}

}

dependencies { def billing_version = "3.0.0"

implementation fileTree(dir: "libs", include: ["*.jar",'*.aar'])
//noinspection GradleDynamicVersion
implementation "com.facebook.react:react-native:+"  // From node_modules
implementation 'org.chromium:v8-android:+'

implementation project(':watermelondb')
implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0"

debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") {
  exclude group:'com.facebook.fbjni'
}

debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
    exclude group:'com.facebook.flipper'
}

debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") {
    exclude group:'com.facebook.flipper'
}

// if (enableHermes) { // def hermesPath = "../../node_modules/hermes-engine/android/"; // debugImplementation files(hermesPath + "hermes-debug.aar") // releaseStagingImplementation files(hermesPath + "hermes-release.aar") // releaseImplementation files(hermesPath + "hermes-release.aar") // } else { // implementation jscFlavor // } implementation "androidx.core:core-ktx:+" implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.3' implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.3' implementation 'com.google.code.gson:gson:2.8.5' implementation 'com.android.support:multidex:2.0.1' implementation "com.android.billingclient:billing-ktx:$billing_version"

}

// 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 from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project) repositories { maven { url 'https://dl.bintray.com/kotlin/kotlin-eap' } mavenCentral() }

`

my app/android/gradle file

` // Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript { ext.kotlin_version = '1.4.0-rc' ext { buildToolsVersion = "29.0.2" minSdkVersion = 21 compileSdkVersion = 29 targetSdkVersion = 29 } repositories { google() jcenter() maven { url 'https://dl.bintray.com/kotlin/kotlin-eap' } } dependencies { classpath("com.android.tools.build:gradle:3.5.3") classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}

}

allprojects { repositories { mavenLocal() maven { // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm url("$rootDir/../node_modules/react-native-v8/dist") } maven { // prebuilt libv8android.so url("$rootDir/../node_modules/v8-android-jit-nointl/dist") }

    google()
    jcenter()
    maven { url 'https://maven.google.com' }
    maven { url 'https://www.jitpack.io' }
}

} `

Can you help with what i am doing wrong

biomancer commented 3 years ago

I am using react-native-v8 with v8-android-nointl and I was getting the same error when I upgraded react-native-v8 to 0.64.0-patch.0 and left v8-android-nointl@8.84.0. Upgrading v8-android-nointl to latest 9.88.0 version fixed the issue. So probably there is some mismatch in react-native-v8 and v8-android versions in your case too.

Kudo commented 3 years ago

the react-native-v8 version should map to v8-android-* version. i've updated the README for the full version mappings.