EAS Build failed, help


FAILURE: Build completed with 2 failures.
1: Task failed with an exception.
* Where:
Build file '/home/expo/workingdir/build/node_modules/react-native-google-mobile-ads/android/build.gradle' line: 75
* What went wrong:
A problem occurred evaluating project ':react-native-google-mobile-ads'.
> Cannot get property 'googleMobileAdsJson' on extra properties extension as it does not exist
2: Task failed with an exception.
* What went wrong:
A problem occurred configuring project ':react-native-google-mobile-ads'.
> compileSdkVersion is not specified. Please add it to build.gradle

What am I missing? Where did you see my code

Hi @anasbouziane

That post is SPAM

2 Likes

Hi @anasbouziane,

In your project, I do not see that react-native-google-mobile-ads library is set up correctly. As per their documentation here the react-native-google-mobile-ads object has to go outside the expo in app.json file. For example:

{
  "expo": {
    // ...
  },
  "react-native-google-mobile-ads": {
    "android_app_id": "ca-app-pub-xxxxxxxx~xxxxxxxx",
    "ios_app_id": "ca-app-pub-xxxxxxxx~xxxxxxxx"
  }
}

Other issues in your project configuration are:

  • There is expo-ads-admob installed and specified under package.json > "dependencies". I’d suggest remove this since this package has been deprecated and removed from SDK 46 and above. Your project is using SDK 47.
  • Also, your project has another issue such as using React Native version 0.70.6 installed. SDK 47 is compatible with 0.70.5. This can be checked and resolved by running expo-cli doctor command locally. Fixing these dependencies issues, following instructions for setting up react-native-google-mobile-ads library, and then re-running the build should fix these issues.
1 Like

Yes I see
Thanks wodin

@amanhimself
“expo”: {
// …
},
“react-native-google-mobile-ads”: {
“android_app_id”: “ca-app-pub-xxxxxxxx~xxxxxxxx”,
“ios_app_id”: “ca-app-pub-xxxxxxxx~xxxxxxxx”
},
This is my code, I don’t see any difference


I removed the package you mentioned ‘expo-ads-admob’.


And when I try running the ‘expo-cli doctor command’ it gives an error
(The expected package.json path: C:.…\command\package.json does not exist)

Is this path in any way related to your project?

(Maybe a stupid question :slight_smile: but did you run it inside your project directory?)

No , but I added the command word the the command lol,


It worked well this time ‘expo-cli doctor’ and it suggested this :

expo doctor --fix-dependencies
Some dependencies are incompatible with the installed expo package version:

  • react-native - expected version: 0.70.5 - actual version installed: 0.70.6

This command is being executed with the global Expo CLI. Learn more: The New Expo CLI. In Expo SDK 46 we introduced a new… | by Evan Bacon | Exposition
To use the local CLI instead (recommended in SDK 46 and higher), run:
Some dependencies are incompatible with the installed expo package version:

  • react-native - expected version: 0.70.5 - actual version installed: 0.70.6
    Your project may not work correctly until you install the correct versions of the packages.
    To install the correct versions of these packages, please run: expo doctor --fix-dependencies,
    or install individual packages by running expo install [package-name …]

Error: Problem validating fields in app.json. Learn more: Configuration with app.json/app.config.js - Expo Documentation
• should NOT have additional property ‘react-native-google-mobile-ads’.

And when I run : expo doctor --fix-dependencies

Some dependencies are incompatible with the installed expo package version:

  • react-native - expected version: 0.70.5 - actual version installed: 0.70.6

This command is being executed with the global Expo CLI. Learn more: …

To use the local CLI instead (recommended in SDK 46 and higher), run:
› npx expo install

Installing 1 SDK 47.0.0 compatible native module using npm.

npm install

added 4 packages, changed 7 packages, and audited 1207 packages in 47s

54 packages are looking for funding
run npm fund for details

5 high severity vulnerabilities

To address all issues (including breaking changes), run:
npm audit fix --force

Run npm audit for details.

Error: Problem validating fields in app.json. Learn more: …
** • should NOT have additional property ‘react-native-google-mobile-ads’.

That’s quite confusing :slight_smile:

Of course in general you should use npx expo ... instead of expo-cli ..., but for upgrade or doctor you should indeed use expo-cli

The complaint about invalid fields in app.json is probably just because the Expo tools aren’t expecting non-expo stuff in app.json. Not sure if it’s normal with react-native-google-mobile-ads

Thanks a lot for your time Michael.

1 Like

When I am looking at your latest build, I see the "react-native-google-mobile-ads" part of "expo" block configuration in app.json. As per their docs, this "react-native-google-mobile-ads" block needs to be outside of the block "expo".

Here is an example configuration of how app.json will look like:

