Spoon JAR for local testing - android

I'm trying to test making changes to the Spoon source (trying to learn how it all works) but can't figure out how to build the final jar (with dependencies similar to the one available from the site) that we can then use to run independently.
I tried running the ./gradlew build and ./gradlew install with some minor code changes and everything builds successfully but I can't locate the JAR that works properly. :(
Any help / documentation related to the build/release process would be much appreciated.

Import project in Intellij Idea (not Android studio)
Import project from external model Gradle
Next -> Finish
Then you'll receive
Error:SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable.
Create local.properties file in root directory with following content:
sdk.dir=/Users/yourusername/Library/Android/sdk
If you see problems with gradle, press on gradle menu (tab at the right side) and click on synchronize/refresh button.
Open Project Structure -> Modules. Click + -> Import module -> spoon-client -> Import module from external model Gradle -> Next -> Next.
Do the same procedure for spoon-runner and click Apply.
Open Project Structure -> Artifacts. Click + -> JAR -> From modules with dependencies...
Select spoon-client, leave Main class empty, press OK.
Do the same procedure for spoon-runner. Click Apply -> OK.
Click Build -> Build Artifacts... -> All artifacts.
JARs will be created at the location you have specified in the Artifacts menu.

Related

How to run the 'gradle init' task in Eclipse Buildship plugin?

I want to use Gradle for my Android project, and I use Eclipse (rather than Android Studio). My web-search pointed me to Eclipse's Gradle Plugin called Buildship. I downloaded and installed it following this guide.
My need is to convert my Android project in my Eclipse workspace into something that works with Gradle build system. So following this section of the guide mentioned, I added Gradle support to my project. But I still can not see a build.gradle file in my project. I did refresh the project.
So what do I do to get a build.gradle file in my project?
*The guide I linked to says, *
Run the 'gradle init' task to create the initial Gradle files, in case
you do not have them yet.
but I can't figure out how to run the gradle init task.
In the "Gradle Tasks" panel, expand the node of your project. Then expand the "build setup" node. Right click on "init" and select "Run Gradle Tasks".
Then in the project explorer, right click on your project and select "Gradle", then select "Refresh Gradle Project". And voila! You must be able to see your build.gradle now.
Go to windows-->Show View-->Gradle Tasks. In this view you will be able to see your project.Expand build setup and double click "init" task.

Android Studio not recognising Gradle projects

No matter what projects I import they never work - Android Studio is always flagging this is not a Gradle build project.
I select VCS -> GIT and clone the repo without any problem. I then go through the wizard with no issues (I select create project from existing sources), creating my code base with a warning, below. When i try to run throws all sorts of errors.
Migrate Project to Gradle? This project does not use the Gradle build
system. We recommend that you migrate to using the Gradle build
system. More Information about migrating to Gradle.
Don't show this message again.
When I go to the link it makes no sense whatever to me, it says to create an arbitrary Gradle file and populate it with my references (I think), which is out of my understanding. I shouldnt have to do this as it says in the repository instructions that it is in fact a Gradle-based project.
The project I am trying to clone is
https://github.com/googlesamples/android-play-location.git
Can anybody tell me specifically how to import and run the following git repo in Android studio for example?
Ok from the start (as i dont know what other way works)
Go to Git master page (it has 'download to zip' or 'clone to desktop' button). use https://github.com/googlesamples/android-play-location as a test master page if you like to ensure you have no other issues i did not.
Click 'download zip'
Unzip the project
Close the current project in Android Studio -> File/Close Projects
A popup screen like this will appear, choose Import Project (Eclipse ADT, Gradle etc.)
You will be asked to select the project, select your unzipped project within the master folder, eg basicLocation
Select 'create project from existing resources' default
dont change project name (may cause issues)
Next through 'import project -> directories'
Next through project -> libraries
Next Through import projects -> modules and module dependencies
Next through import project ->SDK
Next through import project ->manifest.xmls
Android Studio starts. Ensure the configurations dropdown has a project in it called 'app' app
Select 'sync Gradle' icon (green circle)
May get language warning, ignore or accept restart, doesnt matter
At bottom it should now say 'Gradle executing tasks' after which it will run on device or emulator :)
Short answer: File > Open > the build.gradle file you just cloned with the repo
I just wanted to add this, because I had the same problem, and even if Fearghal´s answer and comments pointed me in the right direction, I think he may have added unnecesary extra steps, i.e. Download as ZIP, Close current project, etc.
Simply put, you VCS > Git Clone, and then open the build.gradle file. That´s it
This can happen for many reasons. I typically see it when I move the directory. The easiest way I have found is to close the project and then reopen it using "Import project (Gradle, Eclipse, ADT, etc.) menu item then selecting the folder. This will force it to reimport the project and fix any metadata/configs.
What worked for me was
On Android Studio
Open the settings.gradle file
include your project
include ':myproject'
Well, as Android Studio correctly says, https://github.com/googlesamples/android-play-location is not a Gradle project.
Any subdirectory of that repository is however.
They are different projects.
So clone that repository and import one of its subdirectory in Gradle.

