Ionic run android is not building apk - android

I shifted development of my ionic app from windows to ubuntu 14.04 now. I installed everything new. "Ionic build android" command is working but when i run "ionic run android" or "ionic emulate android" it only starts emulator no BUILD SUCCESS and LAUNCH SUCCESS is shown in console. Also app does not get installed in emulator.
ajeet#samsung:~/deployments/mobile_app/chmapp$ ionic run android
Native thread-sleep not available.
This will result in much slower performance, but it will still work.
You should re-install spawn-sync or upgrade to the lastest version of node if possible.
Check /usr/lib/node_modules/ionic/node_modules/ionic-app-lib/node_modules/cross-spawn/node_modules/spawn-sync/error.log for more details
Running command: /home/ajeet/deployments/mobile_app/chmapp/hooks/after_prepare/010_add_platform_class.js /home/ajeet/deployments/mobile_app/chmapp
add to body class: platform-android
ANDROID_HOME=/opt/android-sdk
JAVA_HOME=/usr/lib/jvm/default-java
No target specified, deploying to emulator
No emulator specified, defaulting to Nexus
Waiting for emulator...
sh: 1: glxinfo: not found
sh: 1: glxinfo: not found
emulator: WARNING: VM heap size set below hardware specified minimum of 256MB
emulator: WARNING: Setting VM heap size to 512MB
console on port 5554, ADB on port 5555

As discussed in comments.
Keep the emulator running first and then execute. Invoking the emulator at runtime often leads to timeout.

Run this command, it will show the missing things
npm list
would shows you need "try-thread-sleep" to use spawn-sync.
So, add bellow in your "package.json" and "npm install" again.
"try-thread-sleep": "^1.0.0".
Hope it will help. copied.

you need to install emulator in Ubuntu then only you can able to see the output in emulator

Related

cordova emulate android stuck in loading forever in CMD

