question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Android compilation problem with expo-av 11.2.3: In file included from .../cpp/JPlayerData.h:6:10: fatal error: 'fbjni/fbjni.h' file not found

See original GitHub issue

Summary

I am expecting that I can follow https://github.com/expo/expo/tree/main/templates/expo-template-bare-minimum then bump expo-av version from 10x series to 11

and my build would succeed

Instead I am getting:

In file included from …/…/…/…/src/main/cpp/JPlayerData.cpp:3: …/…/…/…/src/main/cpp/JPlayerData.h:6:10: fatal error: ‘fbjni/fbjni.h’ file not found

I am not using the new architecture, I am not building a new application. None of the instructions suggest to include anything C++ related, I am not including fbjni in any of my code direction.

Where should I start looking to troubleshoot this? Thank you

build.grade (not app/build.gradle):

import static org.apache.tools.ant.taskdefs.condition.Os.OS_NAME
import org.apache.tools.ant.taskdefs.condition.Os
apply from: 'app/config/gradle_cfg/versioning.gradle'

def myNodeModulesRootDir_abs="${rootDir}/.."

buildscript { //these tools are for building things
    ext {
        targetSdkVersion = Integer.parseInt(findProperty('android.targetSdkVersion') ?: "31") //set the same as compileSDK below

        buildToolsVersion = findProperty('android.buildToolsVersion') ?: "31.0.0"
        kotlinVersion = "1.6.10"
        if (hasProperty('android.kotlinVersion')) {
            kotlinVersion = findProperty('android.kotlinVersion')
        }

        if (System.properties['os.arch'] == "aarch64") {
            // For M1 Users we need to use the NDK 24 which added support for aarch64
            ndkVersion = "24.0.8215888"
        } else if (Os.isFamily(Os.FAMILY_WINDOWS)) {
            // For Android Users, we need to use NDK 23, otherwise the build will
            // fail due to paths longer than the OS limit
            ndkVersion = "23.1.7779620"
        } else {
            // Otherwise we default to the side-by-side NDK version from AGP.
            ndkVersion = "21.4.7075529"
        }
    }
    repositories {
        google() //needed for gradle android plugin
        maven { url 'https://jitpack.io' } //for rxbilling
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:7.0.4'//7.2.0'
        classpath("com.facebook.react:react-native-gradle-plugin")
        classpath("de.undercouch:gradle-download-task:4.1.2")
    }

}

allprojects { //these are for my app
    buildDir = "${System.getenv('HOME')}/tmp/${rootProject.name}/${project.name}"
    repositories {
        mavenLocal()
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url(new File(["node", "--print", "require.resolve('react-native/package.json')"].execute(null, rootDir).text.trim(),
                    "../android"))
        }
        maven {
            // Android JSC is installed from npm
            url(new File(["node", "--print", "require.resolve('jsc-android/package.json')"].execute(null, rootDir).text.trim(),
                    "../dist"))
        }


        mavenCentral {
            content {
                excludeGroup "com.facebook.react"
            }
        }
        google()
        maven { url 'https://www.jitpack.io' }
    }
    logger.quiet("~~~ rootDir is ${rootDir}")
    logger.quiet("~~~ buildDir is ${buildDir}")
    logger.quiet("~~~ Kotlin version is set to ${rootProject.ext.kotlinVersion}")
	repositories
	{	
	  mavenCentral()
	  }		

}

subprojects {

    repositories {
        //jcenter()
        google ()
    }

    //inject for every android project
       afterEvaluate {project ->
        if (project.hasProperty("android")) {
            android {
                compileSdkVersion rootProject.ext.targetSdkVersion

            }
        }
    }

}

wrapper {
    distributionType = Wrapper.DistributionType.ALL
}

gradle.properties:

buildNumber=10 
version=1.1.10

org.gradle.caching=true
org.gradle.unsafe.configuration-cache=false
org.gradle.unsafe.configuration-cache-problems=warn
org.gradle.daemon=true
org.gradle.parallel=true
org.gradle.jvmargs=-Xmx2536m -XX:+UseParallelGC -Dfile.encoding=UTF-8  
org.gradle.configureondemand=true


