קל לארגן דפים בעזרת אוספים
אפשר לשמור ולסווג תוכן על סמך ההעדפות שלך.
מצב הסוכן של Gemini ב-Android Studio נועד לטפל במשימות פיתוח מורכבות ורב-שלביות, שהן מעבר למה שאפשר לעשות באמצעות צ'אט עם Gemini. אתם יכולים לתאר מטרה כללית, והסוכן יוצר תוכנית ומבצע אותה, מפעיל את הכלים הנדרשים, מבצע שינויים בכמה קבצים ומתקן באגים באופן איטרטיבי. תהליך העבודה הזה עם סיוע של נציג מאפשר לכם להתמודד עם אתגרים מורכבים ולזרז את תהליך הפיתוח.
איור 1: Gemini במצב סוכן ב-Android Studio.
שנתחיל?
כדי להתחיל להשתמש במצב סוכן ב-Android Studio, פועלים לפי השלבים הבאים:
בסרגל הכלים של חלון Gemini, לוחצים על Gemini. אם צריך, נכנסים לחשבון ומצטרפים ל-Google Workspace.
בוחרים בכרטיסייה סוכן.
מתארים את המשימה שרוצים שהסוכן יבצע.
בודקים ומאשרים את השינויים בזמן שהסוכן מבצע את המשימה.
איור 2: במצב סוכן, המערכת מחכה שתאשרו או תדחו שינוי.
אופציונלי: כדי לאשר שינויים באופן אוטומטי, בוחרים באפשרות אפשרויות של סוכן
> אישור אוטומטי של שינויים.
איור 3: אישור אוטומטי של שינויים שהסוכן מציע.
תרחישים לדוגמה
הנה כמה דוגמאות לתרחישי שימוש שבהם הסוכן יכול לעזור לכם:
תיקון שגיאות בבנייה כשמבקשים מהסוכן לתקן שגיאת בנייה באמצעות הנחיה כמו 'תקן שגיאות בנייה בפרויקט שלי', הוא מחיל תיקון מומלץ, בונה את הפרויקט כדי לאמת את הפתרון וחוזר על הפעולה עד שהבעיה נפתרת.
איור 4: הסוכן בונה את הפרויקט ומעריך אם יש שגיאות.
הוספה או עדכון של רכיבים בממשק המשתמש. הסוכן יכול להוסיף או לעדכן רכיבי ממשק משתמש.
לדוגמה, אפשר לבקש מהסוכן "להגדיר את העיצוב הכהה כברירת המחדל בהעדפות המשתמש". הסוכן יחפש את הקבצים הרלוונטיים ויציע שינויים כדי לבצע את המשימה. אפשר לראות תצוגה מקדימה של עדכוני ממשק המשתמש באופן מיידי בחלון הכלים Running devices.
איור 5: הסוכן מעדכן את רכיבי ממשק המשתמש.
יוצרים נתוני דמה. כשיוצרים אב טיפוס של האפליקציה ובודקים אותה, אפשר לבקש מהסוכן ליצור נתונים לדוגמה במקום ליצור אותם ידנית. לדוגמה, אם תתבקשו להוסיף עוד שתי סשנים לנתונים המזויפים, הסוכן ימצא את הקובץ הרלוונטי ויוסיף עוד שני אירועים לרשימה mockSessions.
איור 6: הסוכן יוצר נתונים לדוגמה.
הנחיות נוספות שאפשר לנסות:
"Write unit tests for <class> in <module>" (כתיבת בדיקות יחידה עבור <class> ב-<module>)
"Generate documentation for the open file" (יצירת תיעוד לקובץ הפתוח)
"Change the app title from <current name> to <new name>" (שינוי שם האפליקציה מהשם <current name> לשם <new name>)
"Resolve the null pointer exception" (פתרון חריגת מצביע null)
"Refactor my code by moving the <composable name> composable to a new
file. מוודאים שכל הייבוא עודכן"
"תוסיף לחצן חדש למסך הבית של האפליקציה בשם 'מעקב' שיעביר אותי לרשימת נושאים"
"In the <composable name> composable, reduce the padding of the
<modifier name> modifier"
"Create a share button to share to social media" (יצירת לחצן שיתוף לשיתוף ברשתות חברתיות)
איך הסוכן פועל
במצב סוכן, ההנחיה שלכם נשלחת ל-Gemini API עם רשימה של כלים שזמינים. אפשר לחשוב על כלים כעל כישורים: הם כוללים את היכולת לחפש קבצים, לקרוא קבצים, לחפש טקסט בתוך קבצים, להשתמש בכל שרתי MCP שהגדרתם ועוד.
כשנותנים לסוכן משימה, הוא יוצר תוכנית וקובע אילו כלים נדרשים. יכול להיות שתצטרכו לתת הרשאה לחלק מהכלים האלה לפני שהסוכן יוכל להשתמש בהם. אחרי שתתנו הרשאה, הסוכן ישתמש בכלי כדי לבצע את הפעולה הנדרשת וישלח את התוצאה בחזרה אל Gemini API. Gemini מעבד את תוצאת הפעולה ויוצר תשובה נוספת. המחזור הזה של פעולה והערכה נמשך עד שהמשימה מסתיימת.
דוגמאות התוכן והקוד שבדף הזה כפופות לרישיונות המפורטים בקטע רישיון לתוכן. Java ו-OpenJDK הם סימנים מסחריים או סימנים מסחריים רשומים של חברת Oracle ו/או של השותפים העצמאיים שלה.
עדכון אחרון: 2025-09-03 (שעון UTC).
[[["התוכן קל להבנה","easyToUnderstand","thumb-up"],["התוכן עזר לי לפתור בעיה","solvedMyProblem","thumb-up"],["סיבה אחרת","otherUp","thumb-up"]],[["חסרים לי מידע או פרטים","missingTheInformationINeed","thumb-down"],["התוכן מורכב מדי או עם יותר מדי שלבים","tooComplicatedTooManySteps","thumb-down"],["התוכן לא עדכני","outOfDate","thumb-down"],["בעיה בתרגום","translationIssue","thumb-down"],["בעיה בדוגמאות/בקוד","samplesCodeIssue","thumb-down"],["סיבה אחרת","otherDown","thumb-down"]],["עדכון אחרון: 2025-09-03 (שעון UTC)."],[],[],null,["Gemini in Android Studio's Agent Mode is designed to handle complex, multi-stage\ndevelopment tasks that go beyond what you can experience by just chatting with\nGemini. You can describe a high-level goal, and the agent creates and\nexecutes a plan, invoking the necessary [tools](#how-it-works), making changes\nacross multiple files, and iteratively fixing bugs. This agent-assisted workflow\nlets you tackle intricate challenges, accelerating your development\nprocess.\n**Figure 1:** Gemini in Android Studio's Agent Mode.\n\nGet started\n\nTo get started in Agent Mode in Android Studio, follow these steps:\n\n1. Click **Gemini** in the tool window bar. Sign in and onboard if you need to.\n2. Select the **Agent** tab.\n3. Describe the task you want the agent to perform.\n4. Review and approve any changes as the agent works to accomplish the task.\n\n**Figure 2:** Agent Mode waits for you to accept or reject a change.\n\n1. Optional: To automatically approve changes, select **Agent options\n \\\u003e Auto-approve changes**.\n\n**Figure 3:** Auto-approve changes suggested by the agent.\n\nUse cases\n\nHere are some examples of use cases that the agent can help you with:\n\n- **Fix build errors.** When you ask the agent to fix a build error using a prompt like \"Fix build errors in my project,\" it applies a recommended fix, builds the project to verify the solution, and iterates until the issue is resolved.\n\n**Figure 4:** The agent builds your project and assesses if there are errors.\n\n- **Add or update UI elements.** The agent can add or update UI elements. For example, ask the agent to \"Make dark theme the default in user preferences\" and it searches for the relevant files and suggests changes to accomplish the task. You can immediately preview the UI updates in the **Running devices** tool window.\n\n**Figure 5:** The agent updating UI elements.\n\n- **Generate mock data.** When prototyping and testing your app, you can ask the agent to generate mock data instead of manually creating it. For example, when prompted to \"Add two more sessions to the fake data,\" the agent finds the relevant file and adds two more events to the `mockSessions` list.\n\n**Figure 6:** The agent generating mock data.\n\nSome other prompts to try:\n\n- \"Write unit tests for \\\u003cclass\\\u003e in \\\u003cmodule\\\u003e\"\n- \"Generate documentation for the open file\"\n- \"Change the app title from \\\u003ccurrent name\\\u003e to \\\u003cnew name\\\u003e\"\n- \"Resolve the null pointer exception\"\n- \"Refactor my code by moving the \\\u003ccomposable name\\\u003e composable to a new file. Verify that all imports are updated\"\n- \"Add a new button to the app's home screen called 'Follow' that takes you to a list of topics\"\n- \"In the \\\u003ccomposable name\\\u003e composable, reduce the padding of the \\\u003cmodifier name\\\u003e modifier\"\n- \"Create a share button to share to social media\"\n\nHow the agent works\n\nIn Agent Mode, your prompt is sent to the Gemini API with a list of *tools* that\nare available. You can think of tools as skills: they include the ability to\nsearch for files, read files, search the text within files, use any\n[MCP servers](/studio/gemini/add-mcp-server) you have configured, and more.\n\nWhen you give the agent a task, it creates a plan and determines which\ntools are needed. Some of these tools might need you to grant permission before\nthe agent can use them. Once you grant permission, the agent uses the tool to\nperform the necessary action and sends the result back to the Gemini API. Gemini\nprocesses the result of the action and generates another response. This cycle of\naction and evaluation continues until the task is complete."]]