The info I suppose would be useful to you:
cordova its version command tells me I have the following version: 9.0.0 (cordova-lib#9.0.1)
The emulator I use: Pixel 2 API_29
I start my emulator through the AVD manager (android studio)
How I start the emulator: cordova emulate android
So, when I use CMD to start my application, it basically ends up with loading dots.
Sometimes the launch etc. is successful, but sometimes, out of nowhere, it keeps on loading, but the launch is never successful.
The build is: success, the launch and deployment however fails.
The loading looks like this in cmd:
...................................................
but it never starts the application.
To give you an idea of how it looks:
(...) //above this line there is info about the build etc.
BUILD SUCCESSFUL in 8s
42 actionable tasks: 42 up-to-date
Built the following apk(s):
C:\Users\gamek\hexadecimal\platforms\android\app\build\outputs\apk\debug\app-debug.apk
Checking Java JDK and Android SDK versions
ANDROID_SDK_ROOT=undefined (recommended setting)
ANDROID_HOME=C:\Users\gamek\AppData\Local\Android\sdk (DEPRECATED)
..............................................................................
The desired behavior I am looking for:
Not have to live in fear whether the application will start in the emulator or not.
I want the application to start in the emulator when I run the command:
cordova emulate android
You can either:
Check that the emulator memory requirements are not too excessive for your system's resources (lower RAM allocated for example, but not below 1024 MB)
Start the emulator manually immediately after booting
Don't close the emulator anymore, leave it running so you can deploy without issues
More Android emulator tips here, make sure you have installed Intel HAXM if you have an Intel processor, or enabled Windows Hypervisor Platform in Windows Features if you have AMD.

Visual Studio Code IDE returns error when attempt to debug React Native project: Could not find device with the id: "simulator"

My environment.
Windows 10 with Android SDK and AVD Manager and VS Code 1.26.1
Android Nexus S simulator with SDK API 23 Android 6.0 x86_64
react-native: 0.55.4
Problem:
I am failing to debug my sample app.js in Visual Studio Code IDE and fail to stop at any breakpoint.
I have AVD emulator running and when I simply run my simple project, the simulator loads it without issues. So, I do not see a problem with my project.
I also can execute “react-native run-android” in Terminal window of VS Code IDE and it returns success, for example:
BUILD SUCCESSFUL Total time: 10.283 secs Running
C:\Users\myusername\AppData\Local\Android\Sdk/platform-tools/adb -s
emulator-5554 reverse tcp:8081 tcp:8081 Starting the app on
emulator-5554
(C:\Users\myusername\AppData\Local\Android\Sdk/platform-tools/adb -s
emulator-5554 shell am start -n
com.vscodereactdebug3/com.vscodereactdebug3.MainActivity)... Starting:
Intent { cmp=com.vscodereactdebug3/.MainActivity }
However, when I attempt to debug it through Visual Studio IDE (Debug/Start Debugging), the Debug Console shows the following:
OS: win32 x64 Adapter node: v8.9.3 x64 vscode-chrome-debug-core: 3.17.3 Could not debug. Unknown error: not all success patterns were matched. It means that "react-native run-android" command failed.
Please, check the View -> Toggle Output -> React Native, View ->
Toggle Output -> React Native: Run android output windows.
So, below is output from React Native: Run Android:
[Warning] Target simulator is not supported for Android platform. If you want to use particular device or simulator for launching Android
app, please specify device id (as in 'adb devices' output)
instead. [Info] local.properties file doesn't exist. Using
Android SDK location from PATH. [Info] Starting React Native
Packager. [Info] Attaching to running React Native
packager Scanning folders for symlinks in
e:\Software\Android\VSCodeReactDebug3\node_modules (20ms) Could not
find device with the id: "simulator". Choose one of the
following: [ 'emulator-5554' ]
I searched forums for the greater wisdom and saw a few posts related to this erratic behavior but those, while sharing good troubleshooting clues, did not solve my problem:
https://github.com/Microsoft/vscode-react-native/issues/624
My project is very simple, almost empty few liners. So, very likely the problem is with my environment, but I cannot find anything that could explain it. I do not recall assigning ID “simulator” to anything. And do not know where it is controlled.
Any ideas are greatly appreciated.
Update.
Today I came across of post React Native debug with Visual Studio Code not working
and attempted uninstalling react-native package and installing react-native-cli. I literally ran following commands in that sequence to use create-react-native-app:
npm install react-native --global
npm uninstall -g react-native
npm install -g react-native-cli
So, now the IDE debugs and stops on breakpoints as before.
I am yet to learn what happened and why my other project suddenly stopped being debugged. I, perhaps, broke my environment attempting to recover from some other problem.
And I still cannot explain the error related to "Could not find device with the id: "simulator"" in the Debug output.

Can't get React Native to work on Ubuntu

I am trying to get React Native running on Ubuntu 16.04. I have used it with create-react-native-app and expo on my Windows machine with both the Android Studio virtual device and a tablet connected by USB. Now I have a new Ubuntu laptop and a Ubuntu dual boot on my PC and am trying to set it up there but have failed miserably.
Let's deal with the laptop. Following the instructions, I have installed Expo and Genymotion. Expo could never work right so now I'm just trying to get it going more directly. I have also installed Java 8 and watchman. I've installed and tried too many things to mention. I've put in about 20 hours so far.
Here is what happens when I try to start things.
If I plug in my tablet, I get:
kevin#kevin-Kudu:~/programming/rn4$ adb devices
adb server is out of date. killing...
* daemon started successfully *
List of devices attached
5205132d4f9011af device
(As a side note, it seems that my adb server is always out of date.) When I try to run the default code installed by react-native-cli by running react-native run-android, I get:
kevin#kevin-Kudu:~/programming/rn4$ react-native run-android
Scanning folders for symlinks in /home/kevin/programming/rn4/node_modules (9ms)
Starting JS server...
Building and installing the app on the device (cd android && ./gradlew installDebug)...
Error occurred during initialization of VM
java/lang/NoClassDefFoundError: java/lang/Object
Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/getting-started.html
I've researched these errors and can't find a solution that works.
If I start an Android Studio virtual device (N6, API 23), it starts up. adb devices gets me:
kevin#kevin-Kudu:~/programming/rn4$ adb devices
adb server is out of date. killing...
* daemon started successfully *
List of devices attached
5205132d4f9011af device
When I try to run the app:
kevin#kevin-Kudu:~/programming/rn4$ react-native run-android
Scanning folders for symlinks in /home/kevin/programming/rn4/node_modules (9ms)
Starting JS server...
Building and installing the app on the device (cd android && ./gradlew installDebug)...
Error occurred during initialization of VM
java/lang/NoClassDefFoundError: java/lang/Object
Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/getting-started.html
Again, I haven't been apple to find a solution.
When I try to do the same thing through genymotion and do adb devices, I get:
kevin#kevin-Kudu:~/programming/rn4$ adb devices
adb server is out of date. killing...
cannot bind 'tcp:5037'
ADB server didn't ACK
* failed to start daemon *
error:
I get the same result when I try to run the app.
Any ideas what I should try next? Please bear in mind that I am still fairly new to linux so please be specific. If you tell me, "Simply change the RX74 constant in the Fetzer config file" I'm not going to have any idea what you are talking about. (I've had bad experiences with linux advice that assumes that I know what every file on the system is and where to find it.)
Thanx in advance.
ADDENDUM 1 #Vigas Deep:
When I check which -a adb:
kevin#kevin-Kudu:~$ which -a adb
/usr/bin/adb
/usr/bin/adb
/home/kevin/Android/Sdk/platform-tools/adb
So I have more than one. I'll figure out why one is getting called twice, for now I just rename it, and now I get:
kevin#kevin-Kudu:~$ which -a adb
/home/kevin/Android/Sdk/platform-tools/adb
I fire up the Android Studio virtual device and check it:
kevin#kevin-Kudu:~$ adb devices
List of devices attached
emulator-5554 device
And when I try to run a RN starter app:
kevin#kevin-Kudu:~/programming/rn4$ react-native run-android
Scanning folders for symlinks in /home/kevin/programming/rn4/node_modules (18ms)
Starting JS server...
Building and installing the app on the device (cd android && ./gradlew installDebug)...
Error occurred during initialization of VM
java/lang/NoClassDefFoundError: java/lang/Object
Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/getting-started.html
Interestingly, when I try to restart the adb server, I get:
kevin#kevin-Kudu:~/programming/rn4$ sudo adb kill-server && adb start-server
[sudo] password for kevin:
sudo: adb: command not found
Does the adb in the SDK not have those commands?
Just for kicks, I reboot and try pluggin in a tablet:
kevin#kevin-Kudu:~$ adb devices
List of devices attached
5205132d4f9011af device
(But for some reason only shows up when plugged into the USB2 port, very inconveniently located.)
When I try to run the RN project:
kevin#kevin-Kudu:~/programming/rn4$ react-native run-android
Scanning folders for symlinks in /home/kevin/programming/rn4/node_modules (21ms)
Starting JS server...
Building and installing the app on the device (cd android && ./gradlew installDebug)...
Error occurred during initialization of VM
java/lang/NoClassDefFoundError: java/lang/Object
Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/getting-started.html
Sorry, that's all the testing I can do for now. Any other ideas?
ADDENDUM 2 #Vigas Deep:
"just to make sure that its using the adb located inside sdk; use this command for now: /home/kevin/Android/Sdk/platform-tools/adb devices"
OK, I get the same result whichever I use.
"and do not use sudo for adb command because we are not going to run react-native run-android as sudo."
OK. All the examples I saw used sudo to start and kill the adb server. Strangely, now it works without sudo but not with. Before, I think it was the opposite, but I haven't tried it without in a long time so I can't be sure.
"Also; are you using openJDK or oracleJDK ; how did you install the JDK?"
I thought I remembered going to the Oracle site, but when I do "java -version", I get:
kevin#kevin-Kudu:~/programming/rn4$ java -version
java version "1.7.0_95"
OpenJDK Runtime Environment (IcedTea 2.6.4) (7u95-2.6.4-3)
OpenJDK 64-Bit Server VM (build 24.95-b01, mixed mode)
This would seem to indicate otherwise. Should I change it?
ADDENDUM 3 #Vigas Deep:
OK, I looked up how to remove openjdk and followed it. I found instructions about how to install the jdk8, just to be sure. I am getting the same error when I try to run the RN app. When I check java -version:
kevin#kevin-Kudu:~/programming/rn4$ java -version
java version "1.8.0_171"
Java(TM) SE Runtime Environment (build 1.8.0_171-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.171-b11, mixed mode)
and
kevin#kevin-Kudu:~/programming/rn4$ readlink -f $(which java)
/usr/lib/jvm/java-8-oracle/jre/bin/java
When I check the jvm folder:
kevin#kevin-Kudu:/usr/lib/jvm$ ls
java-8-oracle
Just in case, here is my current $PATH:
kevin#kevin-Kudu:/usr/lib/jvm$ echo -e ${PATH//:/\\n}
/home/kevin/bin
/home/kevin/.local/bin
/usr/local/sbin
/usr/local/bin
/usr/sbin
/usr/bin
/sbin
/bin
/usr/games
/usr/local/games
/home/kevin/bin
/usr/bin
/snap/bin
/usr/lib/jvm/java-8-oracle/bin
/usr/lib/jvm/java-8-oracle/db/bin
/usr/lib/jvm/java-8-oracle/jre/bin
/home/kevin/Android/Sdk/tools
/home/kevin/Android/Sdk/platform-tools
Any other ideas? Am I missing something? (highly likely)
ADDENDUM 4 #Vigas Deep:
OK, so completely removed Java, mainly following this.
I reinstalled it using this.
After some monkeying around with genymotion, I was able to get an app started on create-react-native-app that ran on genymotion.
Thank you #vigas-deep. If you're even in Oakland, I owe you a beer, or whatever your beverage of choice is. Thanx!
I have eight years of experience with Ubuntu and other Linux based OSes.
I think the problem is you are having multiple versions of ADB.
run the following command to know if that's right.
which -a adb
And if you have multiple versions of adb, just keep the adb version which is inside your android sdk and remove/rename others.
prefer rename just incase if you need those executables again.
I'd be happy to help more if needed.

