Android Package name changes when building an app from a Flutter Module - android

I'm having a small problem. I'm trying to build an apk from a flutter module. I specified:
module:
androidX: true
androidPackage: com.my.package.name
The issue is that after I run flutter pub get, the applicationId is set to com.my.package.name.host.
I'd like to remove the .host part somehow as I'm trying to automate this and upload it to Firebase app distribution.
Any help is greatly appreciated.
Cheers,
Vlad

I ended up doing something like this:
lane :change_package_name do
path = "../../.android/app/build.gradle"
text = File.read(path)
updated = text.gsub(".host", "")
File.open(path, "w") { |file| file.puts updated }
end
it's a small fastlane script that removes the occurance of .host. Not the best solution but it works for now.

Related

How to get Package name and version Code, Version name in react native [duplicate]

I've made a timestamped versionName in build.gradle like 20150707.1125. I want to show the version of the package in react-native app in about window. How I could get versionName in code?
I've successfully used the React Native Device Info component to get the build details as specified in the Gradle config.
Once installed you can use:
DeviceInfo.getVersion()
To output the version, and:
DeviceInfo.getBuildNumber()
To get the build number.
If you want the version number in your package.json, you can also do:
var pkg = require('./package.json');
console.log(pkg.version);
import { version } from './package.json';
I couldn't get the package react-native-device-info to work. Ran into this issue Might need some gradle and java changes to make it fly.
Anyhow I got what I needed react-native-version-number. And I am happy with it.
import VersionNumber from 'react-native-version-number';
console.log('appVersion:', VersionNumber.appVersion)
Oh, and as it relates to gleaning the version from package.json. It feels wrong to me. I mean I had to try it just to see if it would work. I didn't realize that resource would be available at runtime on the device. It does work, but I also have some buildTypes debug foo going on in my build.gradle I learned here. So its nice to be getting the versionName like 0.1.7-debug straight from the horses mouth.
You can use react-native-device-info
And you can get app version for both iOS and Android by calling following method.
const version = DeviceInfo.getVersion();
// iOS: "1.0"
// Android: "1.0"
Hope this will help.
I used as reference the answer by #Marcos Demetrio
But I was using expo, so I did this:
import {expo} from '../../app.json'
And in the Component:
<Label>{expo.version}</Label>
No package install needed.
If you are using expo and you want lighter lib, use expo-application:
import * as Application from 'expo-application';
Application.nativeApplicationVersion //returns a string
// or
Application.nativeBuildVersion //returns a string
react-native-version-number library works for both Android and iOS. You can find installation instructions here. Remember that in current versions of ReactNative linking libraries is not needed anymore (omit linking while installing - it was not written in the instruction)
https://github.com/APSL/react-native-version-number
import VersionNumber from 'react-native-version-number';
...
render() {
var versionNumber = `${VersionNumber.appVersion}.${VersionNumber.buildVersion}`;
return (
<Text style={ styles.versionText }>v. {versionNumber}</Text>
)
}
...
I used the following snippet to extract version info using package.json:
import PackageJson from '../../../package' // where package is the package.json file
console.log('version', PackageJson.version)
Hope it helps.
I tried most of the thing to fix this nicely and I and happy to see detailed description for doing everything that I needed react-native-version-check
import { Linking } from 'react-native';
import VersionCheck from 'react-native-version-check';
VersionCheck.needUpdate()
.then(async res => {
console.log(res.isNeeded); // true
if (res.isNeeded) {
Linking.openURL(await VersionCheck.getStoreUrl()); // open store if update is needed.
}
});
If you use Expo Framework, you can use expo-constants package as documented in https://docs.expo.dev/versions/latest/sdk/constants/.
For me, this is working: grabs the version and description from the app.json: https://github.com/marcoXbresciani/TKCompanionApp/blob/0.1.12/screens/about/Version.tsx
So, only one point where to store things.
I think the easiest way is to set a version number in App.js just like a variable, and ensure it is global (gettable from the whole app)
const version = "1.0.0"
and do this i every build

