简体   繁体   中英

react native; I'm adding admob code but it doesn't work

Errors:

Task :react-native-admob:compileDebugJavaWithJavac FAILED

Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'

The specified Android SDK Build Tools version (23.0.1) is ignored, as it is below the minimum supported version (28.0.3) for Android Gradle Plugin 3.4.1. Android SDK Build Tools 28.0.3 will be used

This errors I it fixes these errors, but gives the same error

import React, { Component } from "react";
import { View, Text } from "react-native";
import { AdMobBanner } from "react-native-admob";
class App extends Component {
  render() {
    return (
      <View>
        <Text>Alperr</Text>
        <AdMobBanner
          bannerSize="fullBanner"
          adUnitID="ca-app-pub-3940256099942544/6300978111"
          testDeviceID="EMULATOR"
          didFailToReceiveAdWithError={this.bannerError}
        />
      </View>
    );
  }
}
export default App;

this example source code

The error is pretyt self explanatory. You are most likely using a very new version of RN and gradle which forces the dependencies to use the new way of compiling dependencies which is:

implementation(<project>)

instead of...

compile(<project>)

The way to fix this is either checking if admob has a mre update version that uses implementation in the app/buikd.gradle or use an older version of gradlew.

Manual thing you could do as a workaround is going into node_modules/react-native-admob, finding the build.gradle and updating the compile to implementation.

Also, this applies to your local project in app/build.gradle.

If you are doing compile('react-native-admob') just replace compile with implementation.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM