Android ActionBarSherlock on NetBeans - working but editor showing errors - android

I'm using NetBeans for android application. I installed properly (I think) ActionBarSherlock package as android library project. Everything works fine, I can build and run application, but code editor doesn't recognize ABS classes (just look at screenshot, BUILD SUCCESSFUL but errors exists) and code completion doesn't work too.
My configuration:
Stable NetBeans 7.2 with android plugin ver. 1.13
Linux Mint 13 Maya 64 bit, Mate
ActionBarSherlock ver 4.2 (stable)
How I installed ABS:
Download and extract source
From sdk/tools run command:
./android update project -p path_to_ActionBarSherlock/library/
Similar command to connect android project library with my test project (there is similar option in Netbeans IDE but I get error that this is not android library project)
./android update project -l path_to_ActionBarSherlock/library/ -p path_to_my_test_project
I have tried clean and build on both projects but no results. Any idea?
Regards

The way I finally managed to add ActionBarSherlock to my android project on Netbeans was to:
Download the latest version of ActionBarSherlock and unzip it
Go to the subfolder called library and remove the pom.xml file from there (with one of the previous versions it didn't work. I had to first build it, close it and remove not only pom.xml but also some netbeans properties files)
Open that subproject (library) in the Netbeans
Now this project will no longer be seen as a maven project. Netbeans will see it as an Android project. Then I:
Clean&build it
Add it to my-project's library properties (right-click on my-project, properties, library, add, point the proper location of library project). Important here was to copy/move that library project somewhere near my-project. Otherwise it claimed that it cannot open it.
And from now on it works fine.
Key to that thinking was that Netbeans didn't want to add the provided library project cause it saw it as a Maven project. When the pom is deleted, Netbeans no longer sees it as Maven project nut as an Android project and it can without any objections add it as an Android's project library.
Probably there are better solutions, but I didn't find any and that was the only one working for me.
Hope it helps.

You can also make a new Android project, and then copy and paste the needed files in the new project.
So only copy:
libs, res, src, AndroidManifest.xml

Related

Exporting an eclipse project as gradle

I have been trying to export my eclipse project as a gradle build file to use it with Android Studio but I can't seem to make it work correctly.
When I click "Finish" nothing happens. If I repeatedly click it, I can see a progress bar that shows for a millisecond and then vanishes.
My ADT is version 22.3 (which is the latest) and I have tried all of the solutions I found on google as well.
Similar questions can be found here:
Eclipse Gradle export of Android project does nothing
Cannot generate gradle.build files from Eclipse
As you can see, there is not really a solid solution for this problem, but people wrote they created it manually. I don't know how to do so though.
Is there any solution for this problem that I haven't heard of? If not, how can I create the file manually?
Apparently, the current edition of the export-to-Gradle support in Eclipse cannot handle a project that is attached to an Android library project. In that case, you would need to (temporarily) detach the Android library project, export the main project, then modify build.gradle to use the library project (manually or via Android Studio).
Generating build.gradle files FIRST FOR ALL of the projects in my dependencies ONE AFTER ANOTHER worked for me.
I generated build.gradle (with export wizrd for facebook, play and whatever other projects I imported and used in my project).
For not trivial Android project you should do it manually.
For the latest build.gradle template for classic Android project check gh.c/N/n-1/b/m/o.n.e.e.g/docs/android/build.gradle.
You can continue to develop in Eclipse with ADT and run Gradle build using Nodeclipse/Enide Gradle for Eclipse
(marketplace)
Some screenshots for Gradle for Eclipse:

Gradle build errors with Android Studio

When I try to build my project in Android Studio I get the following error, using the gradle plugin provided with the download (v 1.6):
The specified Gradle installation is not supported by this tooling API version (1.6, protocol version 4)
When I downgrade to gradle 1.3, 1.4 or 1.5, I get this error:
Gradle: : java.lang.ClassNotFoundException: org.gradle.tooling.provider.model.ToolingModelBuilderRegistry
The project was originally created in Eclipse, the exported using the build gradle file option, then imported into Android Studio.
Does anyone know what I can do to fix these issues? Many thanks.
I had a similar problem and I believe that it was caused by having multiple versions of gradle on my machine. The solution I found was to use the script that Android Studio creates in your project folder (either gradlew (MacOs/Unix) or gradlew.bat (Windows)):
./gradlew assemble
This causes the correct version of gradle to be run - i.e. the version that was shipped with Android Studio.
I haven't tried creating a project within Eclipse, so I'm not sure if these scripts are created when creating your project in that way.
I think the problem is with the way Eclipse 22 exports the project. In the end the way I got my project transferred over was to create a new project in Android Studio and copy over the files from my Eclipse project into the appropriate directories in the new project.
The directory structure of projects in Android Studio is very different to the structure in Eclipse, and there are several files created when you start a new project which you don't get when importing a project from Eclipse (e.g. gradlew.bat, settings.gradle).
I also had this problem which can indeed be worked around with Mark's suggestion of using ./gradlew assemble.
However, this does not help you run Make Project from within Android Studio.
To do that, I had to go to Preferences / Gradle / Use local gradle distribution
and select any random (but NOT gradle) folder inside the project folder.
You might notice that this is marked as an invalid location, but you can ignore that, it seems...
Not a great solution, but it works.

Unable to build Eclipse library projects after ADT update

I have a main project (mainapp) I am developing for Android under Eclipse. It uses the facebook-android-sdk library (fblib) which is a separate Eclipse project with it's project properties checked as "Library". Under the project properties > android section for mainapp, I have fblib added as a library. everything works fine.
I needed to create a new version of mainapp which uses different database files (assets subdirectory). To do this, I created a new Eclipse project (newapp) and setup mainapp as a library under project properties > android.
Everything was working fine until the latest ADT update. I am getting errors trying to build/run newapp (Conversion to Dalvik format failed with error 1). If I go to mainapp and uncheck "Library" from project properties > android, I can build mainapp as a regular application and it seems to work just fine.
I've searched for multiple jar files in project directories, updated proguard to 4.8beta, deleted/added jars to the build path, removed exports, added exports, deleted dependencies, added "lib" directories, cleaned, restarted, rebooted and pretty much anything else google would turn up, but to no avail.
It was all working fine with ADT 16 so I'm really confused here. Has adding a library project to an application, which also incorporates a library project, become somehow deprecated? I just can't seem to get this working.
The new ADT makes you call it 'libs' instead of lib. rename your directory and see if that fixes it
Refer: http://code.google.com/p/android/issues/detail?can=2&start=0&num=100&q=&colspec=ID%20Type%20Status%20Owner%20Summary%20Stars&groupby=&sort=&id=27490
I've also noticed in my own projects, under Java Build Path > Order and Export, I sometimes need to go in and make sure all my linked sources have their boxes checked.
I had similar issues. The issues were because of different build system introduced "Gradle".
Resolution: Forcibly open Android SDK Manager, and take update to install
1. Android SDK Build Tools revision 17
2. Android SDK platform tools revision 17
3. Android SDK tools revision 17
From all library project dont forget to enable "Android Private Libraries" the check box inside properties-> order and export.
Thanks.

Significance of com.android.ide.eclipse.adt.LIBRARIES in build path?

I've update to the latest SDK(4.0.x), tools(r16) and plugin(16.0.1) for Eclipse. I notice that now nearly all my projects in Eclipse have the library mentioned in this question's title showing as a referenced library in the Libraries tab of the Java build path. This is relatively new, though I'm not sure in which upgrade of the SDK it appeared.
It's not causing any problems but I'd quite like to know what its purpose is?
Interestingly it does not appear in projects which I also build using Ant from the command line. In these projects I send the Ant built binaries to a folder outside the Eclipse workspace. These projects naturally have a build.xml, an ant.properties and a proguard.cfg in the project root. This I suspect has something to do with why the com.android... library isn't in the build path. These projects build perfectly OK when built under Eclipse.
None of my projects are library projects.
Update: If I delete it from the Java build path, it appears to have no ill effects, in so far as the app still builds (even under Eclipse) and runs OK.
If you have any "Android Libraries" set in the Android section of the project then these are for linking in those libraries (the jars that the plugin will build)

Is it possible to set up an IntelliJ Android project to work with Maven?

I want to work with Maven dependencies in an IntelliJ Android project. Has anybody successfully done this?
I use IntelliJ IDEA (currently v11.0.2, build 111.277) on both Ubuntu 11.10 and Mac OS X 10.7.3 for working on Maven-based Android projects, and for the most part it works well. A nice thing about using IntelliJ with Android and Maven is that all support is already built-in - there are no extra IDE plugins to install.
As an example of a good working Android Maven project that can be opened with IntelliJ, you could use the source code of the open-source Gaug.es for Android app by GitHub (not all developers at GitHub use IntelliJ, personally I do - Eclipse is also used to work on this project).
The first step for smooth running is obviously to ensure that your project builds correctly using only plain Maven at the command line - although the question doesn't directly ask about this, I'd advise these pre-requisites as a bare minimum:
Java 6
Maven v3.0.3
android-maven-plugin v3.1.1
Android SDK r16 (if you downloaded your SDK before r15, you're probably better off nuking the entire thing and downloading it all again, as the directory layout has changed)
If you can mvn install the parent pom of your project, you're good to move on to actually working with it with IntelliJ.
If this is the first time opening the project with IntelliJ, you can still open it as a project, you just need to select the parent pom.xml file in the 'Open Project' dialog.
Ensure IntelliJ knows where the Java SDK is. IntelliJ, even though it's running on Java, doesn't auto-detect the location of the SDKs. You have to tell it. Go Project Structure, Platform Settings, SDKs and then edit the Java SDK if it's showing as red, giving it the path of your Java 6 SDK.
In the same Project Structure dialog window, set the Project SDK to the appropriate Android version, and under Project set the Project compiler output to whatever directory name you like - this value is required for doing a 'Make', but also overridden to by your submodules to sensiibly point to the Maven 'target' directories.
Double-check that all the Maven information has been parsed by IntelliJ. You should have a Maven Projects tab. Hit the Reimport All Maven Projects button (looks like two arrows chasing each other). If IntelliJ prompts you to enable Auto-Import, go for it. You should now have at least one module listed under the Maven Projects tab, more if you have an integration test project as well.
At this point, you should have a fairly meaningful IDE experience. Stuff that should work:
There should be no code underlined in red for no readily apparent reason.
All imports (whether from the Android SDK, Java, your own code or from apklibs) should be recognised. Note that apklib support only came in with late IntelliJ IDEA v10.5.
Refactor operations.
Force regenerate R.java file should correctly refresh the file under target/generated-sources/r/... - but this only seems to work if target/generated-sources/r is already set as a source path, ie has been generated by Maven, and imported by IntelliJ. The minimal command line alternative is to execute mvn android:generate-sources from the command line in the folder of the affected module.
Doing a 'Make' of the project within the IDE technically works, but again might fail for the same reason. I invoke all my builds using the mvn package or install at the command line.
Stuff that might not work:
Running individual integration tests from the IDE (dies with ClassNotFoundException: junit.textui.ResultPrinter)
If IntelliJ gets confused, the following steps will normally get you back on track:
mvn clean install on the command line
Hit the Reimport All Maven Projects button
Some advice:
Your Maven pom.xml files should be the source of truth for your project configuration. Minimise IntelliJ-specific configuration you do in the project settings- some of it will be liable to get wiped the next time settings are re-imported from the Maven POM - and try to avoid committing IntelliJ project files into source-control.
Hope that helps!
See Getting Started with the maven-android-plugin.
Here the command you can use to create an sampe working template with Maven structure:
mvn archetype:generate \
-DarchetypeArtifactId=android-with-test \
-DarchetypeGroupId=de.akquinet.android.archetypes \
-DarchetypeVersion=1.1.0 \
-DgroupId=com.foo.bar \
-DartifactId=my-android-project \
-Dpackage=com.foo.bar.android
BTW, IntelliJ has built in support for maven, so just open pom.xml from it - and everything will be ok.

Categories

Resources