How to import a java package in Android Studio
Asked Answered
R

5

14

I'm new in android, and I want to import the jfftpack to my project in android studio anda i don't know how to import it.

The original code was import ca.uol.aig.realdoublefft and I'don't know where to put the java files. I've tried to put them to a libs folder.

here's the jfftpack source code:

Rohn answered 24/11, 2013 at 18:28 Comment(1)
Cause i had some problems with Eclispe and i tough it would be easier with android studio.Rohn
E
10

If it's an existing code library, I'd recommend adding a module for it. Probably the easiest way is to use the File menu command to add a new module, let it create a plain Java (non-Android) module for you, remove the sample class it puts into the module, and then copy your files over into it and tweak it. The module wizard will take care of setting up the directories and build files for you, and you can look at it later and see what did.

Eyde answered 25/11, 2013 at 4:5 Comment(0)
G
3

Without pressing Alt + enter to import the Packages?

There is some steps like 1)File --->Settings --from left pane we find editor---->General--->Auto Import

There Insert imports on paste as ALL not ask

And put check mark for all the Above three Fields

1)Show import popup

2)Optimize the imports on fly

3)Add unambiguous imports on the fly

Click Apply and ok

Happy Coding......

Gera answered 12/4, 2016 at 7:12 Comment(0)
M
0

If you have the sources import them in the src folder. Is the simple thing that you can do.

Mahound answered 25/11, 2013 at 9:34 Comment(0)
S
0

I suggest you to use the command line rather than Android Studio interface. If you work on Linux or MacOS, try to copy the package to your working direcotry like:

cp -r PACKAGE_NAME PATH_TO/AndroidStudioProjects/PROJECT_NAME/app/src/main/java/
Stellastellar answered 24/5, 2019 at 0:53 Comment(0)
W
0

I am also new and had the same problem. I didn't have the package instruction at the top of the java file package com.example.myapp

Wish answered 2/8, 2020 at 21:39 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.