Copy and rename an Android project in Android Studio
วิธีสำเนา Android Application Source Code ไปเป็น Application ใหม่ ลองทำตามขั้นตอนดังนี้
Copy and rename a project
For some lessons, you will need to make a copy of a project before making new changes. You may also want to copy a project to use some of its code in a new project. In either case you can copy the existing project (ExistingProject), and then rename and refactor the new project's (NewProject) components to use the new project's name. (In the instructions below, substitute your actual project names for ExistingProject and NewProject.
1. Copy the project
- On your computer's file system (not in Android Studio), make a copy of the ExistingProject directory.
- Rename the copied directory to NewProject .
2. Rename and refactor the project components
The old name of the project, ExistingProject, still appears throughout the packages and files in the new copy of your project. Change the file and the package references in your app to the new name, as follows:
- Start Android Studio
- Click Open an existing Android Studio project.
- Navigate to the NewProject directory, select it, and click OK.
- Select Build > Clean Project to remove the auto-generated files.
- Click the 1:Project side-tab and choose Android from the drop-down menu to see your files in the Project view.
- Expand app > java.
- Right-click com.example.android.existingproject and choose Refactor > Rename. This opens the Rename dialog.
- Change existingproject to newproject.
- Check Search in comments and strings and Search for text occurrences and click Refactor.
- The Find Refactoring Preview pane appears, showing the code to be refactored.
- Click Do Refactor. (ปุ่ม Do Refactor อยู่ที่แถบด้านล่าง มองหาตั้งนาน เพิ่งเจอ)
- Expand res > values and double-click the strings.xml file.
- Change the name="app_name" string to New Project.
3. Update the build.gradle and AndroidManifest.xml files
Each app you create must have a unique application ID, as defined in the app's build.gradle file. Even though the above steps should have changed the build.gradle file, you should check it to make sure, and also sync the project with the gradle file:
- Expand Gradle Scripts and double-click build.gradle (Module: app).
- Under defaultConfig, check to make sure that the value of the applicationID key has been changed to "com.example.android.newproject". If it has not changed, change it manuall now.
- Click Sync Now in the top right corner of the Android Studio window.
Tip: You can also choose Tools > Android > Sync Project with Gradle File to sync your gradle files.
In addition, some apps include the app name in readable form (such as "New Project" rather than newproject) as a label in the AndroidManifest.xml file.
- Expand app > manifests and double-click AndroidManifest.xml.
- Find the statement below, and if necessary, change the label if to the string resource for the new app name:
android:label="@string/app_name"
เปิดใช้งาน ADB ผ่าน WIFI โดยไม่ต้องใช้สาย USB
$Library/Android/sdk/platform-tools/adb tcpip 5555 $Library/Android/sdk/platform-tools/adb connect 192.168.2.103:5555
อ่านรายละเอียดต่อได้ที่ Copy and rename a project
Relate topics
- สร้างปุ่มเมนูบน Action Bar ของ Template Buttom Navigator Activity
- วิธีการรับส่งข้อมูลของ Android Fragment
- Android : เพิ่มภาษาไทยให้กับ app
- Add Firebase Analytics & Crashlytics to Android App
- ทำให้ Web App คุยกับ Android ผ่านทาง WebView - Building Web Apps in WebView
- Android เขียนยาก กูเกิลเลยเปิดคอร์ส Android Performance ปรับแต่งประสิทธิภาพแอพ เรียนฟรีผ่านเน็ต
- เขียน App Android จะว่ายากก็ยาก จะว่าง่ายก็ง่าย
- Android : Input type="file" ไม่ทำงานบน webView
- มาเริ่มกันใหม่อีกครั้งกับ Android Studio
- Android Studio
- Settrade Streaming for Android
- Change your android phone to auto webcam
- Android App : Instant Heart Rate - จังหวะการเต้นหัวใจ วัดได้จริงเหรอ?
- My app on Android - ใช้แอบอะไรบ้างนะบนแอนดรอยด์