I'm using Nativescript advanced seed project to start with a sample project. The sample project as is, got built and deployed to my device taking arround 100MB, which seems to be a lot considering no new screen added(except for the default 2 screens).
Is it because of the other platforms libs included in the base project?
Is there anyways to disable unused libs to reduce the apk size?
Its not because of the other platform libs, which will not be included in your Android/iOS build. In other words,each platform build has its own command, which will include only that platform specific files. Ex. Mac related wont be present in the Android build.
App size is currently an issue with Nativescript. You might be doing a dev build. When you do PR build with below platform specific commands, base size will be around 50MB.
Android: npm run build.android
iOS: npm run build.ios
Size wont increase exponentially as you add new screens, as the most of the size is coming from nativescrit base web dependencies to execute the JS files in the run time.
More on webpack here -> https://discourse.nativescript.org/t/how-to-decrease-app-size-and-release-it-using-webpack-and-nativescript/798
Related
I have an android system app that is currently being built with the android build system. The SDK in use is system_current as it uses some system apis.
For external dependency reasons, ease of development, debugging etc, it would be nice to move this app to Android Studio and use Gradle to build.
Converting the sources to build with Gradle is straight forward enough. However, at build time, the system APIs are not found as those are not available in the normal SDK. I thought that by generating the SDK from the AOSP sources I'd get an SDK I could use, but that target output seems to also not have the System APIs available.
How would I change my gradle build to be able to use the System SDK to compile against?
There are two ways depending if you are only trying to use current non-public APIs, or of you've added custom ones yourselves and are trying to access those.
If you're only trying to use current system-level APIs, you can use android.jar from this repository https://github.com/anggrayudi/android-hidden-api
If you have added some new method that isn't part of standard AOSP, then it's a but more work.
The reason that all methods don't show as part of Android SDK is that in AOSP code they are annotated with #hide. This means that when SDK is generated, they are exlcuded.
You'll need to remove that annotation for the methods that you want to use. Then you'l need
Run make update-api to update the public API of the project.
Make the Android SDK from code by following: https://android.googlesource.com/platform/sdk/+/master/docs/howto_build_SDK.txt
Change the Android SDK path in Android Studio to use the custom one you build.
There's also the possibility of accessing methods via reflection on runtime without SDK generation. It's slower and messier to code though.
Not sure I understand exactly what you mean by normal SDK etc.
From https://developer.android.com/studio/build
The key part is to have a
apply plugin: 'com.android.library'
...
android {
...
}
If on the other hand you wanted to build with a desktop JDK but compile against java APIs you could add a dependency on robolectric and you can get a jar you can import into another Android project.
implementation "org.robolectric:android-all:11-robolectric-6757853"
Android Studio isn't really designed to work with System APIs. Even if you make Gradle build your platform app, you will also need to sign it with the same certificate as your AOSP build (so that you could run it). As you noticed, if you decide to use Roboelectric you would also need to modify it yourself to match your current AOSP version (System APIs are not as stable as Public APIs and Roboelectric needs to constantly chase all the changes).
I would suggest to keep using the AOSP build system but optimize our workflow.
Ease of development
Doing a full build/flash for every change in your component must be a pain. But if you are just modifying a single app, you can get away with just building that single component:
~/aosp/ $ m -j -- do a full build first
flash a clean image (with your platform certificate)
~/aosp/path/to/your/app/ $ mma -j -- build your app with all dependencies after you made changes
$ adb root && adb remount && adb sync
Basically, adb sync works great if you don't touch any APIs or parts of Android Framework (which would cause a rebuild of thousands other objects). If you see adb sync updating more than handful of files, you'll likely end up with a bad system and need to do a full flash.
Debugging
While Android Studio is a to-go solution for regular apps, framework and the platform apps go with InteliJ (you can probably use Android Studio, but there won't be much of use of Android plugins on top InteliJ) plus some configuration (see idegen.sh - example).
Since I'm building using FireStore and few other Firebase library, the build time has doubled down. I'm wondering if there is a way to avoid compiling it every time I clean & build my project.
Don't clean & build, just build. ;)
Disclaimer: Before doing releases, a clean build is preferred, of course.
UPDATE with better answer: Use cocoapods-binary plugin.
https://guides.cocoapods.org/plugins/pre-compiling-dependencies.html
One solution for this is to not give Xcode the chance to re-compile code. CocoaPods Binary will pre-compile your Pods during pod install, and then add the binary assets (e.g. .framework files) into the generated Xcode projects instead of the source code.
Like this.
plugin 'cocoapods-binary'
use_frameworks!
target "MyApp" do
pod "NeededPod", :binary => true
end
For anyone stumbling on this post, we finally found a way to optimize Firestore build time while still using cocoapods.
We are using THIS REPO
It's a precompiled Firestore iOS SDK xcframework files extracted from the Firebase iOS SDK repository release downloads, tagged by Firebase iOS SDK version and presented as a consumable podspec.
Why
Currently the Firestore iOS SDK depends on some 500k lines of mostly C++, which when compiling as part of your Xcode build takes a long time - even more so in CI environments.
In order to automize the build process when using a cross platform framework (FUSE). Unless I am wrong, I coudn't find any settings in FUSE to cover this cases so that's why I am trying to set them after FUSE builds and generates the xcode project files.
One of the issues I am facing right now is about the target device and the other one is adding an entry in the build phases.
STEP BY STEP
FUSE build generates the xcode project files including a new xcodeproj file everytime with a different FUSE-XCODE classes mapping so I cannot reuse it from one build to another
I can open the project in xcode IDE
Do some settings manually (target device and add a bundle resource)
Generate a build
Publish it to TestFlight
However, I am trying to make a command line build with the following steps:
FUSE build generates the xcode project files including a new xcodeproj file everytime with a different FUSE-XCODE classes mapping so I cannot reuse it from one build to another
Set the target device and the bundle resorce path by script
Build by xcode command line tools and generate the IPA file
Publish it to TestFlight
I already achieved to writhe the app name, version and build number by PlistBuddy using an script. However I didn't manage to do the same for the target device and adding a bundle resource.
About the device, I wanna set iPhone only:
About the Build Phases, I wanna add a Bundle Resource with the license of one library we use in the project. The license file is in a path belonging to the project.
my project code size only 2M ,but by command: [tns build android ] create 《app-debug.apk》 size 78M.
nativescript-vue project
NaticeScript adds node_modules dependencies in build and that's the reason for increased size of android and ios app.If you want smaller size you can opt for native android/ios app.
Use release version of APK and not the debug one.
Try a clean build, sometimes the node_modules folder is copied as it's by mistake (not exactly sure why / when it happens), a clean build mostly resolves the issue.
I created an Phonegap app for iOS devices. It works fine on my connected device, but if I want to archive the app to get an .ipa file I get errors from the compiler.
Do I have to change something in the Build Settings?
A couple of things to try:
Go to the Build Settings, then Linking, then find Other Linker Flags. Then change $(TARGET_BUILD_DIR)/libCordova.a -----> $(BUILT_PRODUCTS_DIR)/libCordova.a
Under Build Settings in Architectures, change Build Active Architecture Only to YES.
I'd try both these methods for the Project and Target. Hope this helps!