Expo build apk : ExponentToken not generated

I created my first expo app, who can send notification to multiple users. I use the expo-notification package to generate the ExponentToken and handle incoming notification.
Everythings works perfecly when I use the expo go app, but recently I build my app in apk with eas
$ eas build -p android --profile genAPK
//the genAPK profile :
build: {
"genAPK":{
"android": {
"buildType":"apk"
}
}
}
I downloaded the builded apk, but when my real app want to generate the ExponentToken it just not works and return me a empty string... (I know it because my app crash do a alert() if the token is empty)
I don't know if this help, but I dont use the firebase way, I use the expo node sdk and my own database and API to store tokens and send notifications
Is this a common mistake and how can I fix this ?
Or at least can I see the output of my package even if this is a apk ?
Thanks in advance
My notification is also not working when i upgrade to EAS.
And i found this in Expo discord group:
No experienceId or projectId found. If one or the other can't be inferred from the manifest (eg. in bare workflow), you have to pass one in yourself.
at http://192.168.7.186:8081/node_modules/expo/AppEntry.bundle?platform=ios&dev=true&hot=false&minify=false:102608:321 in _createSuperInternal
at node_modules/expo-modules-core/build/errors/CodedError.js:10:8 in constructor
at http://192.168.7.186:8081/node_modules/expo/AppEntry.bundle?platform=ios&dev=true&hot=false&minify=false:313197:49 in getExpoPushTokenAsync$
There is a problem with ExpoPushToken, and you can see the source of this error from here expo-notifications-repo. The cause of this error in my case is the projectId, because in the expo-notifications-repo they use expo-constant package which have change in the latest SDK. So i need to add projectId to my app.json
"extra":{
"eas":{
"projectId":"(PROJECT_ID-Expo.dev)"
}
}

More than one file was found with OS independent path 'kotlin/reflect/reflect.kotlin_builtins' - Unity Project

I was trying to create Android build after exporting from Unity Project.
When I tried to export signed APK file, I got many errors and step by step , I have cleared all others.
But at present, get stuck on this one :
This is my Gradle file content :
I have tried Stackoverflow posts with similar problems. So I expect some other solution that work for me.
It seem it's an old post , but i m writing down here a solution it may help somebody else to solve this issue
In your app gradle (Kotlin DSL), add this block :
android {
//...
packagingOptions {
exclude("META-INF/kotlin-stdlib-common.kotlin_module")
exclude("META-INF/kotlin-stdlib-jdk7.kotlin_module")
exclude("META-INF/kotlin-stdlib-jdk8.kotlin_module")
exclude("META-INF/kotlin-stdlib.kotlin_module")
exclude("kotlin/annotation/annotation.kotlin_builtins")
exclude("kotlin/collections/collections.kotlin_builtins")
exclude("kotlin/coroutines/coroutines.kotlin_builtins")
exclude("kotlin/internal/internal.kotlin_builtins")
exclude("kotlin/kotlin.kotlin_builtins")
exclude("kotlin/ranges/ranges.kotlin_builtins")
exclude("kotlin/reflect/reflect.kotlin_builtins")
}
// ....
}
This will fix the build error.

include.gradle file being generated is causing problems

When building a project I get the following error:
Flavor 'nativescript-telerik-ui' has unknown dimension 'nativescript-telerik-ui'.
It happens only when using the pro version through the #progress registry. Doesn't happen with the local .tgz pro version.
I noticed the error has to do with the include.gradle file it generates. I read the following article: https://docs.nativescript.org/plugins/plugins#includegradle-specification
It says that when the plugin doesn't have the include.gradle, at build time gradle creates a default one with default elements. When I saw the include.gradle it generated for the plugin it seems to have generated a default one like so:
android {
productFlavors {
"nativescript-telerik-ui" {
dimension "nativescript-telerik-ui"
}
}
}
The include.gradle generated for the local .tgz version of the plugin is like this:
android {
productFlavors {
"F6" {
dimension "nativescripttelerikuipro"
}
}
}
I replaced the default include.gradle with the latter and it got past the error. You can recreate the problem by following these steps:
create a new hello world app
use the command npm login --registry=https://registry.npm.telerik.com/ --scope=#progress to log in if you're a paying customer.
use the command npm install --save #progress/nativescript-telerik-ui-pro to install the plugin
use tns run android
Is there anything I can do to solve this problem? Really need help on this.
My name is Vladimir and I am part of the nativescript-telerik-ui-pro team. Thank you for logging this issue in our feedback portal. We are going to review it as soon as possible and update you regarding its status, but from what I currently see there is some incorrect "parameters" passed to the 'pro' version of the plugin that are going to be resolved very fast.
We apologize for any inconvenience that this is causing.

How to get a versionName in react-native app on Android?

I've made a timestamped versionName in build.gradle like 20150707.1125. I want to show the version of the package in react-native app in about window. How I could get versionName in code?
I've successfully used the React Native Device Info component to get the build details as specified in the Gradle config.
Once installed you can use:
DeviceInfo.getVersion()
To output the version, and:
DeviceInfo.getBuildNumber()
To get the build number.
If you want the version number in your package.json, you can also do:
var pkg = require('./package.json');
console.log(pkg.version);
import { version } from './package.json';
I couldn't get the package react-native-device-info to work. Ran into this issue Might need some gradle and java changes to make it fly.
Anyhow I got what I needed react-native-version-number. And I am happy with it.
import VersionNumber from 'react-native-version-number';
console.log('appVersion:', VersionNumber.appVersion)
Oh, and as it relates to gleaning the version from package.json. It feels wrong to me. I mean I had to try it just to see if it would work. I didn't realize that resource would be available at runtime on the device. It does work, but I also have some buildTypes debug foo going on in my build.gradle I learned here. So its nice to be getting the versionName like 0.1.7-debug straight from the horses mouth.
You can use react-native-device-info
And you can get app version for both iOS and Android by calling following method.
const version = DeviceInfo.getVersion();
// iOS: "1.0"
// Android: "1.0"
Hope this will help.
I used as reference the answer by #Marcos Demetrio
But I was using expo, so I did this:
import {expo} from '../../app.json'
And in the Component:
<Label>{expo.version}</Label>
No package install needed.
If you are using expo and you want lighter lib, use expo-application:
import * as Application from 'expo-application';
Application.nativeApplicationVersion //returns a string
// or
Application.nativeBuildVersion //returns a string
react-native-version-number library works for both Android and iOS. You can find installation instructions here. Remember that in current versions of ReactNative linking libraries is not needed anymore (omit linking while installing - it was not written in the instruction)
https://github.com/APSL/react-native-version-number
import VersionNumber from 'react-native-version-number';
...
render() {
var versionNumber = `${VersionNumber.appVersion}.${VersionNumber.buildVersion}`;
return (
<Text style={ styles.versionText }>v. {versionNumber}</Text>
)
}
...
I used the following snippet to extract version info using package.json:
import PackageJson from '../../../package' // where package is the package.json file
console.log('version', PackageJson.version)
Hope it helps.
I tried most of the thing to fix this nicely and I and happy to see detailed description for doing everything that I needed react-native-version-check
import { Linking } from 'react-native';
import VersionCheck from 'react-native-version-check';
VersionCheck.needUpdate()
.then(async res => {
console.log(res.isNeeded); // true
if (res.isNeeded) {
Linking.openURL(await VersionCheck.getStoreUrl()); // open store if update is needed.
}
});
If you use Expo Framework, you can use expo-constants package as documented in https://docs.expo.dev/versions/latest/sdk/constants/.
For me, this is working: grabs the version and description from the app.json: https://github.com/marcoXbresciani/TKCompanionApp/blob/0.1.12/screens/about/Version.tsx
So, only one point where to store things.
I think the easiest way is to set a version number in App.js just like a variable, and ensure it is global (gettable from the whole app)
const version = "1.0.0"
and do this i every build

Categories

Resources