Android Studio: Importing Eclipse project from SVN along with Library projects

I am able to import the main project along with two other library projects from SVN. But while in the process if I select,
"Create project from existing sources" it creates the project and after doing some modifications in Project settings it works. But I could not find the Gradle file and it gives error "The project 'CrossConnectRefactored' is not a Gradle-based project" if I select the Gradle icon.
If I select "Import project from external model -> Gradle", it creates the project but still without 'Gradle' file and it gives the similar error.
If I first Export the project from Eclipse using 'Android -> Generate Gradle build files' and import the same in AndroidStudio then it creates all the required Gradle files properly. But I didn't get option to build/run the project and it always says 'Gradle project sync failed. Basic function...'.
It also gives the below error,
Could anyone please help me out with the 1st or 2nd option?

Import an eclipse android project with version control system into Android Studio

I am trying to import an eclipse project with version control system into Android Studio.
Support for direct eclipse project import was added in Android-Studio version "0.5.5" where we don't need to export project first from eclipse to import it into Android-Studio.
I have an eclipse Android Project which I am trying to import into Android Studio.
Import is successful but imported project no more has version control.
Edit:- More detail
Suppose I have following Directory Structure
Project ----
|---------- .git/
|----------- MyApp
|------------MyApp_imported
During project import, I point Android Studio to Project Directory "MyApp", It copies all files in my project "MyApp" to new directory "MyApp_Imported". But imported project doesn't have version control enabled.
Now I am not sure how to proceed further.
How should I tell Android Studio to use old repository for imported project.
A step by step guide to do this will be very helpful .
Here is text from Android Tools Project Site
Project
- Importing modules should now work properly. You can import existing Eclipse
ADT projects as well as Gradle modules into an existing Gradle project;
it will copy in the sources as is done for full project import, as well as
handle dependencies transitively. Import modules either from the project structure dialog or the File | Import Module action.
- New project structure dialog implementation: Should be faster, includes
Gradle sync notification, should only perform a Gradle sync at the end
when necessary, and won't list invalid IntelliJ module warnings as before.
This is actively being worked on and the individual editors
(for flavors, build types, signing configurations etc) will be improved
in upcoming builds.
Here is the step by step solution to do it.
Open Android Studio -> Import Project-> Select your project directory. (In above case "MyApp")
Remember Select the directory which contains Manifest file otherwise new "direct import wizard" doesn't
get triggered and android studio uses old import wizard.
Android Studio will create a copy of your project "MyApp_imported" with new directory structure.
Copy your existing ".git" directory inside "MyApp_imported"
Android Studio -> VCS -> Enable version control
This will make Android Studio use your existing repository for imported project. Though imported project has
different directory structure but git handles them pretty well.
You might want to also call git add . and git add -u in the root folder of the imported project to make sure all new files are added and existing file moves are detected by git.
Android Studio -> Changes
Review all files and commit. Git will automatically handle new directory structure and file history etc will not be lost.
Now you can share it on github/Bitbucket by
VCS-> Share it on GitHUb
Note:- For bitbucket you will have to install "Bitbucket plugin" for Android Studio.
Couple of months ago I got my job as android developer.The first problem i had faced were my collegues who using Eclipse.I was allowed to use Android studio if I will not make any changes to existing project structure.After 3-4 attemps I finally found a decision.Here is steps to open Eclipse git project without migrating to Gradle and without changing project structure.
Clone git repository of project
Add /gen and /.idea to .gitignore
Open any of already created Android Studio projects.
File -> Open -> Choose path root project folder(with src and res inside)
Doble-click project to open project structure
Select root project folder -> F4
Project -> Project SDK -> Android API XX Platform && Project language level -> Override in interfaces
Modules -> Sources tab. Mark src as Sources && res as Resources.
Modules -> Paths tab. Use module compile output path.Create folders output and output_test inside gen folder (create gen if folder not exist yet).Output paths should look like C:\Users\User\project_rep\project\gen\output
Modules -> Dependencies tab. Click "+" -> Jars or directories.Select all .jar libraries which are using by your project.(Android Studio can pretend like its added only one jar but thats not true)
Facets -> "+" -> Android
Facets -> Structure tab -> Reset to defaults.
Close Project Structure window.
Run -> Edit configurations -> Android Application -> Module -> Select your module.Target device -> Show chooser dialog.
Edit configurations -> Before launch -> remove Gragle aware make, add Make.
Finally, after all of those steps you are able to hit Run button.Enjoy!
The import process does not make this easy. But here's something to try:
Let Android Studio do what it wants to do. It creates a file in the root of the new copy of the project which shows what was moved where.
Make a fresh (scratch) copy of the original git repository. Use "git mv" commands to duplicate the directory structure changes which Android Studio made. Commit the changes.
Copy the resulting .git directory into the project made by Android Studio. Use "git status" there to see how the result of the import process differs from what you did in your scratch copy of the project. At this point you might just choose to commit the remaining differences right there.

