Netbeans 8.1, Gluon Project Android Error - android

I'm using Netbeans 8.1, with gluon and nbandroid plugins, on Windows 8.1, and when I create a gluon basic project i can't run on Android platform, the error are about ANDROID_HOME, in the last two days I have searched a lot about it but all the tries I have made don't help.
Here is the error:
Caused by: org.gradle.internal.exceptions.LocationAwareException: ANDROID_HOME not specified. Either set it as a gradle property, a system environment variable or directly in your build.gradle by setting the extension jfxmobile.android.androidSdk.
Caused by: org.gradle.api.GradleException: ANDROID_HOME not specified. Either set it as a gradle property, a system environment variable or directly in your build.gradle by setting the extension jfxmobile.android.androidSdk.
I tried the sample project from gluon, and the error still appears, but if I create an Android project (nbandroid, not gluon) and run it, everything is ok.
I see same difference from other questions on the project, when I create a gluon basic project automatically a Android project is created, but i don't see that on a lot of movies i watch on Youtube.
Can anyone help me, please? If more data is needed, I can upload it.

You can have a look at the JavaFXPorts documentation on the prerequisites to get started.
There are several options on how to set ANDROID_HOME. Basically:
Define the androidSdk property under jfxmobile.android in build.gradle:
jfxmobile {
android {
manifest = 'src/android/AndroidManifest.xml'
androidSdk = 'C:/<path to>/Android/sdk'
}
}
Or create a file named grade.properties, and place it in your local gradle folder (C:/Users/<user>/.gradle), adding this property:
ANDROID_HOME=C:/<path to>/Android/sdk
If you use the second option, you won't need to take care of adding it all the time on new projects.
Also you will find this local file added on your NetBeans projects, in a Gradle Home folder:

Related

Need help setting up RoboSpock

I want to use RoboSpock for Testing my android apps, but I am stuck setting up my project. I created an example project which I have added to github.
https://github.com/DerSchimi/RoboSpockExample
This project contains a folder called AppLibrary which is an android-library. The App itself is inside the folder App.
All RoboSpock Tests should go inside the folder AppTests. I have configured everything, but when I try to run my tests I get this error message:
WARNING: no system properties value for ro.build.date.utc
groovy.lang.MissingPropertyException: No such property: AppActivity for class: de.derschimi.app.MainActivitySpecification
at de.derschimi.app.MainActivitySpecification.Should say hello world(MainActivitySpecification.groovy:15)
This is the line of code:
def mainActivity = Robolectric.buildActivity(AppActivity.class).create().get()
Is there anybody out there who is using RoboSpock? Thanks a lot for your help!
The plugin I consider as deprecated. At this moment I'm creating just samples how to enforce gradle java plugin understand the android one. I suggest to browse this project.
https://github.com/pjakubczyk/robospock-sample/tree/master/simple

Gradle execution fails: Unknown command-line option '--daemon'

