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

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/

Related

unable to to run bazel build command

I m trying to execute handtracking android app using bazel and when I run the build command I get this error :
can you help me fix it please
ERROR: C:/users/admin/mediapipe_repo/mediapipe/mediapipe/framework/formats/BUILD:251:24: C++ compilation of rule '//mediapipe/framework/formats:landmark_cc_proto' failed (Exit 1): clang fai
led: error executing command external/androidndk/ndk/toolchains/llvm/prebuilt/windows-x86_64/bin/clang -gcc-toolchain external/androidndk/ndk/toolchains/aarch64-linux-android-4.9/prebuilt/w
indows-x86_64 -target ... (remaining 57 argument(s) skipped)
clang: error: no such file or directory: '/w'
clang: error: no such file or directory: '/D_USE_MATH_DEFINES'
clang: error: no such file or directory: '/std:c++17'
Target //mediapipe/examples/android/src/java/com/google/mediapipe/apps/handtrackinggpu:handtrackinggpu failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 151.344s, Critical Path: 132.86s
INFO: 160 processes: 128 internal, 31 local, 1 worker.
FAILED: Build did NOT complete successfully
There is a note in the Mediapipe documentation:
Note: building MediaPipe Android apps is still not possible on native Windows. Please do this in WSL instead and see the WSL setup instruction in the next section.
This implies that what you are trying to do is currently not possible, sorry. See also this issue for other people in your situation.

Build failing when running an Android app with Bazel

I am trying to follow a tutorial to build an Android app using Bazel as given here:
https://docs.bazel.build/versions/master/tutorial/android-app.html. The app is being built successfully with the command:
bazel build //src/main:app
However, when I try to run the app using the command bazel mobile-install //src/main:app the build is failing with the following error:
INFO: Analyzed target //src/main:app (0 packages loaded, 0 targets configured).
INFO: Found 1 target...
ERROR: /Users/kanzashaikh/examples/android/tutorial/src/main/BUILD:1:15: Installing //src/main:app failed: (Exit 1): incremental_install failed: error executing command bazel-out/darwin-py2-opt-exec-2B5CBBC6/bin/external/bazel_tools/tools/android/incremental_install --output_marker bazel-out/darwin-fastbuild/bin/src/main/app_files/full_deploy_marker --dexmanifest ... (remaining 11 argument(s) skipped)
Traceback (most recent call last):
File "/private/var/tmp/_bazel_kanzashaikh/df06cea5303c222cca918b7a24c9d8ca/execroot/main/bazel-out/darwin-py2-opt-exec-2B5CBBC6/bin/external/bazel_tools/tools/android/incremental_install.runfiles/bazel_tools/tools/android/incremental_install.py", line 25, in
from concurrent import futures
ImportError: No module named concurrent
Target //src/main:app failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 0.311s, Critical Path: 0.19s
INFO: 3 processes: 3 internal.
FAILED: Build did NOT complete successfully
How to solve this issue?
It looks like bazel is using python2 (the py2 from darwin-py2-opt-exec-2B5CBBC6 from the file paths), but from concurrent import futures in incremental_install.py doesn't work in python2.
If you don't have python3 installed, try installing it and seeing if that fixes the problem.
If you do have python3 installed, then check your bazel version, older versions of bazel might be defaulting to python2.

Ionic2 - Android build failed

I was trying to build an Ionic2 app with Android platform on my Win 7 (32 bt) system.
I ran the ionic build android command in the CLI and the following error occurred :
...ionic build android
> ionic-hello-world# ionic:build D:\<path>
> ionic-app-scripts build
[20:12:32] ionic-app-scripts 1.0.0
[20:12:32] build dev started ...
[20:12:32] clean started ...
[20:12:32] clean finished in 10 ms
[20:12:32] copy started ...
[20:12:32] transpile started ...
[20:12:37] transpile finished in 5.47 s
[20:12:37] webpack started ...
[20:12:38] copy finished in 5.74 s
[20:12:49] webpack finished in 11.84 s
[20:12:49] sass started ...
[20:12:52] sass finished in 2.81 s
[20:12:52] build dev finished in 20.16 s
[20:12:58] tslint: D:/../src/app/app.component.ts, line: 3
Unused import: 'OneSignal'
L2: import { Platform } from 'ionic-angular';
L3: import { StatusBar, Splashscreen, OneSignal } from 'ionic-native';
ANDROID_HOME=C:\Users\<user-name>\AppData\Local\Android\android-sdk
JAVA_HOME=C:\Program Files\Java\jdk1.8.0_60
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
Then as suggested I read the 'https://docs.gradle.org/2.14.1/userguide/gradle_daemon.html' and created the gradle.properties file with the following
org.gradle.daemon=true
The error still persists with the same result !!!
What is going wrong ?? Please help .
Found the solution after a hour long R&D.
Basically as per 'https://cordova.apache.org/docs/en/latest/guide/platforms/android/' - As of cordova-android#4.0.0, Cordova for Android projects are built using Gradle. Earlier it was built using Apache Ant.
Now Gradle looks for latest Android SDK. When I removed the android platform and added again with ionic platform add android command - the CLI listed that the latest Android SDK ( in my case it was SDK 24 ) was not installed.
I installed the required SDK version using Android SDK Manager and subsequent add of Android Platform along with the cordova plugin smoothly installed without any error.
The CLI printed the following -
..ionic plugin add onesignal-cordova-plugin
Fetching plugin "onesignal-cordova-plugin" via npm
Installing "onesignal-cordova-plugin" for android
ANDROID_HOME=C:\Program Files (x86)\Android\android-sdk
JAVA_HOME=C:\Program Files\Java\jdk1.8.0_121
Subproject Path: CordovaLib
Incremental java compilation is an incubating feature.
:clean
:CordovaLib:clean
BUILD SUCCESSFUL
Total time: 1.611 secs
Subproject Path: CordovaLib
Try using cordova platform add https://github.com/apache/cordova-android
Ive had to start using this command ever since updating Ionic.

