Preview is unavailable until a successful build... Gradle sync taking to much time - android-studio-3.0

I'm using latest android studio in Linux mint 18 the preview is not showing and gradle sync taking to much time..
Whenever I give build gradle in terminal after a minute it's showing build failed and giving suggestions run with --stack trace

Sync your project with gradles. from: File --> Sync Project with Gradle Files

Related

Flutter on OSX M1 Mac gives error on xcode_backend.sh, about xcode project version when building for simulator

I'm on an M1 Mac Mini, Monterey 12.0.1, with XCode 13.1 & it's command-line tools and freshly-installed Flutter MacOS 2.8.0. I create a base Flutter project with
flutter create appname
When I do "flutter run" in the ios folder (in the parent folder it launches ok in Chrome), I get the message:
Could not build the application for the simulator.
Error launching application on iPhone 13.
I tried it with the simulator running, and not. It looks like the Runner XCode project build stages runs a script, xcode_backend.sh. I also tried loading the project in the XCode UI to build and get 'Command PhaseScriptExecution failed with a nonzero exit code' on that script.
If I go and run this script directly, from the project folder of the ios folder:
guy#Guys-Mac-mini ios % /bin/sh "$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh"
I get the message:
error: Your Xcode project is incompatible with this version of Flutter. Run "rm -rf ios/Runner.xcodeproj" and "flutter create ." to regenerate.
I tried the steps indicated, which I also found on Google, and removed the folder and regenerated the project, but the same message is appearing. (I did export the FLUTTER_ROOT environment variable, both in the shell and it's also defined in the XCode project settings.
I can build and run the flutter apps to Chrome, but not for the iOS simulator. I also have no problem building and running Swift apps I've coded on the simulator.
I got my Windows and Android setup running in minutes, but on the M1 Mac it's been hours without success. Any ideas?
I'm a developer with decent of experience, but this is my first stab at Flutter and cross-platform (other than Xamarin). Any help is appreciated.
I can't fully explain it, but the problem I was having was related to my having the project files on an SMB share I was accessing from the Mac.
I setup the project on an SMB share so I could access it from my Windows and Mac workstations. I found that any flutter project on that share would fail compilation.
To test this, I created a new flutter app on my Mac Documents folder, comiled and ran it succesfully in the iOS simulator using 'flutter run'. When I moved that project to the SMB share and tried to run it, I got the compilation error again, and it wouldn't run (I also tried clean and run). I moved the project back to the local drive Documents folder, and was able to run it again.
I also noticed that the Mac access to the SMB share is painfully slow, though I tried a required_signon fixes from
https://kb.synology.com/en-us/DSM/tutorial/What_can_I_do_to_fix_slow_SMB_file_transfers_on_OS_X_10_11_5 but it didn't help.
I had even tried to factory reset my Mac, and I thought that fixed it, but it was only because I hadn't connected to the share yet, and made a test project on the local drive.
PS: I don't expect to use the exact same Flutter project between the Mac and Windows workstations because of paths and SDK locations, but I am using it as a convenient place for transfering the source files.
My team was able to solve this by supplying an absolute path to the xcode_backend script in a run phase and running it. Running it once seemed to be enough and we could remove it thereafter:
/bin/sh "/absolute-path-to-flutter/packages/flutter_tools/bin/xcode_backend.sh" thin
/bin/sh "/absolute-path-to-flutter/packages/flutter_tools/bin/xcode_backend.sh" embed

Flutter - build on iOS very slowly, how fix it?

I have flutter's app. I run it app in debug mode on iPhone from Android Studio(on Mac). It is very slowly(about 10 minutes). if I run my project from xCode it is much faster - about a minute.
this is a "medium" project, it uses some firebase packages:
firebase_messaging: ^10.0.3
firebase_analytics: ^8.1.2
firebase_remote_config: ^0.10.0+2
firebase_core: ^1.3.0
but I did not find any problems on the net related to these plugins, only for cloud_firestore.
how can I determine what is the problem with the long build? any advice?
There are several ways to speed up the build process for an iOS app in Flutter:
Use the profile build mode: By default, Flutter builds in the debug mode, which includes additional features for debugging and development. However, building in the profile mode can significantly speed up the build process. You can switch to the profile build mode by running the command flutter build ios --profile.
Enable AOT compilation: Ahead-of-Time (AOT) compilation can improve the performance of your app by compiling the Dart code to machine code before it's run. You can enable AOT compilation by running the command flutter build ios --release --no-codesign.
Use flutter build command instead of flutter run: The flutter run command is convenient for development, but it's slower than the flutter build command because it includes additional features like hot reloading and debugging.
Use flutter build bundle command: flutter build bundle command generates an asset bundle for your app, including all the resources like images, fonts, and JSON files. This command is faster than flutter build command because it only build the necessary asset, not the entire app.
Reduce the size of your app: Remove unnecessary assets, libraries and classes that are not used in your app. You can use flutter analyze command to detect any unnecessary parts in your code.
Clean and rebuild: Sometimes the build process can be slow due to stale files or cached data. Running the flutter clean command and then rebuilding can help speed up the process.
Use a Mac with more powerful hardware: Building for iOS requires a Mac, and building time can be affected by the performance of the Mac you are using. If you are using a Mac with lower performance, you can try building on a more powerful Mac or using a cloud-based Mac build service like Bitrise or CircleCI
It's also good practice to keep your Flutter SDK and Xcode updated to the latest version to take advantage of performance improvements.
I solved this problem - new Mac Mini(M1/8 Gb).
the first build can last 40-50 seconds (10 times faster).
next build - of 10-25 seconds.

Unable to build app for iOS, "unable to write module session file Session.modulevalidation No such file or directory"

yesterday I was working fine with Flutter, now i'm facing this issue and I already search everywhere for a solution but no success.
When I run:
flutter run
The build process starts and when its about to finish the error below is shown:
Launching lib/main.dart on iPhone 11 Pro Max in debug mode...
Xcode build done. 12.3s
Failed to build iOS app
Error output from Xcode build:
↳
** BUILD FAILED **
Xcode's output:
↳
error: unable to write module session file at '/Users/hencke/Library/Developer/Xcode/DerivedData/ModuleCache.noindex/Session.modulevalidation': fopen(/Users/hencke/Library/Developer/Xcode/DerivedData/ModuleCache.noindex/Session.modulevalidation, wb): No such file or directory (2)
note: Using new build system
note: Planning build
note: Constructing build description
Could not build the application for the simulator.
Error launching application on iPhone 11 Pro Max.
Exited (sigterm)
Looks like the process is trying to open this file Session.modulevalidation for writing, but this file really does not exist in that folder. And I don't know what to do.
Things that I already tried:
Reinstalling xcode
flutter clean
Clone my project again in another folder and try to build, but same error
Created a new flutter dummy project and tried to build, still same error
Rebooting machine several times
Give permissions to Staff to the DerivedData and ModuleCache.noindex folders
Deleted the DerivedData within hope that xcode build will recreate all the files needed, but, it created everything again but not that particular file.
So that's it, If any blessed human know how to 'recreate', or reset, clear some cache, I would be very thankful.
Before running your project, check everything is checked when running:
flutter doctor
and also make sure at least a device is connected or open iOS simulator first. You can check if flutter is successfully connected to the device by:
flutter devices
when you make sure that flutter detect your device or the simulator, then run your application by:
flutter run
After hours I finally found the solution as it follows:
Without any hope I opened my flutter project with Xcode, and then tried to build the Runner target from there, same error.
Then, I was browsing the Xcode preferences and something caught my attention, on Locations section I found something about DerivedData location, it was set as Default. So, I changed from Default to Custom location and I set to a new folder on my home directory:
Then immediately Xcode created the entire DerivedData/ModuleCache.noindex folder and with them, the Session.modulevalidation file as well.
Then I closed Xcode and tried flutter run again, and it was successfully build!
I'll let this answer to those who may come here for help.

Cordova iOS Remote Build Release Mode fail

Building Cordova app via Visual Studio using Remote build.
Was using Cordova version 5.3.1, tried updating to the latest version of Cordova too - 6.2.1-nightly.2016.5.23.6e87c71a.
Both times it works in Debug mode but does not work in Release Mode:
Errors - misleading and say nothing whatsoever:
http://imgur.com/TdSfuso
Part of the Output:
ERROR building one of the platforms : error : /Users/Jurgen/.taco_home/remote-builds/taco-remote/builds/66415/cordovaApp/platforms/ios/cordova/build: Command failed with exit code 2
1> You may not have the required environment or OS to build this project (TaskId:10)
1> Failed to build app for buildNumber 66415: /Users/Jurgen/.taco_home/remote-builds/taco-remote/builds/66415/cordovaApp/platforms/ios/cordova/build: Command failed with exit code 2 (TaskId:10)
1>22:57:03.377 1>
1>Error : Remote build error from the build server Build failed with error /Users/Jurgen/.taco_home/remote-builds/taco-remote/builds/66415/cordovaApp/platforms/ios/cordova/build: Command failed with exit code 2: {1}
1> Done executing task "MdaVsCli" -- FAILED. (TaskId:10)
1>22:57:03.393 1>
1>Done building target "BuildMDA" in project "MobileAppNew.jsproj" -- FAILED.: (TargetId:11)
Full Output:
https://www.wetransfer.com/downloads/b9a4e2e932f98bb2286fbb6602c8dfc020160523210524/48dffd
We are planning to send the app to iOS to be released on the App Store but cannot do the .ipa file. Any help would be appreciated
How I solved this problem:
First of all I didn't manage to build and deploy on a device when using the App Store Production Certificate. I did manage however with the Ad hoc certificate, which is a production certificate with the only difference that you still have to specify the UDID of the devices you will deploy on in the developer account.
I then updated my Cordova version from 5.3.1 to 6.2.0. I updated 2 outdated plugins: Inappbrowser and Phonegap-plugin-push and voila; the app suddenly started to deploy in release mode (via a taco remote build). Weird bit is that I had been using the old version of cordova and never had to update the plugins when running in Debug mode - which was why it took me a bit more time to figure it out! Good luck :)

Integrating Crashlytics build script with Xamarin.iOS

I am trying to integrate Crashlytics with Xamarin.iOS. I have successfully added a binding and started the logger with my API key. I'm able to crash the app but no reports are landing on the web dashboard. When adding Crashlytics to an xcode project it prompts you to add a build phase task to run a script (Which I believe uploads your symbol files to their website).
./Crashlytics.framework/run APIKEY
After creating a binding of the framework for Xamarin this doesn't work as expected... I haven't added a build task in Xamarain Studio but running the command from the terminal yeilds:
MacBook-Pro:Crashlytics.framework user$ ./run APIKEY
2013-09-04 16:10:49.941 run[9238:707] Crashlytics.framework/run 1.2.3
2013-09-04 16:10:49.943 run[9238:707]
Crashlytics: Failed to Detect Build Environment
BUILT_PRODUCTS_DIR value not found in environment
So finally the question:
How do you integrate this build script into the Xamarin environment? Do I need to copy more assets around to trick the run command into thinking all is well?
Latest versions of Xamarin Studio support Crashlytics out of the box:
We had been using Crashlytics with our Xamarin project. But, it seems with Xamarin.iOS 8.6 and/or Xamarin Studio 5.7 it is no longer supported, and the Crashlytics APIs have changed.
Here are the steps I used.
In the Xamarin Studio , go to the touch container and add the Crashlytics API key in the Build -> Crash reporting section. Build and run that app. The evidence suggests that is enough to get data sent to Crashlytics. I saw that it knew about older versions of the app I had built and ran weeks ago with the API key already in.
Go to Xcode and create a new project with the same name as the Xamarin project, com.{company}.{appname}. (You probably need to have that profile downloaded.) I did it in Swift by the way with no issues.
Go to crashlytics.com com and go to settings -> Apps (or https://www.crashlytics.com/onboard)
You will get an app to download and run. The app walks through the steps of adding
A build phase run script
Code to the application main Crashlytics.startWithAPIKey(“nnnn”)
Run your Xcode version of the app
The Crashlytics web page popped up immediately.

Resources