facebook twitter hatena line email

Javascript/reactnative/admob/react-native-cli/mediation

提供: 初心者エンジニアの簡易メモ
2020年7月22日 (水) 19:56時点におけるAdmin (トーク | 投稿記録)による版 (Androidの場合)

移動: 案内検索

Admobメディエーションを使う場合

react-native-cliでAdmobメディエーションを使う場合は、androidであれば、build.gradleへ、iosの場合はPodfileへ追加する。

Androidの場合

android/app/build.gradle

dependencies {
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.cardview:cardview:1.0.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation 'androidx.percentlayout:percentlayout:1.0.0'
    implementation 'com.google.android.gms:play-services-basement:17.0.0'
    implementation 'com.google.android.gms:play-services-gcm:17.0.0'
    implementation 'com.google.android.gms:play-services-location:17.0.0'
    implementation 'com.google.android.gms:play-services-ads-identifier:17.0.0'
    implementation 'com.google.ads.mediation:facebook:5.9.0.1'
    implementation 'com.google.ads.mediation:adcolony:4.1.4.1'
    implementation 'com.google.ads.mediation:applovin:9.12.8.0'
    implementation 'com.google.ads.mediation:nend:5.4.2.0'
    implementation 'com.google.ads.mediation:unity:3.4.6.0'
    implementation 'com.google.ads.mediation:maio:1.1.11.1'
    implementation 'com.google.ads.mediation:tapjoy:12.4.2.0'
}

android/build.gradle

allprojects {
    repositories {
        mavenLocal()
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url("$rootDir/../node_modules/react-native/android")
        }
        maven {
            // Android JSC is installed from npm
            url("$rootDir/../node_modules/jsc-android/dist")
        }
        google()
        jcenter()
        maven{
            url "https://imobile-maio.github.io/maven"
        }
        maven {
            url  "https://adcolony.bintray.com/AdColony"
        }
        maven {
            url 'http://fan-adn.github.io/nendSDK-Android-lib/library'
        }

ビルドに失敗、アドネットワークは出てない・・・。

mergeDexが出る場合

ビルド時に以下エラーが出る場合

Execution failed for task ':app:mergeDexDebug'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
   > com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives:
     The number of method references in a .dex file cannot exceed 64K.
     Learn how to resolve this issue at https://developer.android.com/tools/building/multidex.html

以下を追加

android/app/build.gradle

implementation 'androidx.multidex:multidex:2.0.1'

android/app/build.gradle

defaultConfig {
    multiDexEnabled true
}

INSTALL_FAILED_INSUFFICIENT_STORAGEが出る場合

以下エラーが出る場合

com.android.builder.testing.api.DeviceException: com.android.ddmlib.InstallException: INSTALL_FAILED_INSUFFICIENT_STORAGE

端末の容量がいっぱいなので削除すれば良い。

一部adnwで以下エラー出た

インステで以下エラーがでたが、リワードでは2つとも広告が出たので、たまたまかも・・

E AppLovinAdapter: Failed to load interstitial ad from AppLovin: 109: AppLovin requires an Activity context to load ads.
W MaioMediationAdapter: Failed to request ad from Maio: Maio SDK requires an Activity context to load ads.
E UnityMediationAdapter: Failed to load ad: 105: Unity Ads requires an Activity context to load ads.

iOSの場合

以下を追加してpod更新する

ios/Podfile

target 'AdMobMediationDemo' do
  pod 'Google-Mobile-Ads-SDK', '~> 7.41'
  pod 'GoogleMobileAdsMediationUnity', '~> 3.4.6.0'
  pod 'GoogleMobileAdsMediationAdColony', '~> 4.1.5.0'
  pod 'GoogleMobileAdsMediationMaio', '~> 1.5.4.0'
  pod 'GoogleMobileAdsMediationNend', '~> 5.4.1.0'
  pod 'GoogleMobileAdsMediationFacebook', '~> 5.9.0.1'
  pod 'GoogleMobileAdsMediationAppLovin', '~> 6.9.5.0'
  pod 'GoogleMobileAdsMediationTapjoy', '~> 12.4.2.2'
end

更新処理

$ pod update

アドネットワークは出た。