Android Studio Error "output path is not specified for modules"

I just recently upgraded to the newest version of Android Studio (0.1.1), but I also used Android Studio to relocate my project to my Dropbox folder. So, I'm not exactly sure which one is causing this problem. When I build or try to run my project I get this error:
Cannot start compilation: the output path is not specified for modules
"actionbarsherlock",
"EmPubLite-EmPubLite".
Specify the output path in Configure Project.
I can't find any reference to "Configure Project" and the Project Structure option under File no longer works in this release.
Solution for Android Studio version < 1.0 :
You just have to go to your Modules settings > Project and specify a "Project compiler output"
and make your modules inherit from project. (For that go to Modules > Paths > Inherit project.
Or you can specify your output for each module if you want.
In order to do so you just need to follow this steps:
Open Project structure (F4 on one of the modules in the project explorer)
Click on Project tab on the left
Define "Project compiler output:" as YOUR_PROJECT_PATH\out (or any folder you want)
Click on Modules tab on the left
Go over all your modules and verify that under the Paths tab the Compiler output is set to "Inherit project compile output path"
I ended up re-importing the project using Gradle and it's back to normal. Very weird issue.
this is a problem that I face in case I open my phonegap project with Android Studio and Webstorm.
They are IntelliJ-based project and I guess they are both writing the files in .idea
Reimporting the project is the solution.
got same error while using studio feature to import from GitHub repository.
I deleted the whole project and .. cloned it using git terminal and imported as new project ... studio prompted to add VCS root, accepted ....everything was fine afterwards. As #lordhong prompted.
I found this:
http://www.chrisdew.com/blog/2013/07/17/android-studio-nosuchmethoderror-lazystringarraylist/
it is realy help for me.
Thus, in my case, the problem was to have two libraries:
protobuf-2.4.1.jar
and new protobuf-2.5.0.jar
it resulted error:
APK path is not specified for module “Example-Example”
To correct this, rename file protobuf-2.4.1.jar to protobuf-2.4.1.jar.disabled
mv protobuf-2.4.1.jar protobuf-2.4.1.jar.disabled
How I finally managed to fix after hours!
File -> Project Structure -> Facets -> choose module's facet -> Packaging. Enter in APK Path absolute path to apk to be created: C:\workspace\MyCompany\MyProject\myProject.apk
Press ok and run your project

Categories

Resources