How to run this android studio app from github? - android

I downloaded this git repository: https://github.com/jitsi/libjitsi
It contains two examples, but when I try to run them, the run button is disabled:
When I select in the menu "Run" -> "Run", it tells me to add the edit configurations for the app and this window opens, but I don't know what to select there:
I found this additional site referring to the examples (when you scroll down a bit under examples and API):
https://desktop.jitsi.org/Projects/LibJitsi

Those are designed for use from the JVM, such as on a desktop or server. They contain main() methods for use with the java command. They are not Android apps and cannot be run from within Android Studio on Android devices.

It seems that the project is not imported in a good way as in an Android Project and the reason for that is, It is not an Android Project It is just a basic java library.
If you want to add this functionality you can export the JAR and then add it as a library to your existing Android Project.
And if you want to clone some project from GitHub the better way could be:
File -> New -> Project From Version Control -> Add the Git Repo Link

It seems this is a library that is usually added as a dependency to another application. This library can however also be run as a standalone Java application. I'll leave to you whether that is the desired way to use this library, you can also consult the library documentation.
You can find how to run a Java application in IntelliJ IDEA in the documentation here:
https://www.jetbrains.com/help/idea/running-applications.html
https://www.jetbrains.com/help/idea/run-debug-configuration.html
I'll explain it my way.
To start a standalone Java application in IntelliJ IDEA, you need to "Run" the class with a public static void main(String[] args) function. In this project there are several, each with a different purpose. Use the project documentation and their JavaDoc to find out which one you want.
For this answer, I'll use org.jitsi.sctp4j.SampleClient which, according to its JavaDoc, is:
Sample SCTP client that uses UDP socket for transfers.
There are two ways to go about Running it. I'll start with the way I usually use.
Open the class in IDEA. You will see a green triangle next to the class name and also next to the main function. Both do the same thing.
Click it and select "Run 'SampleClient.main()'" from the dropdown menu:
You can see the result at the bottom in the "Run" tab. That's it, at least for this class. The application should start successfully. You can stop it just like in Android Studio, using the red square either in the Run tab or at the top right in the navigation bar. Some applications will just perform an operation and stop on their own.
This class does not need any arguments for its main() method. If it needed them, we would have to add them in the Run Configuration...
And that is where we'll go for the second way to Run an application.
You will need this way if the main() method requires any arguments. You can also use it instead of opening the class file in the first place.
If you used the first method to start the application, you will see a Run Configuration already created for the SampleClient class. You can use it to run the application from the navigation bar, just like in Android Studio. You can also open the dropdown menu and select "Edit Configurations" to modify it or add a new Run Configuration:
You can modify the configuration created for SampleClient - add program arguments, environment variables and more.
To create a new configuration, click the "+" icon and (in our case) select the "Application" type. Other types of Run Configurations include JUnit tests, Maven tasks, server deployments and more:
In the "Main class" field, either manually enter a qualified class name (code completion also works), or click the "..." on the right and select a class from the list of classes with main() methods:
You can again add program arguments and more. When you're done, you can use the configuration from the navigation bar.

Related

Why can't I specify where I want my Kotlin file to be destinated in Android Studio?

my problem is the following:
I'm using Android Studio 3.0.1 and I'm trying to be as fast as possible on creating new files (using MVP can be a challenge in Kotlin).
For example, when in Java you find this:
Then if you click (according to your computer) on Option + Enter, I have the option to create my interface:
I can choose the package and the folder where it will be placed:
But when I'm with Kotlin:
It just offers me to choose the class container (and I want to import it, setting up externally)
Is there any reason why Android Studio is not equipped with this?
You do need a second step currently, but it's very simple: create it in MyListActivity.kt and then Option+Enter on the created interface will give you option to move it to a separate file. And look on https://youtrack.jetbrains.com/ if there is an issue for this yet.

Can I use Android Studio's 'Find Useage' for Android SDK Source Code?

