android studio 复制项目
-
Using Windows Explorer, navigate to the Android Studio projects directory select the project folder to be cloned;
-
Copy the selected folder;
-
Paste the folder into the Android Studio (AS) projects directory;
-
Rename the pasted folder to be the new name of the cloned project, say 'ViewPager_Shell';
-
Launch Android Studio;
-
Select 'Open an existing Android Studio project';
-
Navigate to the AS projects directory;
-
Select the folder 'ViewPager_Shell';
-
Ensure that AS's explorer pane is visible on the left-hand-side of the AS main frame;
-
Select the 'Android' view for the explorer pane;
-
Open app -> java; the old package name should now be visible, e.g. 'com.hulme.owm';
-
Right-click on the old package name and select 'Refactor -> Rename';
-
A dialog should now appear; left-click 'Rename Package';
-
In the pop-up dialog, replace the old package (e.g. 'owm') with the new package name (e.g. viewpager_shell);
-
Left-click on the 'Refactor' button; BEWARE!! ... A new 'Find Factoring Preview' pane should open in the lower-left of the AS main frame window;
-
Select 'Do Refactor';
-
Using the AS explorer pane, navigate to 'Gradle Scripts -> build.gradle(Module:app);
-
Double-click build.gradle(Module:app) to view its contents in the AS editor pane;
-
Change the defaultConfig 'applicationID' string to your new full package path (e.g. "com.hulme.viewpager_shell");
-
Using the AS explorer pane, navigate to 'app -> manifests -> AndroidManifest.xml';
-
Double-click on 'AndroidManifest.xml' to view it in the AS editor pane;
-
Under the manifest tag, you should observe that the new package name (e.g. 'com.hulme.viewpager_shell') now appears, as a result of the previous refactoring step;
-
Under application tag, change android:label to a new name (e.g. "ViewPager Shell Demo") - this is the name that appears in the list of installed apps provided by Android's 'Settings -> Application manager;
-
Under activity tag, change android:label to a new name (e.g. "VP Shell") - this is the name that appears under the app's icon and it is also the activity's default ActionBar title;
-
You should now be able to build and run the newly cloned project.
-
-
使用Windows资源管理器,导航到Android Studio项目目录选择要克隆的项目文件夹;
-
复制所选文件夹;
-
将文件夹粘贴到Android Studio(AS)项目目录中;
-
将粘贴的文件夹重命名为克隆项目的新名称,例如“ViewPager_Shell”;
-
启动Android Studio;
-
选择“打开现有的Android Studio项目”;
-
导航到AS项目目录;
-
选择文件夹“ViewPager_Shell”;
-
确保AS的资源管理器窗格在AS主框架的左侧可见;
-
为浏览器窗格选择“Android”视图;
-
打开应用程序 - > java; 现在可以看到旧的包名,例如'com.hulme.owm';
-
右键单击旧的包名称,然后选择“Refactor - > Rename”;
-
现在应该出现一个对话框 左键单击“重命名包”;
-
在弹出的对话框中,将旧的包(例如'owm')替换为新的包名称(例如viewpager_shell);
-
左键单击“Refactor”按钮; 谨防!!...在AS主框架窗口的左下方打开一个新的“查找因子预览”窗格;
-
选择'Do Refactor';
-
使用AS资源管理器窗格,导航到“Gradle脚本” - > build.gradle(Module:app);
-
双击build.gradle(模块:app)在AS编辑器窗格中查看其内容;
-
将defaultConfig'applicationID'字符串更改为新的完整包路径(例如“com.hulme.viewpager_shell”);
-
使用AS浏览器窗格,导航到“app - >清单 - > AndroidManifest.xml”;
-
双击“AndroidManifest.xml”在AS编辑器窗格中查看它;
-
在清单标签下,您应该观察到,由于以前的重构步骤,新的包名称(例如“com.hulme.viewpager_shell”)现在出现;
-
在应用程序标签下,将android:label更改为新名称(例如“ViewPager Shell Demo”) - 这是Android的“设置” - >应用程序管理器提供的已安装应用程序列表中的名称。
-
在活动标签下,将android:label更改为新名称(例如“VP Shell”) - 这是应用程序图标下方的名称,也是活动默认的ActionBar标题;
-
您现在应该能够构建并运行新克隆的项目。
1:修改包名,定义成你觉得与功能相对应的
2:在工程中找到GradleScripts文件夹下的build.gradle(Module:app)文件中修改- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
applicationId 这个标签,使编译器认为你是新建了一个工程,从而不会覆盖原来的文件目录
-