開發 Android Go 應用程式的最佳做法
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
剛開始開發 Android Go 應用程式或進行相關最佳化作業時,可以參考本文提供的最佳做法和常見問題解答。
針對 Go 進行最佳化調整或開發全新應用程式
很多打算在 Android Go 推出應用程式的開發人員可能都想知道,到底應該針對現有應用程式進行最佳化調整,還是開發全新應用程式?這個問題的答案取決於許多因素,包括您擁有多少開發資源、是否可以保留應用程式中針對 Go 裝置進行最佳化調整的功能,以及您想在何種情況下向世界各地的使用者發行應用程式。
- 提供一個通用應用程式
- 向 Android Go 裝置和所有其他裝置發布同一個應用程式,並提供一致的使用體驗。在此情況下,您需要針對現有應用程式進行最佳化調整,確保應用程式能在任何裝置上順暢運作。此外,這些最佳化作業也能讓現有使用者享有效能優勢。強烈建議您使用 Android App Bundle,這種檔案格式可以大幅縮減應用程式大小,而且不必重構程式碼。
- 提供兩個應用程式
- 建構專為 Android Go 裝置設計的全新「輕量化」應用程式。如此一來,您就能將現有應用程式保持原樣。由於我們並未規定「輕量化」應用程式只能專供 Android Go 裝置使用,因此這類應用程式可以提供給世界各地的所有裝置。
這個頁面中的內容和程式碼範例均受《內容授權》中的授權所規範。Java 與 OpenJDK 是 Oracle 和/或其關係企業的商標或註冊商標。
上次更新時間:2025-07-27 (世界標準時間)。
[null,null,["上次更新時間:2025-07-27 (世界標準時間)。"],[],[],null,["# Best practices for Android (Go edition) development\n\nFollow these best practices and answers to common questions when starting to\ndevelop or optimize your app for Android (Go edition).\n\n- Don't add any excessive permissions to your app.\n- Minimize app activity when in the background and when the device is running on low power.\n- Avoid using wake locks because they prevent the device from going into low-power states.\n- Batch network activity to reduce the number of wakeups. You can use [WorkManager](/topic/libraries/architecture/workmanager) to schedule tasks and let the system batch operations.\n- Validate that your layouts scale down by testing on smaller screens.\n- Methods such as [`isLowRamDevice()`](/reference/android/app/ActivityManager#isLowRamDevice()) and [`getMemoryClass()`](/reference/android/app/ActivityManager#getMemoryClass()) help determine memory constraints at runtime. Using this information, you can scale down your memory use. For example, you can use lower resolution images on low memory devices.\n- Allow your app to be installed to external storage using the [`android:installLocation`](/guide/topics/manifest/manifest-element#install) flag in your `AndroidManifest.xml` file.\n- If you're looking to build for a larger-scaled audience, take a look at the [Build for billions](/topic/billions) documentation.\n\nOptimize for Go or start fresh\n------------------------------\n\nMany developers looking to launch apps on Android Go may wonder if they should\noptimize their existing app or develop an entirely new one. This choice depends\non many factors, including how many development resources you have, whether or\nnot you can keep features in your app that are optimized for these devices,\nand what type of distribution scenarios you want to enable for end-users around\nthe world.\n\nOne app for all\n: Use the same app for Android (Go edition) devices and all other devices with\n an identical experience. In this case, you are optimizing your existing app to\n run well on these devices, and your existing users gain performance benefits\n from those optimizations. We highly encourage you to use the\n [Android App Bundle](/guide/app-bundle) to experience significant size savings\n without having to refactor your code.\n\nTwo apps\n: Create a new \"light\" app and target Android (Go edition) devices.\n You can leave your existing app as is. The \"lite\" app can still target all\n devices in all locales as there is no requirement for this \"lite\" app to only\n target Android (Go edition) devices."]]