One of the most useful functions in AS is right-click and 'Find Useage' or 'See Declaration'. For my code, the 'Find Useage' will show all instances of where a function/object is used.
I have the SDK source code in AS too, but I can't 'Find Useage' on that code. Is there a way to set up my projects so that I can use 'Find Useage' on Android SDK code? For example, I would like to go to android/platform /frameworks/.../Configuration.java, right click on Configuration, and see where that class is being used elsewhere.
Failing that, is there a way to find useages short of grepping around the massive SDK project?
Yes, that is possible. You can configure the scope of the search function.
Move the cursor on the symbol you want to analyse, press Ctrl+Shift+a (search for action) and search for Find Usage Setting or from the menu select Edit -> Find -> Find Usage Setting and select Project and Libraries in the scope section.
If the menu item is grayed out, it's because no symbol has been selected.
Furthermore, if you are looking for a particular feature in AS the search for action function is a huge time saver.
BTW: If Project and Libraries is not available it's because there is no usage of the selected symbol in any library.
May be you are looking for this:
Edit->Find->Find in path...
If you are using Android Platforms Codebase directly from the repo, then you can do it. In this case, you will have to update your dependencies by creating another gradle project in your studio where the platform codebase is and then import that in your project.

How to launch an Android project from an Eclipse plugin programmatically?

OK, I've started doing some Eclipse plugin development.
I've got my own custom icon in the toolbar.
When clicking the icon, I'd like to show the following screen to the user:
I have an IProject object of the Android project I'd like to launch.
Unfortunately, there's no simple IProject.launch() method...
What I've done so far is cloning the ADT source from here
git clone https://android.googlesource.com/platform/sdk
and started copying over all the necessary parts.
There must be an easier solution than this?
Can't I just hand over the launch of the project to Eclipse / ADT Plugin?
If you only need to change some of the Java code directly before the user launches the project, you can go an easier route: Just implement an additional project nature and an additional project builder. Then add the nature and the builder to your specific projects. Make sure your new builder is before the other builders in the project builder order, like in the below screenshot
Everything else works like before. That way your plugin is like every other large plugin. E.g. the Android tools also do some magic first and then the normal Java builder is invoked, instead of re-implementing the Java stuff.

libgdx and TWL: Android app force closes on any TWL menu, works fine on Desktop

I am implementing menus using TWL (http://twl.l33tlabs.org/) in an app written using Libgdx. The app runs fine if I don't start any menus, but as soon as I go to a menu screen it immediately force-closes. Menu screens work fine on the desktop version.
In which build path should TWL-android.jar be included (right now it behaves the same in main, android, and both)? And how will the program know to use the libraries from this .jar instead of the default gdx-twl.jar? Will I have to manually implement something in code to use one or the other depending on platform?
There does not seem to be any documentation or sample code of anyone using TWL on android, only mentioning that it can be done.
Running debugger attached to phone gives the following logcat error:
Could not find class 'com.badlogic.gdt.twl.Layout' referenced from method com.Nanners.OptionsScreen.<init>
I think that TWL-android.jar should be added to android project's build path too. Location of .jar is not relevant.
When you add TWL-android.jar. As that is Android specific you can't use it on the core project, so the classes you are importing are the ones from gdx-twl. To make it simpler to explain I will divide it in different escenarios.
You add TWL-android to your Android buildpath. But you use Gdx-twl in your core project. Which isn't added. Thus getting a:
Could not find class 'com.badlogic.gdx.twl.Layout'
You add both TWL-android AND Gdx-twl to your build path. Thus getting duplicated classes and:
Conversion to Dalvik format failed with error 1
Solution
If you use TWL-android classes, you can only do it inside the Android project:
Merge Core, Desktop and Android project. Or
Use Interfacing with Platform Specific
If you use Gdx-twl:
Don't do it.
Actually the best solution is to get rid of all twl stuff and use Scene2d.Ui instead. Its crossplatform and much easier to use.

Efficient Way to Integrate Project as a Package?

I have two independently developed Android projects (with own activities etc.), tested and working independently.
One project is now supposed to be launching (via Intent) the second project.
I could have kept it that way, but when distributing it via the Android Market, it will necessitate 2 APKs, 2 icons, etc. which could be very confusing to the end user.
So I would like to integrate the second project into the first one, while keeping it as a separate package.
A straightforward approach for doing this is to manually create an empty package, then copy over all files, one by one, from the second project. Tedious.
Is there a built-in shortcut in Eclipse (or ADT) to do this, similar to the File > Import > Existing Projects into Workspace ?
I think you can make your second project as a Library Project by right clicking on it and in the Android tab check isLibrary. And then in your first project, you link the one that you made a library by right clicking again and under the Android tab, Libraries, click Add and point to your Library Project. You could also have a look at Managing Projects from Eclipse.
If this does not work (but I really should), you can simply just right click on your packages, then select Copy and go to your first project, and just right click -> Paste. This also worked for me.

Categories

Resources