{
  "expo": {   //--> expo blocks start here
    "name": "rnadmob-test",
    "slug": "rnadmob-test",
    "version": "1.0.0",
    "orientation": "portrait",
    "icon": "./assets/icon.png",
    "userInterfaceStyle": "light",
    "splash": {
      "image": "./assets/splash.png",
      "resizeMode": "contain",
      "backgroundColor": "#ffffff"
    },
    "updates": {
      "fallbackToCacheTimeout": 0
    },
    "assetBundlePatterns": ["**/*"],
    "ios": {
      "supportsTablet": true
    },
    "android": {
      "adaptiveIcon": {
        "foregroundImage": "./assets/adaptive-icon.png",
        "backgroundColor": "#FFFFFF"
      },
      "package": "com.amanhimself.admobstest"
    },
    "web": {
      "favicon": "./assets/favicon.png"
    },
    "extra": {
      "eas": {
        "projectId": "910c5ec6-6bdf-4476-9b2e-a216c4f14248"
      }
    }
  },   //--> expo blocks ends here
// then the mobile ads library config is added =======================
  "react-native-google-mobile-ads": {
    "android_app_id": "ca-app-pub-1671297437112106~3920968130",
    "ios_app_id": "ca-app-pub-1671297437112106~3920968130"
  }
}

Could also be this is why you are getting the invalid app.json error as you shared:

2 Likes

Invariant Violation: Your JavaScript code tried to access a native module that doesn’t exist.

A frequent cause of the error is that the application entry file path is incorrect. This can also happen when the JS bundle is corrupt or there is an early initialization error when loading React Native.

There is always errors I don’t know why , I did all the things you mentioned

Are you getting the error when you are running the build on the device/emulator? Also, which command you are using to start the development server in the development build?

Just to be clear, you will not be able to run this in Expo Go. You will need to run it in a development build (a.k.a. dev client) which is basically like a custom version of Expo Go that has your dependencies compiled in.

  1. I have created another project and installed the react-native-google mobile-ads and added the block in App.json as you mentioned.

  2. The command I am using to start is 'npx expo start --tunnel' and then I scan the code from the Expo mobile app from my ‘iPhone 7’ , but suddenly nothing appears except that default splash screen.

  3. Also successfully intalled expo-dev-client .

  4. when I run 'npm install -g eas-cli' it gives this :

changed 351 packages, and audited 352 packages in 10s*
35 packages are looking for funding*
run npm fund for details*

2 high severity vulnerabilities*

Some issues need review, and may require choosing*
a different dependency.

  1. I successfully logged in using eas login.

  2. I successfully exucuted also eas build:configure :

💡 The following process will configure your iOS and/or Android project to be compatible with EAS Build. These changes only 
apply to your local project files and you can safely revert them at any time.

√ Which platforms would you like to configure for EAS Build? » Android

🎉 Your project is ready to build.

- Run eas build when you are ready to create your first build.        
- Once the build is completed, run eas submit to upload the app to app stores.
- Learn more about other capabilities of EAS Build: https://docs.expo.dev/build/introduction

And my code is as simple as that :

import { StatusBar } from 'expo-status-bar';
import { StyleSheet, Text, View } from 'react-native';
import {
  // AppOpenAd,
  // InterstitialAd,
  // RewardedAd,
  BannerAd,
  TestIds,
  BannerAdSize,
} from "react-native-google-mobile-ads";

export default function App() {
  return (
    <SafeAreaView style={styles.container}>
      <View>
        <Text>Open up App.js to start working on your app!</Text>
        <StatusBar style="auto" />
      </View>
      <BannerAd
        unitId={TestIds.BANNER}
        size={BannerAdSize.LARGE_BANNER}
        requestOptions={{
          requestNonPersonalizedAdsOnly:true
        }}
      />
    </SafeAreaView>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: '#fff',
    alignItems: 'center',
    justifyContent: 'center',
  },
});

After running npx expo start --tunnel ,this is the error message :

`A frequent cause of the error is that the application entry file path is incorrect. This can also happen when the JS bundle is corrupt or there is an early initialization error when loading React Native.

eas build --platform android

✔ Using remote Android credentials (Expo server)
✔ Using Keystore from configuration: Build Credentials YmmLiOHo8q (default)

Compressing project files and uploading to EAS Build. Learn more: https://expo.fyi/eas-build-archive
✔ Uploaded to EAS 3s

Build details: https://expo.dev/accounts/anasbouziane/projects/adstest/builds/4e8babe7-b4da-4ccd-8233-af6e4e149bed

Waiting for build to complete. You can press Ctrl+C to exit.
✔ Build finished

🤖 Android app:
https://expo.dev/artifacts/eas/axVukmkyRgwkfSkX.aab

The Expo Go mobile app? Or the development build?

You should create a new development build after installing this.

Yes, that’s unfortunate, but misleading.

That is a production build. Add --profile development to create a development APK