disableAllBuildTypesApartFrom=debug
android.useAndroidX=true
pk12FileLocation=overridden
releaseTrack=alpha
increaseMinSdkForDev=false


android.enableJetifier=true
disableSomeBuildTypes=false
dexMemoryAllocation="1092m"

FLIPPER_VERSION=0.125.0
expo.jsEngine="hermes"



# Use this property to enable support to the new architecture.
# This will allow you to use TurboModules and the Fabric render in
# your application. You should enable this flag either if you want
# to write custom TurboModules/Fabric components OR use libraries that
# are providing them.
newArchEnabled=false

# Enable GIF support in React Native images (~200 B increase)
expo.gif.enabled=true
# Enable webp support in React Native images (~85 KB increase)
expo.webp.enabled=true
# Enable animated webp support (~3.4 MB increase)
# Disabled by default because iOS doesn't support animated webp
expo.webp.animated=false
#expo end


android.enableR8.fullMode=false

What platform(s) does this occur on?

Android

SDK Version

45.0.4

Environment

expo-env-info 1.0.3 environment info: System: OS: Linux 5.15 Manjaro Linux Shell: 5.1.16 - /bin/bash Binaries: Node: 16.14.2 - ~/.nvm/versions/node/v16.14.2/bin/node Yarn: 1.22.18 - ~/.nvm/versions/node/v16.14.2/bin/yarn npm: 8.5.0 - ~/.nvm/versions/node/v16.14.2/bin/npm npmPackages: expo: ^45 => 45.0.4 react: 17.0.2 => 17.0.2 react-native: 0.68.1 => 0.68.1 Expo Workflow: managed

Reproducible demo

I am looking for guidance on how to troubleshoot this new build/compile issue due to expo-av upgrade My application is not a ‘full’ expo app, I am just using RN+Expo-av in one of the activities.
Since my app is not a full expo app, I always use https://github.com/expo/expo/tree/main/templates/expo-template-bare-minimum
as a guide for upgrades.

I had copied/inserts bits in pieces in all the various config files that I have to manually manage with every upgrade. But i cannot see what I missed to get passed this error

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:1
  • Comments:11 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
vladpcommented, Nov 24, 2022

For what it is worth, I think this is also the reason, I think, why many folks get strange build errors when they switch from Debug to Release, or Release to Debug build types, at least on Android. It is because the expo-av build process deposits its artifacts in the locations that are not understood by Gradle :clean commands, (and certainly by the Include directives as I noted above). So the remedy there is to delete the node_modules directory and then recreate it with yarn install (this is what I am doing at least).

1reaction
vladpcommented, Nov 22, 2022

@barthap @Kudo I found what was causing this expo-av induced build problem. It took me may be 100 of iterations over the course of the year, was very difficult, I have to say.

In my project level gradle, I had


allprojects { 
    buildDir = "${System.getenv('HOME')}/tmp/${rootProject.name}/${project.name}"

In other words, I was directing gradle to use different directory to store build/intermediate results. I had this in place for last 7 years, never caused a problem. It was done so that I can build on windows and linux machines without running into ‘long path name’ issues.

The build process that expo-av introduced, involves, apparently generating fbjni.h in-place (I guess into node_modules directory directly ?). When I looked into my buildDir (find . -name “fbjni.h”) – I saw the fbjni.h file there. So it was generated correctly into that folder, but I am guessing the way that header include is setup in expo-av, it does not consider this way of configuring the build steps, so the compiler could not find the header files…

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error 'features.h' file not found in QTCreator in a Android Project
This is caused by an unsupported version of NDK. You need to: Install the proper version of Android NDK in Android Studio (21.3.6528147)...
Read more >
Known issues with Android Studio and Android Gradle Plugin
Compilation errors may arise in Kotlin MPP code due to missing symbols. Upgrading your Kotlin plugin to version 1.4 should resolve this issue....
Read more >
AV - Expo Documentation
This is only present if the media has a duration. Note that in some cases, a media file's duration is readable on Android,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found