I am new to java and Andriod studio development. I working on an app that need to run "gradlew assembleDebug" command in the app itself.
is that possible?
Android does not ship with any build tools inside it. On your phone, there is no gradle.
In theory you can make an app that ships these tools but this is very complicated; that sounds like a project far beyond sensible for someone new to java and android development.
--
Or, did you mean: You are writing a plugin for Android Studio and it needs to run gradlew? That doesn't sound like a good idea: Android Studio itself does a bunch of stuff around invoking gradle and may have it built in; you should tell studio to invoke it, instead of doing it yourself. I don't know how that's done, though.
--
If you really want to invoke commands, use ProcessBuilder. But as I said, this is not what you want to do here.
Related
I am currently using ubuntu 21.10 and have flutter, java, Android Studio,Visual Studio Code installed. I can build android fine. I can run desktop versions of it. When it comes to building a snap, that is a different story. I once tried to build a desktop app by following the instructions here.
After following the instructions I ran the "snapcraft" and my computer pretty much exploded. It kept installing java and flutter and went into some infinite loop until i ran out of space on my computer (and I also have to pay for data too).
I'm wondering what went wrong? I used the multipass method. I'm not sure what that is or the alternative for LXD.
I have installed android studio, java, and flutter by using the download package methods and not snap. Was that the problem? When I first tried flutter, it did not work with snap, so I prefer not to. I wish there was a simple way to do this, like making a windows exe in flutter, etc.
I can make electron-builder snaps quite easy as well and have uploaded to the store. It was very simple. I'm wondering why things are so complex with flutter?
Any solutions? I would like to rebuild my dev machine in the next few days. I'm thinking of using the snap installs of java, flutter, android studio, instead.
I downloaded the Android studio and installed it. When I launched it, it's all "graphical". My screen reader is reading nothing on it.
I'd prefer if I could use my Notepad app, but the "stand alone" tutorials are too tiresome, and not many tutorials on the web have instructions making apps using Notepad. I wanted to know if there is an alternate IDE, or another way to code Android apps?
The Java IDE Eclipse is also not very compatible with my screen reader. I use JAWS screen reader by Freedom Scientific. I used to code Java desktop software using my Notepad, so I'm familiar with programming using Notepad.
Also, if I somehow figure out how to make Android apps using Notepad, how am I going to test them? Do I need a phone? I'm sorry for all these beginner questions, but I'm a beginner :)
You can follow this link:
http://developer.android.com/tools/building/building-cmdline.html
If you only want to build, not run, you don't need a phone. If you want test without a phone you can use an emulator by running"AVD Manager.exe" in Android SDK folder.
The good thing since the transition to android studio is that now the building of an android project is done using Gradle and can be piloted entirely by command line. So technically, you don't need an IDE at all.
Basically, every project has at least a build.gradle file that contains the instructions to build it. You only have to launch Gradle with the appropriate command to compile your app.
Yelliver mentionned the tools to build the app from the command line, there are also tools to create the project structure and the basic build files: http://developer.android.com/tools/projects/projects-cmdline.html (this documentation appears not to be entirely up-to-date, though, as it mentions the old project.properties format)
Having a phone to run your app is certainly going to be nicer and faster to develop. The emulator is far from perfect, quite slow, and sometimes not responsive. It is also easier to install other apps on your phone than on the emulator, in case your app interacts with other apps.
I wrote two small scripts for Android development without using Android Studio. They are building apk and installing it on the connected device and opening the logcat with the output of the installed application. This two scripts not even near to complete when to think all the features of the Android Studio but they are allowing to at least run the project on your phone.
I'm trying to begin programming with libgdx (in Windows XP with Eclipse for JAVA - Android) but, as every begining, nothing is clear and every doubt is a big problem.
I have found some tutorials about how to begin to programming with libgdx, but every tutorial found says the same: you must create a PC project for compile the native JAVA code and then create another project for Android who needs the PC project.
It's possible to do it in a easier way (all in only one Android project)? If it's possible, how? It would be really slower? I run my Android projects in my device (a Motorola G) and it seems pretty fast.
All (kind) responses will be appreciated. Thank you.
Are you using the project generator? http://code.google.com/p/libgdx/wiki/ProjectSetupNew
You could use that and simply ignore the non-android projects it creates ,even delete the other ones you don't plan to use (not the main java one though) and run it via an android emulator/device.
You will probably still have to keep the main java project, libgdx is geared towards people that want to compile to multiple devices.
It's been over year since i've used libgdx and i don't recall this being one of the issues i had with it.
The easiest way I find is to actually just put a main method class in your libgdx project. I have a wrapper project for android that invokes my libgdx project but if you look at the example in superjumper source in github you can see they just put a main method class within their libgdx project.
The android project then just delegates to this project.
Consider though, if you do run it directly from a project, you'll need to code in keyboard cursor keys which is pretty easy, you can follow the superjumper example here line 138.
I know that questions like this have been asked before, and I have been sifting through them. So here is my situation: I have a decent amount of experience using Java, specifically Eclipse, and I have a game ready that from my current standards, could be uploaded to the Google marketplace.
However, I have the project saved as a Java project. How do I make this project into an android app? I have attempted using the ADT plugin for Ecclipse, and changing the nature of the project file but I am beyond confused regarding how to proceed.
Right now I can click: Run < Run as < Java application.
The goal is to be able to click: Run < Run as < Android application.
I don't know of a streamlined way of doing it. Is your game using Swing as a UI? JavaFX? Is it text?
Regardless, I imagine your game would need to be wrapped in an android activity in some way. e.g. The activity can invoke the browser to run your applet (if your game is an applet).
I'd first create an android project, then copy your source from the java project into the android project. The manifest (R) will be updated with the new resources, etc.
Then you have to finish wiring everything up.
It's going to take more than that. Android has it's own UI system and lifecycle that differs from raw Java. Depending on how you've written the game you may be able to reuse a lot of the drawing and logic code but you going to need to make a lot of changes to the input and allowing multiple screen sizes.
Without seeing your code I can say exactly what you'll need to do but I can tell you it's not going to be as simple as Run As... Android Application.
Although android apps are written in Java code, this doesn't means that it is possible to "translate" a java program or a game in an android app simply clicking a button.
If the game are complex I suggest that you rewrite the game using a framework for develop android game!! You can reuse some logic but sure you have to create all the graphics and readapt the game to run in android devices.
GOOD WORK!!
Be patient and star from here:
Androi Developers
It is not possible. You can implement the application logic in Android in the same way that you used in Java, but you cannot simply convert the java project into Android project. Some packages used in your java project (like swing) can't be used in Android.
Lately I've been doing a lot of web development on my Droid via ssh using the ConnectBot app and a few other apps for reference. I've also been doing a lot of Android development back home in eclipse, and I wondered: would it be possible to develop and test my android projects right on my phone? All I can do at the moment is either write the code via ssh and then open it later with eclipse to finish it up, or remotely use eclipse via LogMeIn Ignition or VNC. Does anyone know a native way to do what I'm trying to do, preferably offline?
Try AIDE. I use it because it supports Eclipse projects. https://play.google.com/store/apps/details?id=com.aide.ui
Not sure if this hits the target you're looking for, but The Scripting Layer for Android (formerly known as the Android Scripting Environment) is available and has a lot of power available to it.
Scripting Layer for Android (SL4A,
formerly known as Android Scripting
Environment or ASE) brings scripting
languages to Android by allowing you
to edit and execute scripts and
interactive interpreters directly on
the Android device. These scripts have
access to many of the APIs available
to full-fledged Android applications,
but with a greatly simplified
interface that makes it easy to get
things done.
Scripts can be run interactively in a
terminal, in the background, or via
Locale. Python, Perl, JRuby, Lua,
BeanShell, JavaScript, Tcl, and shell
are currently supported, and we're
planning to add more. See the SL4A
Video Help playlist on YouTube for
various demonstrations of SL4A's
features.
I found DroidScript. It's a quite powerful JavaScript interpreter thats based on the Rhino-library. It can import every Java-package and even create activities for starting from the launcher. The URL is http://droidscript.se for the Live-Editor with which you can edit scripts online and send them to your phone, and the droidscript-app has an editor, too but it cant save at the moment, i think. DroidScript is Open-Source and embeddable in an own app, I think. More info on news of DroidScript are found on droidscript.blogspot.com.
check out JAVAIDEDROID on the market
You can if you have a remote linux machine that you normaly develop on.
ssh into the machine with some ssh app.
edit the code with some console text editor (vim for example).
build the application with ant
copy the generated apk into the android phone and install it
repeat from point 2.
Good luck!
I really don't know if it's possible, but to do it, you should:
"Install" java inside Android.
"Install" ant
run ant debug
Check this link for more instructions.
PS: Please let us know if you could do it :)