Android Studio 3.1运行指令不重建APK问题求助
Hey there, I totally get how frustrating this is—having to manually hit "rebuild & run" every time after a code change is such a workflow killer. I dealt with this exact issue when I upgraded to AS 3.1, so here are some fixes that worked for me and other developers:
Invalidate Caches & Restart
This is the classic fix for wonky IDE behavior. Navigate toFile > Invalidate Caches..., tick all the cache options, then click "Invalidate and Restart". This clears out any corrupted cached build data that might be blocking the auto-rebuild.Verify Gradle & Plugin Settings
Double-check your build configuration to make sure nothing got messed up during the upgrade:- Open your project’s
gradle.propertiesfile and confirmandroid.enableBuildCache=trueis present (it’s enabled by default in AS 3.1, but sometimes gets reset) - Ensure your module-level
build.gradleuses the compatible Gradle plugin version:com.android.tools.build:gradle:3.1.0(or the latest patch for 3.1.x)
- Open your project’s
Turn Off Instant Run
Instant Run can clash with the new build system after upgrades. Go toFile > Settings > Build, Execution, Deployment > Instant Runand uncheck the box for "Enable Instant Run to hot swap code/resource changes on deploy". Restart AS and try running your app again—this often fixes the auto-rebuild issue.Do a Full Clean + Rebuild
Even though you’re doing this manually now, a one-time full clean might reset the build state:- Run
Build > Clean Project - Follow it with
Build > Rebuild Project - Try running the app normally afterward—this sometimes jumpstarts the auto-rebuild process again.
- Run
Check Device Deployment Settings
Sometimes the error isn’t about building the APK, but installing it:- Make sure your device has USB debugging enabled and is properly detected by AS
- Confirm there’s enough storage space on the device for the APK
- On physical devices, ensure "Install unknown apps" is allowed for your computer’s connection
内容的提问来源于stack exchange,提问作者Marcos DaSilva