I use latest Android Studio (0.8.2). On my other PC the same code is successfully builded.
It means that build scripts are correct.
So I assume that it is something with Gradle configuration, but I double rechecked all configs:
I completely removed .gradle folder under C:\Windows\Users{MyUser}.gradle to delete old configurations;
gradle.properties file doesn`t have any uncommented options
What do I miss?
NOTE! I have not specified '--daemon' option. Or I only think so:( I can`t find it in Gradle default and project specific settings
Also I created absolutely new project in the studio. It didn`t help - the same error(
The answer is very simple. It seems that new version of Android studio imported all setting from previous one. Some of old options added additional options to compiler
Android Studio always uses a Gradle daemon. It connects to the daemon via the Gradle Tooling API, and perhaps the latter doesn't understand --daemon (because it's redundant).

Integrate new relic sdk into a non-gradle project in android studio

I am trying to integrate new relic SDK into my app, and the problem is that the code is old and wasn't ported to gradle and we don't have time to port it. So when we try to add the new relic sdk into the project structure as a library is not working and it's throwing me an error that I can't get any feedback, the error is the following.
Failed to detect New Relic instrumentation. Something likely went wrong during your build process and you should contact support#newrelic.com.
NewRelic provides a video on their page for proper import in ADT/Eclipse. It is available on this page: https://docs.newrelic.com/docs/mobile-apps/android-installation-and-configuration
Generally, after adding a .jar to your library directory, you must set your build path correctly. Right click on your project, select Build Path -> Configure Build Path and make sure that the .jar appears in the Libraries tab and that it is checked in the Order and Export tab.
Anyways, regarding about the problem of not been able to build in android studio is fixed, but also I were able to import my code to eclipse and make it run and after that I make it work also in android studio without gradle. I have submitted a ticket to new relic just in case they are willing to create a new tutorial for people, like me, that are not using gradle an make it work in android studio.
This is the important line:
-javaagent:/path/to/newrelic-android-3.330.0/lib/class.rewriter.jar
you have to add this into your compilation parameters, and the only way to do it is through the preference of the android studio, instead of your project preference.
Try to find a way to add this command only for when we are building this project and not other ones. Let see.

Environment variable in settings.gradle not working with Android Studio

I do have a multi-module project with a library project in a different root path. As illustration you can imagine something like this:
/projects_home/projects/app_root
|--app/
| |--build.gradle
|--build.gradle
|--settings.gradle
/libraries_home/libraries
|--libA
|--build.gradle
In my settings.gradle file I am able to set the absolute path to the library project utilizing the projectDir attribute. This works just fine within the console as well as with Android Studio.
But if I try to use an environment variable it stops working with Android Studio. The settings.gradle for the example above would look like this:
include ':app'
include ':libA'
project(':libA').projectDir = new File("$System.env.LIB_ROOT", '/libraries/libA')
If I build with the graddle wrapper from the console, it still works. But AS stops working with the following error msg:
Gradle 'app' project refresh failed:
Configuration with name 'default' not found.
If I unset the environment variable, the build on console fails with the same msg:
* What went wrong:
A problem occurred configuring project ':app'.
> Configuration with name 'default' not found.
Therefore I guess that AS is somehow not be able to access the environment variables set with my ~/.bashrc
Does somebody of you maybe know a way how I can make AS aware of my environment?
Android Studio does read the environment variables. You can prove it by launching Android Studio from the shell in which those env. variables being specified instead of from X-window dash board.
The reason you did not have those variables is the X-window environment you were using did not read $HOME/.bashrc which contained those variables. This makes sense because bashrc is for Bash not X.
Assuming you are using GNOME or Unity, to launch Android Studio with those environment variables being specified, just modify the .desktop file of Android Studio (e.g. ~/.local/share/applications/android-studio.desktop):
Find this line:
Exec="/home/username/tools/android/android-studio/bin/studio.sh" %f
Change it to:
Exec=env LIB_ROOT=/libraries_home "/home/username/tools/android/android-studio/bin/studio.sh" %f
Note:
This modification just prepend env LIB_ROOT=/libraries_home to the original command. You must replace username with your own user name.
Update
If you have any questions, please leave a comment instead of editing the answer directly.
On Macs, Android Studio does not read environment variables for use in Gradle apparently. I believe this is the cause for confusion in the answers here - maybe it does on Windows.
In order to get Android Studio to read environment variables, I run the application from the command line:
> /Applications/Android\ Studio.app/Contents/MacOS/studio
The other answers here offer solutions other than using environment variables. For my situation, I'm using a library I didn't write that requires the use of an environment variable, and I'd rather not edit their code so it's easier to update later.
EDIT: And, I have a dock icon to launch Android Studio this way:
OSX: Add Dock icon for dedicated Terminal command explains how.
Android Studio doesn't read environment variables, so this approach won't work. Also, using the projectDir scheme in settings.gradle will probably cause problems. Android Studio has a limitation that all of its modules need to be located underneath the project root. If you have libraries that are used in multiple projects and they can't be placed under a single project root, the best advice is to have them publish JARs or AARs to a local Maven repository that individual projects can pick up.
Despite the answer from Scott Barta is correct, I realized there is a way to solve my problem and wan't to share this in case somebody else has the same requirement.
I am now using the gradle.properties file do define and use gradle properties instead of system properties. The documentation of this feature can be fined in the user guide
The solution to my original question now looks like this:
$USER_HOME/.gradle/gradle.properties:
LIB_ROOT=/libraries_home
The settings.gradle file has to be modified to use the gradle property instead of the system property:
include ':app'
include ':libA'
project(':libA').projectDir = new File(LIB_ROOT, '/libraries/libA')
This works fine for me, headless as well as with AS.
Some more words regarding the fact that I am working with modules which are not placed underneath one project root. Till now it looks like AS is not complaining about this. But I just started working with this structure and it may be that I will run into problems later. What I like about this is the more flat representation in AS which is more like I am used to have it with Eclipse.
What is also described in the user guide, is to set system properties with the gradle.properties file. I tried this also, but I did run into the same problems with AS using environment variables.
It works for me with the following steps:
Set your variable in Windows
Reboot
reach it in gradle build: System.env.MYVARIABLE
I faced the same issue in apple laptop after the Android Studio Bumblebee update. This seems to be happening due to some permission issue with the Android Studio.
The workaround is to add missing flag:
chmod +x /Applications/Android\ Studio.app/Contents/bin/printenv
You can check this issue tracker for more details.
You can set environment variable by appending:
-DYOUR_VARIABLE=variable_value
to ~/Library/Preferences/AndroidStudioX.X/studio.vmoptions that you can open by selecting Help -> Edit Custom VM Options... from Android Studio menu.
And then you can use it like:
System.env.YOUR_VARIABLE
in build.gradle or settings.gradle.
MAC OS Update
I confirm that I have Environmental Variables working on Mac OS Catalina
You just need to set it in the shell you are using. I was using zsh, and was trying to set ~/.bash_profile, so it wasn't working.
Example:
ZSH Profile

What could be causing the "OutputPath property is not set for project ProjectName.csproj" error in my MonoDevelop project

On Windows 7 (64 bit) with the Android SDK working perfectly with Eclipse - my first android application, using the first "Hello World" sample (found here - http://docs.xamarin.com/android/getting_started/hello_world - from Xamarin)
fails with the error "the OutputPath property who is not set for project NameProject.csproj".
I have tried re-runing the installation program from Xamarin and this error still occurs.
Could someone please suggest what may be causing this problem?
Thanks a lot.
the exact error:
C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(9,9):
Error: The OutputPath property is not set for project 'helloWorld3.csproj'.
Please check to make sure that you have specified a valid combination of
Configuration and Platform for this project.
Configuration='Debug'
Platform='BPC'.
This error may also appear if some other project is trying to follow a
project-to-project reference to this project, this project has been
unloaded or is not included in the solution, and the referencing project
does not build using the same or an equivalent Configuration or Platform.
(helloWorld3)
I think we've seen this before. Your system manufacturer installed an environment variable called Platform onto your system. This breaks all msbuild based stuff, since msbuild automatically imports that as $(Platform), conflicting with the real $(Platform) that msbuild uses to compile.
Try removing the environment variable and try again.

Categories

Resources