Reputation: 127
I am new to Android Studio and a trying to use it to run a piece of java code that I have made on my phone. I exported the code as a .jar file and imported it into android studio but I have no idea how to get it to run, I read that you have to add a few lines to the dependencies so I have done that but nothing has changed, ideally I would just like a simple app that contains a button that when pressed executes the java code but I cannot get past importing the libraries. Is what I am trying to do even possible? Could someone please explain how I can get my java code to run inside an android app?
As I mentioned I am very new to Android Studio.
Upvotes: 1
Views: 271
Reputation: 1998
Place the jar into the /libs folder (you'll need to create this folder first), and add this dependency to your app/build.gradle file (inside the already existing "dependencies" block):
implementation fileTree(dir: 'libs', include: ['*.jar'])
This way all the jars you put into the "libs" folder will be accessible in the app code.
Upvotes: 2