如何使用Android Studio 3.4的Run Anything及新增功能?
Android Studio 3.4: Run Anything & New Feature Guide
Hey there! Let me walk you through using the Run Anything feature and all the other handy new additions in Android Studio 3.4—these tools are designed to speed up your workflow, so let's dive in.
Run Anything: Your Quick Command Hub
Run Anything is like a Swiss Army knife for quick actions—no more digging through menus to find what you need. Here's how to make the most of it:
1. Open Run Anything
- Keyboard Shortcut: On Windows/Linux, hit
Ctrl+Shift+A; on Mac, useCmd+Shift+A. You can also click the search icon (magnifying glass with a small arrow) in the toolbar and type "Run Anything" to launch it. - Even Faster: Double-tap the
Shiftkey to bring up the global search box—this works interchangeably with Run Anything, so you can just start typing your command right away.
2. Common Actions You Can Do
- Run/Debug Your App: Type
runordebug, then pick your target module and device. Hit enter, and you're off—way quicker than clicking the toolbar buttons. - Execute Gradle Commands: Skip the Terminal and type
gradle clean,gradle assembleDebug, or any other Gradle task directly. You'll see the build logs right in the IDE as it runs. - Launch an Emulator: Just type
emulator, select the AVD you want, and it starts up instantly—no need to navigate to the AVD Manager. - Open Tool Windows: Type
Logcat,Terminal, orProfilerto jump straight to those tools. - Git Commands: Do quick version control actions like
git commitorgit pullwithout leaving the IDE.
3. Pro Tips
- As you type, you'll get smart autocompletion—no need to type the full command. Use the arrow keys to pick the right option.
- Type
?in Run Anything to see a full list of all supported commands and actions.
Other New Features in Android Studio 3.4
Beyond Run Anything, there are several upgrades that make development smoother:
1. Improved Layout Editor
- Real-Time Dark Theme Preview: In the Layout Editor toolbar, use the theme switcher to toggle to
Darkmode. You'll see exactly how your layout looks in dark theme without running the app. - Constraint Layout Helpers: The new
Auto-connectfeature adds constraints automatically as you drag controls around. If you have unconstrained views, click theInfer Constraintsbutton to let the IDE fill in the gaps for you.
2. Enhanced App Bundle Support
- New projects now default to generating an Android App Bundle (
.aab) instead of a universal APK. This reduces app size for users since Google Play delivers only the necessary files for their device. - For existing projects, go to
Build -> Generate Signed Bundle/APK, selectAndroid App Bundle, and follow the prompts to create your bundle.
3. Better Performance Profiling
- CPU Profiler Upgrade: The CPU Profiler now offers finer-grained sampling and lets you inspect method call stacks directly in the profiler. Open it via the bottom
Profilertab, select the CPU module, and start sampling to spot bottlenecks. - Memory Leak Detection: In the Memory Profiler, after clicking
Dump Java Heap, the IDE will automatically flag potential memory leaks and highlight suspicious objects—super helpful for tracking down those tricky memory issues.
4. Kotlin Enhancements
- Smarter Autocompletion: The IDE now gives more accurate suggestions for Kotlin lambda expressions, extension functions, and more, making coding faster and less error-prone.
- View Kotlin Bytecode: Right-click any Kotlin code, select
Show Kotlin Bytecode, and you can even clickDecompileto convert it to Java—great for understanding how Kotlin code translates under the hood.
内容的提问来源于stack exchange,提问作者Vivek Hirpara