how to completely remove android and all its files from mac?

Awhile ago I tried to get cordova working but the android emulator would never start. It just hangs with a black screen.
I had originally installed it with brew install android-sdk.
Then I read somewhere that was bad. So I have since removed it and installed Android Studio.
Either way, I could never get the emulator to bring up an app.
I have tried remove android studio by dragging to trash from Apps, but it seems to have left some files around.
I just recently tried running meteor which has a built in command for running/installing the android sdk, but alas, when I run the app there it just crashes too.
$ meteor run android
Starting android emulator
[[[[[ ~/projects/simple-todos ]]]]]
=> Started proxy.
=> Started MongoDB.
Unexpected exit code 1 from /Users/username/.meteor/android_bundle/android-sdk/tools/emulator [ '-avd', 'meteor' ]
stdout:
emulator: Failed to sync vcpu reg
emulator: Failed to sync HAX vcpu context
stderr:
HAX is working and emulator runs in fast virt mode
I have no idea. I just need to start over I guess. iOS works fine.
Here is a screenshot from Android Studio when I try to run the emulator:
I had a VM running apparently. No idea how, but I restarted the computer and emulator boots up fine as long as I don't run any other apps.

How to configure ADK/virtual devices for Meteor/CORDOVA-PREVIEW#5?

Question: How can I configure the ADK automatically installed through meteor add-platform android? The command proposed in the documenting Hackpad (meteor configure-android) doesn't exist.
Background: I ran everything as described in the hackpad, but when I run meteor run android --verbose I get (after a lot of output) this:
BUILD SUCCESSFUL
Total time: 5 seconds
WARNING : no emulator specified, defaulting to virtual
Waiting for emulator...
PANIC: Could not open: virtual
Secondary question: Where can I file this as a bug?
Try to start the android emulator first, and then run the meteor command.
Here's some steps if you (or someone else) need it:
Create/configure an android virtual device (AVD) first with:
> android avd
In my case, I created a AVD with the name meteor and CPU: ARM (armeabi-v7a).
If you don't have that CPU option, you can install the ARM System Image with the Android SDK Manager running:
> android
Start the emulator with the AVD we just created:
> emulator -avd meteor
when finished loading the emulator run:
> meteor run android --verbose
As #imslavko pointed out, the feature wasn't yet added, but for completeness I'll add this as an answer with the relevant source.
As stated in the Meteor Cordova Phonegap integration:
Meteor tries to set up a virtual device for you, but it's possible that it will be
incorrect or misconfigured for your machine. You can open the Android configuration tool
from Meteor's environment by calling the following command:
meteor configure-android

Categories

Resources