Cannot build cordova project successfully error while executing ant debug command

I was having an error that is Camera not successful invoked on first try (click) so I tried this solution on stackoverflow Phonegap(3.0.0) Camera not successful on first try.
I followed the steps as mentioned in the answer removed android by cordova platform remove android then I run the second command cordova platform add android ;
Now when I use netbeans to run the cordova application on cordova android decvice this error occurs:
exec: ant debug -f "/var/www/mobile/platforms/android/build.xml"
[ 'ant debug -f "/var/www/mobile/platforms/android/build.xml"',
{ [Error: Command failed:
BUILD FAILED
/var/www/adt-bundle-linux-x86_64-20130917/sdk/tools/ant/build.xml:720: The following error occurred while executing this line:
/var/www/adt-bundle-linux-x86_64-20130917/sdk/tools/ant/build.xml:734: Compile failed; see the compiler error output for details.
Total time: 8 seconds
] killed: false, code: 1, signal: null },
'Buildfile: /var/www/mobile/platforms/android/build.xml\n\n-set-mode-check:\n\n-set-debug-files:\n\n-check-env:\n [checkenv] Android SDK Tools Revision 22.3.0\n [checkenv]
.
.
.**LONG TEXT which I removed from the post **
.
\nBUILD FAILED\n/var/www/adt-bundle-linux-x86_64-20130917/sdk/tools/ant/build.xml:720:
The following error occurred while executing this line:\n/var/www/adt-bundle-linux-x86_64- 20130917/sdk/tools/ant/build.xml:734:
Compile failed; see the compiler error output for details.\n\nTotal time: 8 seconds\n' ]
Error executing "ant debug -f "/var/www/mobile/platforms/android/build.xml"":
BUILD FAILED
/var/www/adt-bundle-linux-x86_64-20130917/sdk/tools/ant/build.xml:720: The following error occurred while executing this line:
/var/www/adt-bundle-linux-x86_64-20130917/sdk/tools/ant/build.xml:734: Compile failed; see the compiler error output for details.
Total time: 8 seconds
child_process.spawn(/var/www/mobile/platforms/android/cordova/build,[]) = 2
/usr/local/lib/node_modules/cordova/node_modules/q/q.js:126
throw e;
Error: An error occurred while building the android project.Error executing "ant debug -f "/var/www/mobile/platforms/android/build.xml"":
BUILD FAILED
/var/www/adt-bundle-linux-x86_64-20130917/sdk/tools/ant/build.xml:720: The following error occurred while executing this line:
/var/www/adt-bundle-linux-x86_64-20130917/sdk/tools/ant/build.xml:734: Compile failed; see the compiler error output for details.
Total time: 8 seconds
at ChildProcess.<anonymous> (/usr/local/lib/node_modules/cordova/src/compile.js:65:22)
at ChildProcess.EventEmitter.emit (events.js:98:17)
at maybeClose (child_process.js:735:16)
at Socket.<anonymous> (child_process.js:948:11)
at Socket.EventEmitter.emit (events.js:95:17)
at Pipe.close (net.js:466:12)
/var/www/mobile/nbproject/build.xml:256: exec returned: 8
BUILD FAILED (total time: 4 minutes 36 seconds)
any idea about this problem?
I was having a similar issue. I ran ant debug -f "/path/to/project/build.xml" from a separate terminal. It displayed a more specific description of the error (which for me wast that there was a space in the project name). This answer also notes:
config.xml can't have a widget id with number as a first character
after a dot. For example: com.42myapp.test or com.myapp.42test won't
work as well as 42com.myapp.test. It will trigger an error from the
compiler.
I was facing similar issues when i started using the CLI to build apps using cordova and started checking the internet for solutions. While i was at it, i discovered the following things that may help you or anyone else facing the same problem can take some hints from this:
These are some very basic checks that you need to take
1. make sure you have all the required sdk's in place (ANT, Java, Android) and is available when you use these commands on the terminal/command $ ant $ java $ adt. if any of these commands are not found, then you need to get it installed or get the class paths fixed.
make sure your project path does not have spaces. i.e. do not have spaces or special characters in directory names. this issue seems to have been fixed on latest versions of cordova and phonegap, but either cases it is a good practice to follow as ant and java paths could be dependent on the folder names you make.
use -d or -v to get extra debug information on the build process to know where and what is causing the issue. $ cordova build android -d or $ cordova build android -v
Make sure you dont use "#" as the link attribute of author tag in the cordova config.xml on the root of the project. This expects the compiler to interpret a hexadecimal color and fails the build. (this was my problem)
Hope this helps.
er... Happy debugging??
Make sure your Ant is 1.8.0 or later version. Cordova 3.3 demands that.
In the past several days, I found that the conflicting files from Dropbox had a very long name. After renaming it, everything worked.

scala-android plugin

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).

Categories

Resources