yandexmobile/yandex-ads-sdk-android/migrate-yandex-ads-sdk-from-7-to-8
Claude Code and agent skill by yandexmobile/yandex-ads-sdk-android
- community
Checking that the SKILL.md file is still in the repository.
Install
npx vskill@latest install yandexmobile/yandex-ads-sdk-android/migrate-yandex-ads-sdk-from-7-to-8SKILL.md
AI Migration Agent Instructions for the Yandex Mobile Ads SDK
Efficient Migration Strategy
General StrReplace Rules
To avoid tool errors when modifying files:
- Include surrounding context: Add 1-2 lines before/after for unique matching.
- Match exact whitespace: Preserve all indentation, spaces, newlines exactly.
- One logical change per operation: Don't combine multiple unrelated edits.
- Use unique anchors: Include unique variable/method names or comments.
- Verify uniqueness: Ensure pattern matches only ONE location in file.
- Mark manual changes: Whenever you add new code, layouts, or modify logic during the migration, ALWAYS add a comment
// FIXME_SDK8: Auto-generated during migration, please review.(or<!-- FIXME_SDK8: Auto-generated during migration, please review. -->in XML) to indicate that this code was auto-generated and requires manual review.
Migration Sequence:
STEP 0: Update Yandex Ads SDK dependencies
Use latest available versions in repositories :
- Core SDK: https://repo.maven.apache.org/maven2/com/yandex/android/mobileads/
- Mediation bundle: https://repo.maven.apache.org/maven2/com/yandex/android/mobileads-mediation/
- Mediation adapters: https://repo.maven.apache.org/maven2/com/yandex/ads/mediation/
STEP 1: Identify Application Package (MANDATORY - CANNOT SKIP)
Read the app module's Gradle build script and find the namespace value (e.g., "com.yandex.ads.sample").
The build script may use either Gradle DSL — do NOT assume .kts:
- Kotlin DSL:
app/build.gradle.kts—namespace = "com.yandex.ads.sample" - Groovy DSL:
app/build.gradle—namespace "com.yandex.ads.sample"ornamespace = "com.yandex.ads.sample"
Many projects (including Capacitor / hybrid wrappers) use the Groovy build.gradle. Check which file actually exists in the app module before reading it.
If namespace is absent (older AGP), fall back to the applicationId in the same file or the package attribute in app/src/main/AndroidManifest.xml.
CRITICAL: Any import starting with this namespace is application code, NOT SDK code. NEVER replace imports that start with the application namespace.
STEP 2: Bulk Import Replacement
Replace SDK imports ONE BY ONE using bulk find-and-replace (e.g., one command per import). Only process lines that do NOT start with application namespace.
How to replace imports:
- Extract the old and new package/class paths from the Complete Package Structure (SDK 8) and Class Mapping tables below.
- Replace imports ONE AT A TIME with surrounding context.
- Include a blank line or the next import for context to ensure uniqueness.
- Never replace multiple imports in one operation or combine with code changes.
Use IDE's "Replace in Path" feature or command-line tools (sed, PowerShell, etc.)
STEP 3: Bulk Simple API & Removed Classes Replacement
Replace simple class/method names ONE BY ONE using bulk find-and-replace (e.g., one command per API):
How to replace APIs/Classes:
- Replace ONE method call or class name at a time.
- Include surrounding code (variable declaration, next line, type declaration, assignment) for context.
- Preserve original variable names.
Replace patterns:
MobileAds.initialize→YandexAds.initializeAdRequestConfiguration.Builder→AdRequest.BuilderClosableBannerAdEventListener→BannerAdEventListenerMobileInstream→YandexInstreamAdsBannerAdSize.stickySize→BannerAdSize.stickyBannerAdSize.inlineSize→BannerAdSize.inline
Use IDE's "Replace in Path" feature or command-line tools (sed, PowerShell, etc.)
Optional: If possible, perform STEP 2 and STEP 3 in parallel in one response (both commands are independent). If not, perform sequentially.
Do not start the build.
STEP 4: Replace Native Templates
NativeBannerView (with NativeTemplateAppearance) was a ready-made template removed in SDK 8. The SDK now requires a custom native ad view: NativeAdView as the root container + NativeAdViewBinder to bind assets to child views.
Ready-to-use replacement: The Yandex Mobile Ads public sample (YandexMobileAdsExample) provides a complete drop-in implementation. Read the following files from the sample and create them in the partner's project, replacing the sample package com.yandex.ads.sample with the app namespace from STEP 1:
app/src/main/java/com/yandex/ads/sample/nativeads/NativeAdBannerView.kt— a customFrameLayoutthat wires up all native ad asset views viaNativeAdViewBinderapp/src/main/java/com/yandex/ads/sample/common/RatingView.kt— aRatingBarthat implements the SDK'sRatinginterface; place it alongsideNativeAdBannerView.ktand update its packageapp/src/main/res/layout/native_banner_ad_view.xml— the full XML layout; update theRatingViewclass reference to match the new package
Add //FIXME(SDK8): Auto-generated during migration, please review. to the top of each copied Kotlin file.
Migration Actions:
- Extract customizations first: Search for
NativeTemplateAppearance,ButtonAppearance,TextAppearance,ImageAppearance,RatingAppearance,SizeConstraintusages andapp:appearancein XML. Note the values — you will apply them to the new layout in step 3. - Delete old appearance builder code: Remove all usages of the builders listed above after extracting the values.
- Apply customizations to `native_banner_ad_view.xml`: For each value extracted in step 1, set the equivalent XML attribute on the corresponding view. If
app:appearance="@style/..."was used, open that style to extract values first.
| Old customization | View @id | XML attribute | |
|---|---|---|---|
withTitleAppearance → withTextColor / withTextSize | title | android:textColor / android:textSize | |
withBodyAppearance → withTextColor / withTextSize | body | android:textColor / android:textSize | |
withCallToActionAppearance → withTextColor / withNormalColor / withTextSize | call_to_action | android:textColor / android:backgroundTint / android:textSize | |
withIconAppearance → withWidth / withHeight | icon | android:layout_width / android:layout_height | |
withRatingAppearance → withStarColor | rating | android:progressTint | |
withDomainAppearance → withTextColor / withTextSize | domain | android:textColor / android:textSize | |
withSponsoredAppearance → withTextColor | sponsored | android:textColor | |
withWarningAppearance → withTextColor | warning | android:textColor | |
SizeConstraint on root | native_ad_container | android:layout_width / android:minHeight |
- Replace `NativeBannerView` in XML with
NativeAdBannerView(using the partner's app package). Remove theapp:appearanceattribute. Keepandroid:idand all layout parameters. - Update Kotlin/Java code:
- Replace
nativeBannerView.setAd(nativeAd)→nativeBannerView.bindNativeAd(nativeAd) - Add
nativeBannerView.release()before each new load and inonDestroy()
Do not start the build.
STEP 5: First Build to Identify Complex Cases
Explain to user: build needed to identify complex migration cases.
Only after completing STEP 1-4, start the fast compilation check:
Important: This is the first build run before iterative fixes.
STEP 6: Iterative Fixes & Builder Patterns (apply_diff)
For each compilation error:
- Read the error from the build log (do not restart the build)
- Verify that the error is related to Yandex Mobile Ads SDK classes. Do NOT attempt to fix unrelated application errors.
- Use
apply_diffto fix it. - Fix ALL SDK-related errors from the build log, then rebuild once to verify.
Optional: If fixes are in different files and don't depend on each other, you can perform multiple apply_diff operations in parallel in one response. Important: Do not rebuild after every 5-10 fixes. Fix all SDK-related errors from the current build log, then rebuild once.
Complex cases (require apply_diff):
- Listener refactoring:
- Remove
setAdLoadListener()call (with context). - Update
loadAd()to include listener parameter (with context). - Remove interface implementation from class declaration (if needed).
- Convert listener to lambda/object (separate operation).
- AdRequest.Builder with adUnitId parameter:
- Old:
AdRequestConfiguration.Builder().setParameters(...).build() - New:
AdRequest.Builder(adUnitId).setParameters(...).build() - Extract
adUnitIdfromsetAdUnitId()call or banner setup. RemovesetAdUnitId()call after migration. - AdTargeting extraction:
- Old:
AdRequest.Builder().setAge(25).setGender(Gender.MALE) - New:
AdRequest.Builder(id).setTargeting(AdTargeting.Builder().setAge(25).setGender(Gender.MALE).build()) - Move
.setAge(),.setGender(),.setLocation()toAdTargeting.Builder(). - Result.Success/Failure handling.
STEP 7 : Verify success build and fix issues
Iterate assemble application until success build, fix found issues between builds.
(Optional) Check if the user's project uses this specific mediation adapters (mobileads-google, mobileads-mytarget, mobileads-extras):
- minSdk — Only required if the user includes specific mediation adapters, and the required level differs per adapter.
mobileads-googlerequiresminSdk 24starting with Yandex Mobile Ads SDK 8.4.0, where it moved to the GMA Next-Gen SDK (it was 23 before).mobileads-extrasbundles third-party SDKs that already requireminSdk 24.mobileads-mytargetrequiresminSdk 23. If they use these adapters andminSdkis lower, warn them that a manifest merger failure will occur and suggest raising it accordingly. Do not force this if they don't use these adapters. - Kotlin 2.1.0+ — Recommended if transitive dependencies ship Kotlin 2.1 metadata (which causes errors with 1.8 compilers). If the user upgrades Kotlin to 2.0+
- Compose, if Kotlin 2.1 is updated , ensure they use the
plugin.composecompiler plugin instead of the oldcomposeOptions { kotlinCompilerExtensionVersion = ... }.
Do not automatically edit these Gradle settings unless the user explicitly agrees or encounters a build error related to them.
Tool Usage Rules:
| Task | Tool | Rationale | |
|---|---|---|---|
| Import replacement | execute_command (sed) | Processes all files in 1 sec | |
| Simple API replacement | execute_command (sed) | Safe for simple patterns | |
| Complex refactoring | apply_diff | Requires context and precision | |
| Project build | execute_command (gradlew compileDebugSources) | Only after bulk replacements |
Recommended Approach (speeds up work):
- Use
sedfor bulk replacements (imports, simple APIs), but apply them ONE BY ONE (one pattern per command). - Group changes: first process imports (one by one), then simple APIs (one by one).
- Start the compilation check only after bulk replacements
- Use
apply_diffonly for complex cases - Read the build log once, fix several errors, then re-run compilation check
Migrate to Yandex Ads SDK 8
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingYandexMobileAdsExample/skills/migrate-yandex-ads-sdk-from-7-to-8/SKILL.md
Popularity
- Repository stars
- 95
- Repository forks
- 23
- 7-day trend score
- 23
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/yandexmobile/yandex-ads-sdk-android/migrate-yandex-ads-sdk-from-7-to-8)