简体   繁体   中英

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,

"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."

The problem is, how to import the helper classes to my android project? 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."

This means copy the source code under /util directory to your project and don't forget to change the package name if needed.

Just Copy Those classes to your project directory. Android Studio will automatically change their package names.

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. 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:

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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