Yandex Mobile Ads в Ren'Py игре
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # добавить в конец файла | |
| android.useAndroidX=true | |
| android.enableJetifier=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // убрать данный импорт | |
| import android.support.annotation.NonNull; | |
| // удалить упоминания NonNull | |
| @NonNull |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| android{ | |
| ... | |
| compileOptions { | |
| sourceCompatibility JavaVersion.VERSION_1_8 | |
| targetCompatibility JavaVersion.VERSION_1_8 | |
| } | |
| ... | |
| } | |
| dependencies { | |
| ... | |
| // https://github.com/yandexmobile/yandex-ads-sdk-android/issues/126 | |
| implementation 'androidx.core:core-ktx:1.6.0' | |
| implementation ('com.yandex.android:mobileads:5.2.0') { | |
| exclude group: 'androidx.core', module: 'core' | |
| exclude group: 'androidx.core', module: 'core-ktx' | |
| } | |
| ... | |
| } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // секция импорта | |
| ... | |
| import com.yandex.mobile.ads.banner.AdSize; | |
| import com.yandex.mobile.ads.banner.BannerAdEventListener; | |
| import com.yandex.mobile.ads.banner.BannerAdView; | |
| import com.yandex.mobile.ads.common.AdRequest; | |
| import com.yandex.mobile.ads.common.AdRequestError; | |
| import com.yandex.mobile.ads.common.ImpressionData; | |
| import com.yandex.mobile.ads.common.MobileAds; | |
| ... | |
| // тело класса | |
| private static final String YANDEX_TAG = "YANDEX_ADDS_RENPY"; | |
| private static final String ADD_ID = "R-M-DEMO-320x50"; | |
| protected void onCreate(Bundle savedInstanceState) { | |
| ... | |
| MobileAds.initialize(this, () -> { | |
| Log.v(YANDEX_TAG, "Adds initialized"); | |
| }); | |
| BannerAdView adView = new BannerAdView(this); | |
| { | |
| RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams( | |
| RelativeLayout.LayoutParams.WRAP_CONTENT, | |
| RelativeLayout.LayoutParams.WRAP_CONTENT | |
| ); | |
| layoutParams.addRule(RelativeLayout.CENTER_HORIZONTAL); | |
| adView.setLayoutParams(layoutParams); | |
| } | |
| adView.setAdSize(AdSize.stickySize(-1)); | |
| adView.setAdUnitId(ADD_ID); | |
| adView.setBannerAdEventListener(new BannerAdEventListener() { | |
| @Override | |
| public void onAdLoaded() { | |
| Log.v(YANDEX_TAG, "Add view load success"); | |
| } | |
| @Override | |
| public void onAdFailedToLoad(AdRequestError adRequestError) { | |
| Log.e(YANDEX_TAG, "Add view load error: "+adRequestError.getDescription()); | |
| } | |
| @Override | |
| public void onAdClicked() { | |
| } | |
| @Override | |
| public void onLeftApplication() { | |
| } | |
| @Override | |
| public void onReturnedToApplication() { | |
| } | |
| @Override | |
| public void onImpression(ImpressionData impressionData) { | |
| } | |
| }); | |
| AdRequest adRequest = new AdRequest.Builder() | |
| .build(); | |
| adView.loadAd(adRequest); | |
| mLayout.addView(adView); | |
| } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| android { | |
| defaultConfig { | |
| ... | |
| multiDexEnabled true | |
| ... | |
| } | |
| ... | |
| compileOptions { | |
| sourceCompatibility JavaVersion.VERSION_1_8 | |
| targetCompatibility JavaVersion.VERSION_1_8 | |
| } | |
| ... | |
| } | |
| dependencies { | |
| ... | |
| implementation 'com.android.support:multidex:1.0.3' | |
| .... | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment