scala-android plugin - android

I'm having problems running the scala-android plugin when running sbt from inside IntelliJ. When I run sbt for the same project from Mac terminal I get no errors:
~/Documents/my-android-project $ sbt
[info] Loading global plugins from /Users/rgoodwin/.sbt/plugins
[info] Loading project definition from /Users/rgoodwin/Documents/my-android-project/project
[info] Set current project to (in build file:/Users/rgoodwin/Documents/my-android-project/)
But when I try to run sbt from IntelliJ I get:
[info] Loading global plugins from /Users/rgoodwin/.sbt/plugins
[info] Loading project definition from /Users/rgoodwin/Documents/my-android-project/project
[error] Android SDK not found. You might need to set ANDROID_SDK_HOME or ANDROID_SDK_ROOT or ANDROID_HOME
[error] Use 'last' for the full log.
Project loading failed: (r)etry, (q)uit, (l)ast, or (i)gnore?
Why doesn't sbt inside of IntelliJ pick up the Path names I have set?

I think that you have probably set ANDROID_SDK_HOME in your .bashrc file so this property is set when you run sbt.
When you run Intellij, you don't launch it from command line so the ANDROID_SDK_HOME is not defined when you run sbt from Intellij.
For MacOS, I think that you can set global environment variables (take a look at http://developer.apple.com/library/mac/#documentation/MacOSX/Conceptual/BPRuntimeConfig/Articles/EnvironmentVars.html).

Related

Node.js process with a non-zero exit code [duplicate]

I am new to cordova and am trying to create an android HelloWold project.
When I use cordova platforms add android, it throws some exception:
D:\CordovaSpace\helloWorld>cordova platforms add android
Adding android project...
Creating Cordova project for the Android platform:
Path: platforms\android
Package: com.example.helloworld
Name: HelloWorld
Activity: MainActivity
Android target: android-24
Subproject Path: CordovaLib
Android project created with cordova-android#6.0.0
Installing "cordova-plugin-whitelist" for android
ANDROID_HOME=D:\Java_Android_SDK\android_sdk
JAVA_HOME=C:\Program Files (x86)\Java\jdk1.8.0_73
Subproject Path: CordovaLib
Starting a new Gradle Daemon for this build (subsequent builds will be faster).
FAILURE: Build failed with an exception.
* What went wrong:
Unable to start the daemon process.
This problem might be caused by incorrect configuration of the daemon.
For example, an unrecognized jvm option is used.
Please refer to the user guide chapter on the daemon at https://docs.gradle.org/2.14.1/userguide/gradle_daemon.html
Please read the following process output to find out more:
-----------------------
Error occurred during initialization of VM
Could not reserve enough space for 2097152KB object heap
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
Failed to install 'cordova-plugin-whitelist':Error: cmd: Command failed with exit code 1
at ChildProcess.whenDone (D:\CordovaSpace\helloWorld\platforms\android\cordova\node_modules\cordova-common\src\superspawn.js:169:23)
at emitTwo (events.js:106:13)
at ChildProcess.emit (events.js:191:7)
at maybeClose (internal/child_process.js:850:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:215:5)
Error: cmd: Command failed with exit code 1
Try again after increasing your Java VM(?) memory size.
Here is how to fix it on a Windows platform:
Go to Start -> Control Panel -> System -> Advanced(tab) -> Environment Variables -> System Variables -> New:
Variable name: _JAVA_OPTIONS
Variable value: -Xmx512M
Don't ignore the score and underscore characters.
I had the exact same problem. I switched to use 64-bit JDK as suggested in here and it worked fine. I was using Ionic 3.5.0 on Windows 10.
this worked for my ionic app.
Change line on
// to allow dex in process
'org.gradle.jvmargs': '-Xmx1024m',
from
// to allow dex in process
'org.gradle.jvmargs': '-Xmx2048m',
in your
<app path>\platforms\android\cordova\lib\config
thanks
args.push('-Dorg.gradle.jvmargs=-Xmx2048m')
into
args.push('-Dorg.gradle.jvmargs=-Xmx1024m');
on the following location files.
project-folder\platforms\android\cordova\lib\builders\GradleBuilder.js
project-folder\platforms\android\cordova\lib\builders\StudioBuilder.js
Go to : \platforms\android\cordova\lib\config\GradlePropertiesParser.js
constructor (platformDir) {
this._defaults = {
// 10 seconds -> 6 seconds
'org.gradle.daemon': 'true',
// to allow dex in process
'org.gradle.jvmargs': '-Xmx2048m',
// allow NDK to be used - required by Gradle 1.5 plugin
'android.useDeprecatedNdk': 'true'
// Shaves another 100ms, but produces a "try at own risk" warning. Not worth it (yet):
// 'org.gradle.parallel': 'true'
};
And change the 'org.gradle.jvmargs': '-Xmx2048m', to 'org.gradle.jvmargs': '-Xmx1024m',
args.push('-Dorg.gradle.jvmargs=-Xmx2048m')
to
args.push('-Dorg.gradle.jvmargs=-Xmx1024m');
on the following location files.
project-folder\platforms\android\cordova\lib\builders\builders.js
project-folder\platforms\android\cordova\lib\builders\GradleBuilder.js
project-folder\platforms\android\cordova\lib\builders\StudioBuilder.js
Go to Start -> Control Panel -> System -> Advanced(tab) -> Environment Variables -> System Variables
Add/change JAVA_HOME value
from C:\Program Files (x86)\Java\jdk1.8.0_192
to C:\Program Files\Java\jdk1.8.0_192
That is, change from Program Files (x86) path to Program Files path.
I had a same problem.
Anyway, here is how to fix it:
Go to Start->Control Panel->System->Advanced(tab)->Environment Variables->System Variables->New:
Variable name: _JAVA_OPTIONS
Variable value: -Xmx512M
if 512 not work then change it to.
Variable value: -Xmx1024M
And also change the path.
Variable name: Path
Variable value: ;C:\Program Files\Java\jre6\bin;F:\JDK\bin;
Change this to your appropriate path.
Setting the environment variable at system level as in the #kemal's solution will set the memory size for all the JVM applications in the system, which is not a what most would want to do.
Instead, set the heap size in your cordova gradlebuilder property file.
args.push('-Dorg.gradle.jvmargs=-Xmx2048m');

Android Error: Failed to find 'ANDROID_HOME' environment variable

I just started Android development with ionic framework on Linux (Ubuntu).
I successfully created my ionic project using the command:
sudo ionic start demo blank
Now to add the android platform to the project, I ran the command:
sudo ionic platform add android
And this is the result it gave me:
function bold() { [native code] } https://github.com/driftyco/ionic-default-resources/archive/master.zip
[=============================] 100% 0.0s
Adding android project...
Creating Cordova project for the Android platform:
Path: platforms/android
Package: com.ionicframework.demo504884
Name: demo
Activity: MainActivity
Android target: android-24
Subproject Path: CordovaLib
Android project created with cordova-android#6.0.0
ls: no such file or directory: /home/awa/Desktop/mobile/demo/res/mipmap-*
Installing "cordova-plugin-console" for android
Failed to install 'cordova-plugin-console':CordovaError: Failed to find 'ANDROID_HOME' environment variable. Try setting setting it manually.
Failed to find 'android' command in your 'PATH'. Try update your 'PATH' to include path to valid SDK directory.
at /home/awa/Desktop/mobile/demo/platforms/android/cordova/lib/check_reqs.js:222:19
at _fulfilled (/home/awa/Desktop/mobile/demo/platforms/android/cordova/node_modules/q/q.js:834:54)
at self.promiseDispatch.done (/home/awa/Desktop/mobile/demo/platforms/android/cordova/node_modules/q/q.js:863:30)
at Promise.promise.promiseDispatch (/home/awa/Desktop/mobile/demo/platforms/android/cordova/node_modules/q/q.js:796:13)
at /home/awa/Desktop/mobile/demo/platforms/android/cordova/node_modules/q/q.js:857:14
at runSingle (/home/awa/Desktop/mobile/demo/platforms/android/cordova/node_modules/q/q.js:137:13)
at flush (/home/awa/Desktop/mobile/demo/platforms/android/cordova/node_modules/q/q.js:125:13)
at _combinedTickCallback (internal/process/next_tick.js:67:7)
at process._tickCallback (internal/process/next_tick.js:98:9)
Error: Failed to find 'ANDROID_HOME' environment variable. Try setting setting it manually.
Failed to find 'android' command in your 'PATH'. Try update your 'PATH' to include path to valid SDK directory.
At first I doubted if it had successfully added the android platform so I ran the same command again (sudo platform add android) and it said platform already existed.
Now seeing the last section of the error, I set the ANDROID_HOME environment variable by putting this code at the end of my .bashrc file located my home directory.
export ANDROID_HOME=/home/awa/Android/Sdk
export PATH=$PATH:/home/awa/Android/Sdk/tools
export PATH=$PATH:/home/awa/Android/Sdk/platform-tools
I saved the file. In order to build my project, I ran the command:
sudo ionic build android
and it gave the error:
add to body class: platform-android
Error: Failed to find 'ANDROID_HOME' environment variable. Try setting setting it manually.
Failed to find 'android' command in your 'PATH'. Try update your 'PATH' to include path to valid SDK directory.
I verified again to make sure I had succeeded in setting the ANDROID_HOME environment variable correctly. So in the Command line I ran the command echo $ANDROID_HOME and it gave as output:
/home/awa/Android/Sdk
...which is the right directory for my SDK.
I have tried other solutions like setting the environment variables in the .profile file but nothing changed.
Now I am suspecting the problem may have something to do with my sdk version though I'm not entirely sure.
What am I doing wrong, or what I'm I missing?

Ar toolkit nftBook with android studio

How to solve artoolkit nftBook issues in android studio
When I run the command ndk-build in android studio terminal for nft book it shows the error like:
clang++.exe: error: linker command failed with exit code 1 (use -v to
see invocation) make: *** [obj/local/armeabi/libnftBookNative.so]
Error 1
How can I solve this?
You should not run it in the android studio terminal but in the Git-Bash.
Read the documentation more closely :).
You look like you are working from Windows so you need to use Git-Bash for compilation.
See: http://artoolkit.org/community/forums/viewtopic.php?f=26&t=17092
===========
EDIT:
Make sure you have these environment variables set:
- Set ANDROID_HOME to indicate the path to root folder of the downloaded Android SDK.
Set ANDROID_NDK_ROOT to indicate the path to root folder (most likely, “ndk-bundle”) of the downloaded NDK. The ANDROID_HOME environment variable can be used to help define NDK.
ANDROID_NDK_ROOT=$ANDROID_HOME/ndk-bundle
Set NDK to the same path as ANDROID_NDK_ROOT. NDK=$ANDROID_NDK_ROOT
Set PATH to include a path to the ndk-build[.cmd] script file, that is, the path to the root folder of the NDK. The NDK environment variable can be used to help define the added path.
Now start gitBash and navigate to your ARToolKit5_ROOT directory.
cd android
./build.sh
if successful
./build_native_examples.sh

ENOENT, no such file or directory - on building Android Cordova Project

I have created a Cordova Application Project using the CLI tool and NetBeans IDE for Cordova Project. I have also mapped the following path variables.
ANDROID_HOME F:\AndroidProjects\adt-bundle-windows-x86-20131030\
ANT_HOME C:\apache-ant-1.9.4\
JAVA_HOME C:\Program Files\Java\jdk1.8.0_25\
PATH C:\Users\Administrator\AppData\Roaming\npm;F:\Android Projects\adt-bundle-windows-x86-20131030\sdk\platform-tools\;F:\AndroidProjects\adt-bundle-windows-x86-20131030\SDK\TOOLS\;C:\Program Files\Java\jdk1.8.0_25\bin;%JAVA_HOME%\bin;C:\Program Files (x86)\Git\;C:\Program Files (x86)\Git\bin;%ANT_HOME%/bin;
I am also able to run the Demo Cordova Application on AVD and Real device,using eclipse. But, while trying to build the project with additional changes the CLI is giving me with the following error message
[Error: ANDROID_HOME is set to a non-existant path: F:\Android
Projects\adt-bund le-windows-x86-20131030] Command finished with error
code 2: F:\CordovaProjects\CordovaAppOne\platforms\a
ndroid\cordova\build.bat Error:
F:\CordovaProjects\CordovaAppOne\platforms\android\cordova\build.bat:
Com mand failed with exit code 2
at ChildProcess.whenDone (C:\Users\Administrator\AppData\Roaming\npm\node_mo
dules\cordova\node_modules\cordova-lib\src\cordova\superspawn.js:135:23)
at ChildProcess.emit (events.js:98:17)
at maybeClose (child_process.js:756:16)
at Process.ChildProcess._handle.onexit (child_process.js:823:5)
What should I set in addition to the above to resolve the error. I am using Windows8-64Bit on administrator account. Only Android platform has been added to the application using the CLI.
Issue has been resolved. The issue was raised due to wrong pointing of ANDROID_HOME environment variable. It is required that the variable directly points to sdk folder itself instead of the Android Eclipse bundle.

Unable to build Android+Scala project using sbt+sbt-android plugin

I can't build Android + Scala (and IntelliJ Idea 12) project using sbt and sbt-android plugin. I installed everything needed and added ANDROID_SDK_HOME to both .bashrc and /etc/profile but:
me123#ubuntu:~/Documents/android_projects/my-android-project$ echo $ANDROID_SDK_HOME
/home/me123/android-sdk-linux/sdk
me123#ubuntu:~/Documents/android_projects/my-android-project$ sudo echo $ANDROID_SDK_HOME
/home/me123/android-sdk-linux/sdk
me123#ubuntu:~/Documents/android_projects/my-android-project$ sbt
[info] Loading global plugins from /home/me123/.sbt/plugins
[info] Loading project definition from /home/me123/Documents/android_projects/my-android-project/project
[info] Compiling 3 Scala sources to /home/me123/Documents/android_projects/my-android-project/project/target/scala-2.9.2/sbt-0.12/classes...
[error] /home/me123/Documents/android_projects/my-android-project/project/target/scala-2.9.2/sbt-0.12/classes/AndroidEclipse$Transformer.class (Permission denied)
[error] one error found
[error] (compile:compile) Compilation failed
Project loading failed: (r)etry, (q)uit, (l)ast, or (i)gnore? q
me123#ubuntu:~/Documents/android_projects/my-android-project$ sudo sbt
[info] Loading project definition from /home/me123/Documents/android_projects/my-android-project/project
[info] Updating {file:/home/me123/Documents/android_projects/my-android-project/project/}default-6ff5da...
[info] Resolving org.scala-sbt#precompiled-2_10_0;0.12.2 ...
[info] Done updating.
[error] Android SDK not found. You might need to set ANDROID_SDK_HOME or ANDROID_SDK_ROOT or ANDROID_HOME
[error] Use 'last' for the full log.
Project loading failed: (r)etry, (q)uit, (l)ast, or (i)gnore? q
UPDATE:
> android:start-device
[info] Wrote /home/alex/Documents/android_projects/my-android-project/target/scala-2.10/src_managed/main/scala/my/android/project/TR.scala
[info] Compiling 2 Scala sources and 1 Java source to /home/alex/Documents/android_projects/my-android-project/target/scala-2.10/classes...
[warn] there were 4 feature warnings; re-run with -feature for details
[warn] one warning found
ProGuard, version 4.6
ProGuard is released under the GNU General Public License. You therefore
must ensure that programs that link to it (scala, ...)
carry the GNU General Public License as well. Alternatively, you can
apply for an exception with the author of ProGuard.
Reading program directory [/home/alex/Documents/android_projects/my-android-project/target/scala-2.10/classes]
[trace] Stack trace suppressed: run last main/android:proguard for the full output.
[error] (main/android:proguard) java.io.IOException: Can't read [/home/alex/Documents/android_projects/my-android-project/target/scala-2.10/classes] (Can't process class [my/android/project/R$id.class] (Unsupported version number [51.0] for class format))
[error] Total time: 14 s, completed May 30, 2013 3:49:46 PM
First, doing sudo echo $ANDROID_HOME will be exactly the same as echo $ANDROID_HOME, because the variable will be replaced by your shell before executing the command.
Then, you most likely have a permission problem. Try running this to make sure you have the right ones :
$ chmod -Rv 700 /home/me123/Documents/android_projects/my-android-project/

Categories

Resources