I'm building an app with NativeScript using TypeScript and Angular. This has happened twice while building the app.
In order to add resources (like images), I add them to my_app_folder\app\App_Resources\Android\src\main\res. I accidentally added a folder called "video" with a file called "sample_video.mp4" into the res folder. When I tried to run my app on my Android emulator using the cloud build, I received this error in my NativeScript Sidekick console:
/mnt/storage/builds/_/b10d99b4991d936c4896cd72f0628901fa996d4c/4.2.4/saintstanreal/platforms/android/app/src/main/res/video/sample_video.mp4: Error: The file name must end with .xml
I realized I had placed the file in the wrong place, deleted the video and the video folder, and tried to build the app again, but now I am consistently getting the above error, even though the offending file is long gone.
This has happened to me before (with a .png file with a capital letter in the name, which android does not like) and I would love to know why. Last time I had to delete my whole project, revert to my previous commit, and rebuild the app, which is frustrating.
My app ran perfectly fine before I added that file, so I know that the problem is not being caused by my code. I tried deleting the android platform and reinstalling it, to no avail.
Any help would be amazing as I am very confused as to why the file, which is no longer in my project, would continue to cause this problem.
Try a clean build to reset the data that was cached.
In Sidekick go to Build and from the menu options check Clean Build
When you enable the Clean Build option, any previously cached data
will be ignored and the application will undergo a complete rebuild.
This type of build will not take advantage of certain optimizations
and may take longer to finish.
As of the resolution of this issue in NativeScript Sidekick, using File -> Clean Cloud Workspace fixes this problem.
If I add an incorrect resource file to Android's "res" folder, try to build (and fail), remove the incorrect file, and use the "Clean Cloud Build" command, the Android cloud build will then work as intended (without having to use the "Clean Build" checkbox when building).
Related
Please help me solve the following bug. After many attempts, I came to the conclusion that the point is not which program template I am using, but specifically in the xml files that have a design section (like activity_main.xml), it seems to me that I have already re-tried everything:
installed new gradle
deleted the .idea .gradle folders, files with the .iml extension, modules, settings.gradle files a million times
Invalidate Caches / Restart
changed the path for the SDK
imported the project using "Import project (Eclipse ADT, Gradle, etc.)"
deleted all files along this path C: \ Users (Your UserName). AndroidStudio (version) and not only these files
did chkdsk
And it still doesn't work. The crash occurs only when opening xml files with design sections, on other files, including .xml, everything is ok. Has anyone come across a similar one?
P.S. the error occurs by default along with the creation of a new template.
I seem to have figured out this error.
For those who will come across something similar in the future:
If I start a project and open an xml file that has a design in it (for example, activity_main.xml), then the program crashes. If you do not open this file, then everything is ok. You can even run it. The solution is as follows: you need to go to your project, while the main thing is that the xml files (similar to those I described above) are closed. Then start the MainActivity class with a debugger (set a breakpoint and then shift + F9) and then you need to walk a little (I mean step into with debugger) (maybe this is not necessary at all) through the files using F7 (step by step) and then open the file activity_main.xml (or any similar ) and voila! It will load and will not kick you out. Then you can work. You can even go out and go into the project and then it shouldn't crash anymore, but after the reboot your system you will need to repeat this process. I don’t know what it’s connected with at all, but it seems to me that the problem is that something prevents the .xml files (that is, the design tab) from loading and the program starts to crash with an unknown exception. And in order to solve this, you need to somehow run this file.
Try to install the latest Android Studio version from here and reinstall all files from beginning on your set-up
Restore default settings
I think its work.
I've solved the issue by installing Android Studio 4.2 RC 1 from https://developer.android.com/studio/archive.
I am trying to move a project folder from one location to another and change the folder name.
For various reasons version control was not possible so I have the following structure: MyApp\Version 1.xx\ and in this folder I have more folders named 1.0.1, 1.0.2 etc.
I also have another folder called MyApp that I want to copy into MyApp\Version 1.xx\ and rename it to 1.0.5.
Unfortunately, I am stuck with the following message: "Gradle files have changed since last project sync".
If I try to sync, the message pops up again in a few seconds. If I try to build/debug the project, I get this:
I also tried to create a new empty project with the same name into the desired folder and add the layouts and classes there but if I try to run the app I get these:
I tried Clean, Invalidate Cache and Restart, deleting and recreating Gradle files as well as most of the solutions provided around here, without any luck.
Any ideas on how to fix this issue?
(Posted on behalf of CommonsWare, from the comments).
If I try to sync, the message pops up again in a few seconds. If I try to build/debug the project, I get this"
Try a command-line build, and see if that gives you anything more to go on. Otherwise, for that project (module? whatever), delete your .gradle/, .idea/, and build/ directories, plus .iml files, and try re-importing into Android Studio.
I'm using Jenkins to build an Android project.
The problem I have is that unless I disable the cache Jenkins gives me several errors like for example:
12:31:15 AAPT: \?\C:\Windows\System32\config\systemprofile.android\build-cache\34562456245625\output\res\drawable-mdpi-v4\abc_text_select_handle_left_mtrl_dark.png ERROR: Unable to open PNG file
I can't disable the cache because I would have to do it in the gradle.properties file that is shared on git.
I do not want to use the cache on Jenkins because I want to be sure that the builds always run from scratch.
What's the best practice in this case? Should I leave the cache on or off?
If I need to turn it off how can I do it without stopping the cache while building on the developers' machines?
If I should keep it on, what should I do to avoid the error and to be sure that the build won't be affected by any weird issue with the cache?
I would recommend to disable the build cache.
If you can't do it because it is under source control and shared on several environments, I'd go with a little batch script that creates a copy of gradle.properties before the build, modify the original to disable the cache while building and in a post build step copy the unmodified original back to the location.
If everything is done right, this gradle.properties file will not be recognized as modified and will therefore not cause any pull/checkout conflicts.
I do this in several builds with more than one file (in c# we replace version numbers in the AssemblyInfo.cs file while building and then restore them, and we also do some file-hiphop with android builds)
hope this helps,
cheers, Gris
I decided to keep the cache. Now I'm:
1) setting the build cache dir in the gradle.property
2) cleaning the cache every time by calling gradlew cleanBuildCache
I tried some things with vcs, git, not sure what I did. Suddenly my Android view says nothing to show:
However here's my Project view showing everything correctly:
I also can't run my app anymore, it prompts me with run configurations.
No idea what I did wrong.
Edit: I fixed it, luckily I backed up the project beforehand, simply replaced the whole folder of the project with the backed up folder.
When this happens, check your settings.gradle(Project Settings) file in Gradle Scripts, ensure that file has the following line;
include ":app"
I fixed it, luckily I backed up the project beforehand, simply replaced the whole folder of the project with the backed up folder.
Click on gradle tab in android studio.Now you can see your project name in opened window ; click on it and let to gradle build running. :)
When I start to debug my first Xamarin Android application, I set some breakpoints. Whatever I do, it will still not hit the breakpoint. What's wrong with this?
I have tried many times, but it did not help.
I've found that the name of the folder that contains your project can make a difference. Do you have any spaces or punctuation characters in yours?
The folder name is often the same as the project name, but it doesn't have to be. I had a Xamarin Android project called "Engagement (Android)" within a solution, and by default it was stored on disk at ...\Engagement (Android)\Engagement (Android).csproj
No matter what I did, it wouldn't hit breakpoints. Brand new projects that I added (called Test1, Test2, etc) - debugged perfectly.
When I changed the folder name to "Engagement_Android" (keeping the same project name) - it started hitting breakpoints again.
Other symptoms that went with this included the "Clean Project" option not clearing all the files from the bin/debug folder (it left behind the project's main DLL and PDB file).
The thing that nailed it for me was noticing that when I did a clean build, the bin/debug folder did not contain an "MDB" file for the main exe (in this case Engagement Android.dll.mdb) and so was not been packaged into APK file.
It turns out that the MDB files are the way that debugging information gets packaged up into the APK - without it you can't debug! I think they are created by a tool called PDB2MDB.exe during the build process.
If you try this, bear in mind it is the physical folder name not the project name that is important. Also, you need to edit the SLN file because it contains a reference to the path of each project in the solution - so make the change there too.
I experienced the same issue before and, I've managed to find a workaround for this. I have tried cleaning all of my project’s bin\Debug folders manually and this worked. Just never rely on the clean solution/project alone because this doesn't delete all the files in your output folders. After, rebuild your projects.
Also, try save all your work and shut down Xamarin Studio and restart it.
I have had a few issues in the past that only disappeared when I restarted the IDE.