Skip to content

Android build fails with com.facebook.infer.annotation.Assertions not found on latest Expo SDK 31.0.0 & React Native 0.57 #342

@webdevbyjoss

Description

@webdevbyjoss

Build failure

Trying to build the Android app after detaching on latest Expo SDK 31.0.0 & React Native 0.57.

Build fails with the following:

/home/travis/build/-------/node_modules/react-native-youtube/android/src/main/java/com/inprogress/reactnativeyoutube/YouTubeManager.java:5: error: package com.facebook.infer.annotation does not exist

import com.facebook.infer.annotation.Assertions;
                                    ^
/home/travis/build/-------/node_modules/react-native-youtube/android/src/main/java/com/inprogress/reactnativeyoutube/YouTubeManager.java:49: error: cannot find symbol
        Assertions.assertNotNull(view);
        ^
  symbol:   variable Assertions
  location: class YouTubeManager
/home/travis/build/-------/node_modules/react-native-youtube/android/src/main/java/com/inprogress/reactnativeyoutube/YouTubeManager.java:50: error: cannot find symbol
        Assertions.assertNotNull(args);
        ^
  symbol:   variable Assertions
  location: class YouTubeManager
Note: /home/travis/build/-------/node_modules/react-native-youtube/android/src/main/java/com/inprogress/reactnativeyoutube/YouTubeStandaloneModule.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
3 errors
:react-native-youtube:compileReleaseJavaWithJavac FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':react-native-youtube:compileReleaseJavaWithJavac'.
> Compilation failed; see the compiler error output for details.

The build was passing successfully on Expo SDK 28.0.0 & React Native 0.55 before the upgrade.

Workaround

Add the explicit infer-annotation dependency to react-native-youtube/android/build.gradle:

dependencies  {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.facebook.react:react-native:+'
    compile 'com.facebook.infer.annotation:infer-annotation:+'    <====== add this line!!!!
}

Build turns green again!

This assertion is actually used only once:
https://github.com/inProgress-team/react-native-youtube/search?q=Assertions&unscoped_q=Assertions

Wondering if we could get rid of this whole library and assertion code to just have:

if (object == null) {
      throw new AssertionError();
}

that's actually what it does under the hood: https://github.com/facebook/infer/blob/master/infer/annotations/src/main/java/com/facebook/infer/annotation/Assertions.java#L24

Would be happy to do a PR for this fix, if you think it all makes sense.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions