简体   繁体   English

如何将示例应用程序导入Android Studio Project

[英]How to import sample app to Android Studio Project

I am following this tutorial regarding in app purchase. 我正在关注应用程序购买的本教程

In step 3, the tutorial ask to do, 在第3步,教程要求做,

"Add the helper classes from the /util directory of the TrivialDrive sample to your project. Remember to change the package name declarations in those files accordingly so that your project compiles correctly." “将TrivialDrive示例的/ util目录中的帮助程序类添加到项目中。请记住相应地更改这些文件中的程序包名称声明,以便项目正确编译。”

The problem is, how to import the helper classes to my android project? 问题是,如何将帮助程序类导入我的android项目? Is there any where I can import to project (sample app) into my existing project? 我可以将项目(示例应用程序)导入到现有项目中吗?

Thank you for your help.. 谢谢您的帮助..

"Add the helper classes from the /util directory of the TrivialDrive sample to your project. Remember to change the package name declarations in those files accordingly so that your project compiles correctly." “将TrivialDrive示例的/ util目录中的帮助程序类添加到项目中。请记住相应地更改这些文件中的程序包名称声明,以便项目正确编译。”

This means copy the source code under /util directory to your project and don't forget to change the package name if needed. 这意味着将/ util目录下的源代码复制到项目中,如果需要,不要忘记更改包名称。

Just Copy Those classes to your project directory. 只需将这些类复制到项目目录中即可。 Android Studio will automatically change their package names. Android Studio将自动更改其包名称。

What this means is that you should create a new java class in your project and then just copy the code from the sample project into your project. 这意味着您应该在项目中创建一个新的java类,然后将示例项目中的代码复制到项目中。 It says to change package name declarations to match your project. 它说更改包名称声明以匹配您的项目。 Look at the top of the Java class in the sample project and you will see a line that looks like this: 查看示例项目中Java类的顶部,您将看到如下所示的行:

package com.example.project.util

If you look at the top of one of the activities in your own project you will see something similar. 如果你查看自己项目中其中一个活动的顶部,你会看到类似的东西。 When you paste the code just make sure that line is changed to match yours and it should work. 粘贴代码时,只需确保更改行以匹配您的代码,它应该可以正常工作。

To create a new Java class in Android Studio just right click on the folder that contains your activity classes and click on create new Java class. 要在Android Studio中创建新的Java类,只需右键单击包含活动类的文件夹,然后单击“创建新的Java类”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM