How to cloud build my app while PlayServices is using AndroidX? - nativescript

Today, I created a new project, installed some plugins and tap on "Run" in NativeScript Sidekick, to build my app on cloud to my Android device, but I faced this error:
[00:01:35.796] [WARN] Attribute application#appComponentFactory value=(android.support.v4.app.CoreComponentFactory) from [com.android.support:support-compat:28.0.0] AndroidManifest.xml:22:18-91
is also present at [androidx.core:core:1.0.0] AndroidManifest.xml:22:18-86 value=(androidx.core.app.CoreComponentFactory).
Suggestion: add 'tools:replace="android:appComponentFactory"' to <application> element at AndroidManifest.xml:8:5-18:19 to override.
FAILURE: Build failed with an exception.
Some said that NativeScript Sidekick and NativeScript Cloud build are not yet compatible with NativeScript 6
I have been navigating for hours and reading similar issues on GitHub and Stack Overflow, but none of them worked for me, or for Cloud build.
This is my package.json content:
{
"nativescript": {
"id": "com.app.test",
"tns-android": {
"version": "5.4.0"
},
"tns-ios": {
"version": "5.4.2"
}
},
"description": "NativeScript Application",
"license": "SEE LICENSE IN <your-license-filename>",
"repository": "<fill-your-repository-here>",
"dependencies": {
"nativescript-geolocation": "5.1.0",
"nativescript-mapbox": "4.4.1",
"nativescript-plugin-firebase": "9.0.3",
"nativescript-theme-core": "1.0.6",
"nativescript-ui-autocomplete": "5.0.0",
"nativescript-ui-dataform": "5.0.0",
"nativescript-ui-listview": "7.0.1",
"nativescript-ui-sidedrawer": "7.0.0",
"nativescript-webrtc-plugin": "2.0.0-alpha.18",
"tns-core-modules": "5.4.3"
},
"devDependencies": {
"nativescript-dev-typescript": "~0.10.0",
"nativescript-dev-webpack": "~0.24.0"
},
"gitHead": "**************",
"readme": "NativeScript Application",
"author": "***"
}
Edit
I am not using NS 6, I use NS 5, since Sidekick is not yet compatible with NS 6. Also, I removed UI Pro components plugins, and it seems to work now. The pro UI plugins might work if I use older versions.

