Android Studio运行App遇transformClassesWithInstantRunForDebug报错求助
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 Projectfrom the toolbar - Then run
Build > Rebuild Project - If that doesn't work, manually delete the
.gradlefolder in your project root, plus thebuildfolders 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 likeplay-services-authandplay-services-gcm, delete this full dependency to avoid conflicts and reduce app size. - Align Support Library Versions: Your
compileSdkVersionis 26,buildToolsVersionis 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:
Also update all your manually declared Support Library dependencies (likeconfigurations.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' } } } }design,support-v4) to use26.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'sattachBaseContextmethod:@Override protected void attachBaseContext(Context base) { super.attachBaseContext(base); MultiDex.install(this); } - Make sure your
AndroidManifest.xmlreferences 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.zipfor plugin 3.2.1)
内容的提问来源于stack exchange,提问作者Manoj Goswami

