I have angular 2 nativescript project and I use
tns livesync android --watch or tns run android
to see changes on both real device and emulator. It usually works fine but at some point it starts building and syncing old code and throws JS errors based on that code.
It's usually solvable by reseting the whole project (remove platforms, node-modules, hooks) and tns install everything back.
When I add new node modules and/or new custom components, I usually kill the lifesync and do the tns build android.
Regardless of this lifewatch serves old html and old js (transpiled from ts).
When I saw the output in the terminal I copied out the elements that caused an error and searched in the whole project for these elements. However they are nowhere to be found. First I thought they were still inside platforms folder, but no, so they must be cached somewhere. Has anyone noticed this as well? How to fix this / work around this ?
I am using Webstorm - tried invalidating cache and restart. Didn't help. Decided to switch over to Visual Studio Code, but it is doing the exact same thing. I have even deleted .gradle folder in order to delete cached files. Didn't help.
It seems this is fixed in next release (unfortunately not the current 2.2). Read up on their github . It was indeed the CLI syncing wrong files.
Related
I have been using Android studio for a long time, yet never understood what are the processes that Android studio runs at when we load a new project via File>New or File>Open. We just load the project and have to wait for so many minutes before the android studio completes those processes (I know that we can still click on file names and editor would open them, but i have observed the android studio will still lag until all those processes are completed)
However I don't know how, recently My Android studio started behaving differently. I don't know what i did, But every time i created a new project, or loaded a previous one, it would show a message like this:
This was very good for me, because even when i don't click the try again
button, I am still able to access all files and without any lag, thereby removing a need for external file editor. I feel this was some bug in gradle or cache handling that got fixed when i uninstalled AS and updated to AS 3.5 .
So is there a way to manually run all those build and indexing processes, instead of Android Studio just running them automatically?
UPDATE:
I think i was not clear before. I want that error to occur . Meaning I want to have a control over when the building process starts. Also, I am NOT having any error as of now, all my projects are working fine.
Look for highlighted warnings in you Gradle file, you may need to update some things and then sync again.
You could also try to clean and rebuild your project.
You can also File->Invalidate Caches / Restart if none of the above work.
If none of the above work, please provide more details on what warnings/errors you get.
When version conflict in gradle file, it cant be able to build and sync the project.There may be show "Unsupported Modules Detected: Compilation is not supported for following modules”. Fix them too
I was always able to build from this project, this just started happening this morning. When I run ionic build android everything runs smoothly and the build succeeds, but the date modified on the android-debug.apk file stays the same, and I don't see my changes when I run it on a device.
Could it have something to do with messed up permissions and somehow it doesn't have permission to write the apk? I'm running Ubuntu-server 14.04.4.
I know it's been answered before but I'm adding this to let you guys know what I've tried and how it's not working anyways...
I've also faced same issue and tried several things like
Renaming APK file, expecting it will create new one.
Deleting build folder, expecting as usual will create new one.
opening project in Android studio, expecting it will create new one when I use it to launch the APK to device.
I've tried calling ionic prepare platform before calling ionic build.
The ionic build is a proxy for cordova build command.
But in this issue all of above approaches were failed.
The reason I can see behind this is because of no proper response/function of added platform to your project, as when you build it's cordova platform android's responsibility to prepare build on your command. Which is not working.
Lot of people suggests that You need to us ionic/cordova restore, this will restore your state.
Another way is you can use Android Studio's build APK option which helps you not to disturb your plugins by restore or reset commands.
Hope this helps you save your time from trying all these approaches.
Could it that you are looking at a wrong place?
When build command is successfully finished you should see smth like below in console
Built the following apk(s):
<PATH_TO_YOUR_SOURCES>/platforms/android/build/outputs/apk/android-debug.apk
Are you checking this this location?
Okay so the problem isn't with Ionic, it's just that the changed files aren't showing up in the ftp for some reason. So now I will try and figure that out.
As suggested by #mobileevangelist , ionic cordova restore can be done using command
ionic cordova prepare
It fixed my problem.
Try to
Open Android Studio
Choose Import project
Select YourProjectDirectory/platforms/android folder
Choose Build -> Build APK
I'm making my first steps in phonegap. I've been able to set up a project, install a plugin and build the app on my phone without errors. However, now, when I try to change the layout of my www/index.html in the project's root platforms/android/assets/www/index.html stays untouched whenever I (re)build the app.
I'm basically working in eclipse, only for html and javascript I use sublime. I've searched now for a couple of hours for a solution. The most promising approach was this thread: Changes to HTML files not showing on built phonegap 3.0 app ... but even that didn't work.
What can I have done wrong? There's no error, no warning (none resulting from the build process) and I don't know how I could debug the issue. I'm currently using phonegap/cordova 4.2.0
Any clue? Thanks
I still don't know the reason for my problem. However, installing the app via cordova CLI rather than eclipse seems to have solved the problem:
$ cordova prepare android
$ cordova run android
I recently switched from Eclipse to Android Studio because I read that it is now the official IDE for Android application development. I downloaded and installed the latest version (1.0.2) for Windows. When using the program for the first time, I decided to create a test application to see if the program was working correctly. Unfortunately, it was not. Once I clicked the finish button to complete the New Project Wizard, A loading bar showed up that said Gradle: Build. This is where the program gets stuck. There is no error message and it appears that the program is running fine, however the build never actually completes. I am never given my MainActivity.Java class, or my activitymain.xml document. If I click the cancel button, the program freezes and I have to use the TaskManager to kill the program. If I re-enter the program and choose to open an existing project, my project will be there. However, upon trying to open the project, I am greeted with the same Gradle: Build loading bar.. I have been searching for an answer for the last 3 days and nothing has worked. Any help is greatly appreciated!
Things I have tried:
Simply letting the program sit for a while to see if it was actually downloading something and was just really slow. I let it sit for 45+ minutes before killing the program.
Uninstalling and re-installing Android Studio
Restarting my computer
Turning off my firewall (Kaspersky)
Running the program as an administrator
Connecting to a different network
Disconnecting my computer from any networks (to force the program to build in offline mode)
Manually downloading Gradle from the link that Android Studio attempts to use when it gets stuck and telling the program to use that file instead of downloading another one.
(I went to this link https://services.gradle.org/distributions/gradle-2.2.1-all.zip, downloaded the file, unzipped it, went to Gradle settings in Android Studio, checked the Offline work checkbox, and finally set the service directory path to my unzipped Gradle folder.)
Hopefully I have given enough information and made it clear what my problem is. If not please tell me what else I need to explain so I can get this issue resolved. Thanks!
Please note I am working on a 64 bit machine running Windows 8. Also, I use studio64.exe
to run the program.
From the discussion we had in the comments, it does not look like you have your gradle on your windows path.
Please change the below to point to your gradle install:
set GRADLE_HOME=C:\<installation location>\gradle-1.11
set PATH=%PATH%;%GRADLE_HOME%\bin
After this, verify that in the terminal running the following works:
gradle tasks
once you get this working, you will want to run the following in your project:
gradle wrapper
This will produce a .bat file which you can then use to run gradle through the wrapper, letting you support multiple native gradle installations.
I noticed today that: sudo npm update -g phonegap showed that v3.5 was available. After doing this update, phonegap -v returns: 3.5.0-0.20.4
I then proceeded to create a sample app using the Phonegap CLI:
cd myProjectFolder
phonegap create HelloPhoneGap350
cd HelloPhoneGap350
phonegap local build ios (to add the ios platform)
phonegap run ios --emulator
At this point, the sample app launches. However, deviceready event never gets called. (I added some alert code and can see that the app.initialize() and app.bindEvents() get called. But onDeviceReady never gets called. I was also able to reproduce this with an Android build.
A few weeks ago, I went through exactly the same process with the previous version of Phonegap (v3.4.0-0.20.0) to create a HelloWorld340 which works fine and does call the onDeviceReady function.
I realize that the Phonegap 3.5.0 packaging of cordova 3.5.0 has only been out a few days. Perhaps it's a bug in the packaging? Anyone have any ideas or solutions.
Thanks!
well, im using 3.5.0-0.2.4 and it works like a charm.
perhaps you forget to inherit the cordova.js-file?
More interesting observations over the past few days. I went through the process to create a few more projects. (I'm migrating a bunch of old PhoneGap apps to the new PhoneGap 3.5 and it's easier to create new, sample projects and just move the existing HTML/JS/CSS code over...)
During this work, I noticed that - with a few specific steps - the generated project can fire "deviceready" out of the box. Here are the details:
I noticed that the phonegap.js file does seem to get put in the right place (yourProjectName/platforms/ios/www/phonegap.js) when the application is created from the command line.
However, upon first launch of the project with Xcode, it doesn't seem to be noticed even though it's in the "Staging/www" view within Xcode. However, if you following procedure, the rebuild in Xcode seems to notice that it's there and package up the right bits to push to the device/emulator.
CLI: phonegap local build ios
Xcode: Product - Clean <-- this seem to be the important step.
Xcode: Product - Build/Run
(Note, however, that the cordova.js file that appears in the initial creation of platforms/ios/www doesn't get removed. So, you end up with 2 copies of the same file with different names: cordova.js and phonegap.js)
With this approach, you don't have to edit the generated index.html solution (mentioned as another solution/workaround in this thread).
Thanks to the suggestion by brauchle_andi above, I dug deeper and found the problem and just reproduced it in a 'clean' generated project.
I am using PhoneGap 3.5.0-0.20.4
I generated a new project (details) below and the file cordova.js is placed in the proper platforms/ios/www folder
However, the generated index.html has a reference to loading the script file, phonegap.js. Editing the index.html to load cordova.js fixes this problem.
Seems like a bug in the PhoneGap packaging process.
Here are the steps taken to reproduce this problem:
Use npm to install (though I may have done an update, don't recall) PhoneGap 3.5.0-0.20.4
cd Documents/PhoneGapProjects (the folder where I put my Hello World programs)
phonegap create /Users/John_Arnold/Documents/PhoneGapProjects/HelloPhoneGap350A -i "com.phonegap.HelloPhoneGap350A" -n "HelloPhoneGap350A"
phonegap run ios --emulator
This creates the project with the problem described above. Editing index.html and re-running the project fixes it.