I'm not sure the compatibility of SideKick/Cloud build and 6.0/AndroidX, that normally lags a couple weeks. However I can tell you based on your package file, that it won't work. You are mixing Android & AndroidX :)
NativeScript requires NS 6.0 runtimes for AndroidX. NS 5.4 DOES not use AndroidX. But you are using NS-UI versions which are AndroidX.
So to test if sidekick/cloud builds supports AndroidX I would make the following changes:
{
"nativescript": {
"id": "com.app.test",
"tns-android": {
"version": "5.4.0"
},
"tns-ios": {
"version": "5.4.2"
}
},
Needs to be changed to
{
"nativescript": {
"id": "com.app.test",
"tns-android": {
"version": "6.0.0"
},
"tns-ios": {
"version": "6.0.1"
}
},
In addition this needs to be changed:
"devDependencies": {
"nativescript-dev-typescript": "~0.10.0",
"nativescript-dev-webpack": "~0.24.0"
},
to
"devDependencies": {
"nativescript-dev-webpack": "~1.0.1"
},
And finally this:
"tns-core-modules": "5.4.3"
needs to be
"tns-core-modules": "~6.0.1"
As for the rest of the dependencies; that is hard to say; because NativeScript just transitioned to AndroidX; their is a good change that some of the other plugins you have listed; might not be AndroidX compatible. I would honestly try building an app with out any of the extra plugins first:
"dependencies": {
"nativescript-theme-core": "1.0.6",
"tns-core-modules": "~6.0.0"
},

Related

Expo - standalone APK crashing when running on physical device; app working on expo-cli

First off, I'm new to react-native so please excuse my missing knowledge regarding troubleshooting.
I have built a basic app using Expo, which runs perfectly fine when I run expo start and scan the QR code to run it on my physical device.
I then ran expo build:android in my terminal and selected apk to create an apk file. It installs, but when I try to open the app on my phone, it crashes straight away. I'm not sure why this happens, or how to troubleshoot it.
Some steps I have taken:
Reinstalled expo-cli
Reinstalled react-native
Ran npm-update
Manually downgraded my sdkVersion to 37.0.0 in my app.json file (as suggested by online forums)
Here is my app.json file:
{
"expo": {
"name": "FactApp",
"slug": "FactApp",
"sdkVersion": "37.0.0",
"platforms": [
"ios",
"android",
"web"
],
"version": "1.0.0",
"orientation": "portrait",
"icon": "./assets/icon.png",
"splash": {
"image": "./assets/splash.png",
"resizeMode": "contain",
"backgroundColor": "#ffffff"
},
"android": {
"package": "com.kmdevops.factapp",
"versionCode": 2,
"config": {
"googleMobileAdsAppId": "ca-app-pub-7529073010403742/8555991419"
}
},
"updates": {
"fallbackToCacheTimeout": 0
},
"assetBundlePatterns": [
"**/*"
],
"ios": {
"supportsTablet": true,
"bundleIdentifier": "com.yourcompany.yourappname",
"buildNumber": "1.0.0"
},
"description": ""
}
}
And here is my package.json file:
{
"main": "node_modules/expo/AppEntry.js",
"scripts": {
"start": "expo start",
"android": "expo start --android",
"ios": "expo start --ios",
"web": "expo start --web",
"eject": "expo eject"
},
"dependencies": {
"#react-native-community/masked-view": "0.1.6",
"#react-navigation/native": "^5.5.1",
"expo": "^37.0.12",
"expo-ads-admob": "~8.1.0",
"expo-linear-gradient": "~8.1.0",
"react": "~16.9.0",
"react-dom": "~16.9.0",
"react-native": "https://github.com/expo/react-native/archive/sdk-37.0.1.tar.gz",
"react-native-gesture-handler": "~1.6.0",
"react-native-reanimated": "~1.7.0",
"react-native-safe-area-context": "0.7.3",
"react-native-screens": "~2.2.0",
"react-native-web": "~0.11.7",
"react-navigation": "^4.3.9",
"react-navigation-stack": "^2.7.0",
"react-navigator": "0.0.0-0"
},
"devDependencies": {
"babel-preset-expo": "~8.1.0",
"#babel/core": "^7.8.6"
},
"private": true
}
Any help would be greatly appreciated!
So I created a fresh new app with expo-cli and the resulting APK crashed so I figure it's an issue with expo. I used react-native cli to create an apk for this app and it works with no issues

Nativescript 6 - environment specific files not working

I just recently migrated my app to NS 6 and I noticed that the environment specific files are not processed properly.
E.g. I have settings.debug.json and settings.release.json. In code, I reference them as import * as settings from '/settings.json' . In NS < 6, this used to work, but now I get an error that that settings.json does not exist.
I have very limited experience with Webpack. Is there a setting I need to configure there for this to work?
Here is my package.json
{
"name": "<app>",
"nativescript": {
"id": "<id>",
"tns-ios": {
"version": "6.0.1"
},
"tns-android": {
"version": "6.0.1"
}
},
"description": "",
"license": "SEE LICENSE IN <your-license-filename>",
"repository": "<fill-your-repository-here>",
"dependencies": {
"moment": "^2.24.0",
"nativescript-appversion": "^1.4.2",
"nativescript-geolocation": "5.1.0",
"nativescript-iqkeyboardmanager": "1.3.0",
"nativescript-loading-indicator": "2.4.0",
"nativescript-local-notifications": "3.1.0",
"nativescript-plugin-firebase": "9.0.2",
"nativescript-theme-core": "~1.0.4",
"tns-core-modules": "6.0.1"
},
"devDependencies": {
"nativescript-dev-webpack": "1.0.2",
"typescript": "3.4.5"
},
"readme": "",
"author": ""
}
Thank you.
You can conditionally load the files using the TNS_ENV variable.
const settings = TNS_ENV !== 'production' ? require('./settings.debug.json') : require('./settings.release.json')

React Native OSX CRNA Compilation of µWebSockets has failed C++11 compiler

Got this issue after ejecting from Expo (with ExpoKit). Had a working environment before ejecting. npm run ios will run with this issue repeating over and over:
Origin: Worker (PID 6336) 12:18:06: [Error] Error: getaddrinfo
ENOTFOUND lcalhost 12:18:06: at errnoException (dns.js:28:10)
12:18:06: at GetAddrInfoReqWrap.onlookup [as oncomplete]
(dns.js:76:26)
Expo XDE will not run at all and repeats this message. XCode includes C++11 compiler.
Error: Compilation of µWebSockets has failed and there is no
pre-compiled binary available for your system. Please install a
supported C++11 compiler and reinstall the module 'uws'.
package.json
{
"name": "OurApp",
"version": "0.0.1",
"private": true,
"devDependencies": {
"babel-eslint": "^8.0.3",
"eslint": "^4.13.1",
"eslint-config-airbnb": "^16.1.0",
"eslint-plugin-import": "^2.8.0",
"eslint-plugin-jsx-a11y": "^6.0.3",
"eslint-plugin-react": "^7.5.1",
"jest-expo": "^23.0.0",
"react-native-scripts": "1.8.1",
"react-test-renderer": "16.0.0",
"remotedev-rn-debugger": "^0.8.3"
},
"main": "./node_modules/react-native-scripts/build/bin/crna-entry.js",
"scripts": {
"start": "react-native-scripts start",
"eject": "react-native-scripts eject",
"android": "react-native-scripts android",
"ios": "react-native-scripts ios",
"test": "node node_modules/jest/bin/jest.js --watch",
"postinstall": "remotedev-debugger --hostname lcalhost --port 5678 --injectserver",
"eslint": "./node_modules/.bin/eslint"
},
"remotedev": {
"hostname": "localhost",
"port": 5678
},
"jest": {
"preset": "jest-expo"
},
"dependencies": {
"#expo/vector-icons": "^6.2.1",
"axios": "^0.17.1",
"expo": "^23.0.0",
"lodash": "^4.17.4",
"prop-types": "^15.6.0",
"react": "16.0.0",
"react-native": "https://github.com/expo/react-native/archive/sdk-23.0.0.tar.gz",
"react-native-elements": "^0.18.5",
"react-native-maps": "^0.19.0",
"react-navigation": "^1.0.0-beta.19",
"react-navigation-redux": "^0.1.0",
"react-redux": "^5.0.6",
"redux": "^3.7.2",
"redux-logger": "^3.0.6",
"redux-promise": "^0.5.3",
"redux-thunk": "^2.2.0",
"remote-redux-devtools": "^0.5.12"
}
}
app.json
{
"expo": {
"isDetached": false,
"privacy": "unlisted",
"sdkVersion": "23.0.0",
"orientation": "portrait",
"primaryColor": "#ffde00",
"name": "OurApp",
"description": "Desc",
"icon": "./resources/icon.png",
"version": "0.0.1",
"slug": "our-app",
"scheme": "ourapp",
"ios": {
"bundleIdentifier": "se.comp.expo",
"config": {
"googleMapsApiKey": "key"
},
"buildNumber": "1.0.0",
"isRemoteJSEnabled": true,
"supportsTablet": false,
"associatedDomains": [
"myDomain.com"
]
},
"android": {
"package": "se.comp.expo",
"versionCode": 1,
"config": {
"googleMaps": {
"apiKey": "key"
}
},
"permissions": [
"CAMERA",
"ACCESS_FINE_LOCATION"
]
},
"notification": {
"icon": "./resources/icon_notify.png",
"color": "#ffde00",
"androidMode": "collapse",
"androidCollapsedTitle": "#{unread_notifications} new"
},
"loading": {
"icon": "./resources/icon.png",
"backgroundColor": "#000000",
"backgroundImage": "./resources/splash.png",
"hideExponentText": true
},
"splash": {
"backgroundColor": "#000000",
"image": "./resources/splash.png",
"resizeMode": "cover"
},
"androidStatusBar": {
"barStyle": "dark-content",
"backgroundColor": "#ffde00"
},
"facebookAppId": "id",
"facebookDisplayName": "OurApp",
"facebookScheme": "fbId",
"androidShowExponentNotificationInShellApp": true
}
}
As #SyedZainAli mentioned this might be caused by environment. A few things to try then is:
Remove node_modules, run npm cache clean and reinstall
Reinstall NodeJS
Create a new app using CRNA and compare
In my case ejecting and using Expo react-native branch (default behavior) causes the issue. Changing back to official react-native npm package resolves the issue. So should be something on Expo's side.
I don't know if this may help you, but it fixed my issue within docker.
In Docker file
//////////////////////////////////////////////////////////////////////////
FROM node:8.9-alpine
RUN apk add --update \
libc6-compat
//////////////////////////////////////////////////////////////////////////
Needed libc6-compact
so try installing libc6-compat.
I had the same issue (below) when I was trying the start an app I got from my team in Expo. And it turned out that uws version in the project was not compatible with the Node version I was using. - node v10.15.0
Switching the node version to be 8.11.4 using nvm - nvm use 8.11.4 solved my issue. (If there is no 8.11.4 version installed use nvm install 8.11.4 instead)
$ expo start
Starting project at /Users/dugong/development/myApp
Expo DevTools is running at http://localhost:19002
Opening DevTools in the browser... (press shift-d to disable)
oteDev] Start server...
--------------------------------------------------------------------------------
[Busy] Launching SocketCluster
1555352786943 - Origin: Worker (PID 63541)
[Error] Error: Compilation of µWebSockets has failed and there is no pre-compiled binary available for your system. Please install a supported C++11 compiler and reinstall the module 'uws'.
at native (/Users/dugong/development/myApp/node_modules/socketcluster-server/node_modules/uws/uws.js:38:19)

NativeScript : An Uncaught Exception Occurred on main thread on android(In ios runs perfectly)

I am new to nativescript i developed a simple app for learning purpose. i tried to run it in ios it works.whereas in android i cant run
the following is the error iam facing
Following is my Package.json
{
"description": "NativeScript Application",
"license": "SEE LICENSE IN <your-license-filename>",
"readme": "NativeScript Application",
"repository": "<fill-your-repository-here>",
"nativescript": {
"id": "org.nativescript.excercises",
"tns-ios": {
"version": "2.5.2"
},
"tns-android": {
"version": "2.5.0"
}
},
"dependencies": {
"nativescript-checkbox": "^1.2.6",
"nativescript-platform-css": "^1.4.0",
"nativescript-star-ratings": "^0.1.0",
"nativescript-theme-core": "~1.0.2",
"nativescript-web-image-cache": "^3.4.0",
"tns-core-modules": "^2.5.1"
},
"devDependencies": {
"babel-traverse": "6.23.1",
"babel-types": "6.23.0",
"babylon": "6.16.1",
"lazy": "1.0.11",
"nativescript-dev-android-snapshot": "^0.*.*"
}
}
Thanks in advance

NativeScript build failed after adding telerik ui plugin

I'm building a NativeScript app. For implementing Drawer, I'm trying to use 'Telerik NativeScript UI' plugin. But, something is not working after installing the plugin & my NativeScript build is getting failed.
Here are 2 screenshots of the build failed.
My package.json file content
{
"description": "NativeScript Application",
"license": "SEE LICENSE IN <your-license-filename>",
"readme": "NativeScript Application",
"repository": "<fill-your-repository-here>",
"nativescript": {
"id": "org.nativescript.testapp",
"tns-android": {
"version": "2.0.0"
}
},
"dependencies": {
"#angular/common": "2.0.0-rc.1",
"#angular/compiler": "2.0.0-rc.1",
"#angular/core": "2.0.0-rc.1",
"#angular/platform-browser": "2.0.0-rc.1",
"#angular/platform-browser-dynamic": "2.0.0-rc.1",
"#angular/platform-server": "2.0.0-rc.1",
"#angular/router-deprecated": "2.0.0-rc.1",
"nativescript-angular": "0.1.1",
"nativescript-telerik-ui": "^1.1.1",
"tns-core-modules": "^2.0.0"
},
"devDependencies": {
"babel-traverse": "6.9.0",
"babel-types": "6.10.2",
"babylon": "6.8.1",
"filewalker": "0.1.2",
"lazy": "1.0.11",
"nativescript-dev-typescript": "^0.3.2",
"typescript": "^1.8.10"
}
}
My NativeScript CLI version is 2.0.1
Any idea, what's probably going wrong ?
-------It's fixed-------
The solution is, after getting the error..
Don't remove the plugin
Remove the platform(android/ios)
Add the platform once again(android/ios)
Rebuild the app
Try
platform remove android
and then
platform add android
tns run android
I have had this issue every time I try to add a new plugin to nativescript (e.g the phone, telerik-UI, and contact plugins). What worked for me was just navigating into platform > android and then running gradlew clean. This way you wouldn't have to re-add the android platform every time you add a plugin.

Resources