You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Android Studio运行App遇transformClassesWithInstantRunForDebug报错求助

Fixing transformClassesWithInstantRunForDebug java.lang.VerifyError

Hey, I see you're hitting this tricky VerifyError tied to Instant Run—this is a super common issue in Android projects with multi-dex setups or complex dependency trees. Let's walk through some proven solutions you can try one by one:

1. Disable Instant Run First

Instant Run's hot-swap mechanism often messes up bytecode verification, especially in multi-dex projects. Here's how to turn it off:

  • Go to File > Settings (on Mac, Android Studio > Preferences)
  • Navigate to Build, Execution, Deployment > Instant Run
  • Uncheck the box for Enable Instant Run to hot swap code/resource changes on deploy, then restart Android Studio and rebuild your project.

2. Clean & Rebuild Your Project

Corrupted build cache is a frequent culprit here. Try these steps:

  • Click Build > Clean Project from the toolbar
  • Then run Build > Rebuild Project
  • If that doesn't work, manually delete the .gradle folder in your project root, plus the build folders in both your project root and app module. Then sync Gradle again.

3. Fix Dependency Conflicts & Bloat

Looking at your app-level build.gradle, there are a couple of red flags:

  • Full Play Services Dependency: You're including compile 'com.google.android.gms:play-services:11.6.2'—this is the bloated full package that includes every Google service module. Since you already have specific modules like play-services-auth and play-services-gcm, delete this full dependency to avoid conflicts and reduce app size.
  • Align Support Library Versions: Your compileSdkVersion is 26, buildToolsVersion is 26.0.2, but you're using Support Library version 26.0.0. Let's align them to 26.1.0 (a more stable match for your build tools):
    Update your resolution strategy block:
    configurations.all {
        resolutionStrategy.eachDependency { DependencyResolveDetails details ->
            def requested = details.requested
            if (requested.group == 'com.android.support') {
                if (!requested.name.startsWith("multidex")) {
                    details.useVersion '26.1.0'
                }
            }
        }
    }
    
    Also update all your manually declared Support Library dependencies (like design, support-v4) to use 26.1.0.

4. Properly Configure MultiDex

You've enabled multiDexEnabled true, but if your app doesn't properly initialize MultiDex, it can cause verification errors:

  • If you have a custom Application class, have it extend MultiDexApplication:
    public class MyApp extends MultiDexApplication {
        // Your existing code here
    }
    
  • Or if you can't extend MultiDexApplication, add this to your custom Application's attachBaseContext method:
    @Override
    protected void attachBaseContext(Context base) {
        super.attachBaseContext(base);
        MultiDex.install(this);
    }
    
  • Make sure your AndroidManifest.xml references this custom Application class.

5. Check Gradle Plugin & Google Services Compatibility

Your project uses com.android.tools.build:gradle:3.0.0 and com.google.gms:google-services:3.0.0—this combo is compatible, but if none of the above works, try upgrading to more recent stable versions. For example:

  • Update gradle plugin to 3.2.1
  • Update google-services to 4.0.1
  • Don't forget to update your gradle wrapper's distribution URL to match the plugin version (e.g., distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip for plugin 3.2.1)

内容的提问来源于stack exchange,提问作者Manoj Goswami

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.15 04:25:36