[enter image description here][1]My React Native Android application works perfectly fine on POCO X2 , if I install it via USB. But if I assemble the .apk or .aab ,the app get installed but do not perform action like Login or register.
Please note , this issue is specific for POCO X2 phone. It is working on other phones.
Phone model POCO-X2 , Android 10 , API 29.
I am attaching my build.gradle config:
List item
buildscript {
ext {
buildToolsVersion = "28.0.3"
minSdkVersion = 16
compileSdkVersion = 28
targetSdkVersion = 29
}
[1]: https://i.stack.imgur.com/Yl1sM.jpg
Well, I figured it out. I tried to install same application bundle on other android 10 devices and it wasn't working on any.
That means something was blocking the http request made by the application and the actual issue was that latest RN versions target recent Android SDK that blocks insecure HTTP connections automatically.
Just by adding this : android:usesCleartextTraffic="true" inside manifest file inside tag , my problem was solved.Attached the link here
Another solution for this problem is to avoid making http request as they are insecure, and use https instead.
<application ... android:usesCleartextTraffic="true"
Related
So I have seen that Android 13 has been officially released. But, when I searched for it in the official page, I have seen that it appears as beta version: https://developer.android.com/studio/releases/platforms#13
So, my question is, is it better to wait some time so that it is safe to target that Android 13 version?
I would say - it depends on your app, but mostly sure, it's safe. For example, we faced a couple of issues with the notification permission and a foreground service and it took some time to fix and test it, and it's always better to test such things on a real device rather than an emulator with a strange behaviour coming from the newest system image. If you don't have any particular/hardware places which should be tested on a physical device only, then I think that it's safe enough - you'll have plenty of time to fix any random roughnesses :)
Yes it is safe, Mine is given below in android/build
.gradle
ext {
buildToolsVersion = "33.0.1"
minSdkVersion = 23
compileSdkVersion = 33
targetSdkVersion = 33
androidXCore = "1.6.0"
kotlinVersion = "1.6.0"
}
I followed this page: https://developer.android.com/about/versions/13/setup-sdk
to set up Android 13 SDK.
In my build.gradle:
android {
compileSdkVersion("Tiramisu")
defaultConfig {
targetSdkVersion("Tiramisu")
}
}
Then I got the error:
> Unsupported value: Tiramisu. Format must be one of:
- android-31
- android-31-ext2
- android-T
- vendorName:addonName:31
I tried to use "33" instead of "Tiramisu", but it's not working.
I'm using the latest Android Studio Preview as the instruction.
Is there anyone trying to use Android 13 SDK?
This answer is no longer valid because you can use API version 33 now for Tiramisu as it's officially released
Credit to #NickolaySavchenko - Posting this answer since I've been waiting for him for a day.
Finally, after taking advice from #NickolaySavchenko - I have a final working code like this.
compileSdkVersion "android-Tiramisu"
targetSdkVersion "Tiramisu"
Yes, you see it correctly, the targetSdkVersion is Tiramisu, not android-Tiramisu so that it can run in an emulator API Tiramisu device.
I tested and can confirm that minSdkVersion doesn't need to change to android-Tiramisu or Tiramisu. I'm still keeping it as 19 and it's working great.
As #NickolaySavchenko said
compileSdkPreview "android-Tiramisu"
targetSdkPreview "android-Tiramisu"
working fine
and to run it on android 13 you also need to change your minSdk to "android-Tiramisu"
Fetching non-https url are failing after updating sdk version to 26. This happens only in production build. In development mode everything works fine. Here is the piece of code:
fetch('http://something.com/').then(
r => {},
e => console.error(e));
This produces the following in logcat:
08-12 19:08:47.555 14586 14623 E ReactNativeJS: [TypeError: Network request failed]
Here is my android/app/build.gradle file:
android {
compileSdkVersion 23
buildToolsVersion "27.0.3"
defaultConfig {
...
minSdkVersion 16
targetSdkVersion 26
versionCode 28
versionName "0.1.0"
}
...
}
Try with some other http client, for example axios
You might need to add INTERNET permissions to your AndroidManifest.xml.
Like this:
<manifest xlmns:android...>
...
<uses-permission android:name="android.permission.INTERNET" />
<application ...
</manifest>
Another reason might be that your request contains charset: utf-8 in the header. This can be a problem if you ping non-latin servers. In that case your server admin needs to update his nginx (or whatever he uses for web-serving) settings to allow that header.
Last but not least the problem might be a virtual router.
The thing is, that iOS is running in a simulator and Android is running in an emulator.
The localhost is pointing to the environment in which the code is running. The emulator emulates a real device while the simulator is only imitating the device.
Therefore the localhost on Android is pointing to the emulated Android device. And not to the machine on which your server is running.
The solution is to replace localhost with the IP address of your machine.
i have successfully made a project apk which allow the watch download the wear app. And i am trying to use that wearable code to support standalone for wear 2.0 as well - seem not much resources in the internet.
my question is how to determine if the wearable device is 1.0 or 2.0. i made use of productFlavors based on this link as follows:
android {
// Allows you to reference product flavors in your
// phone module's build.gradle file
publishNonDefault true
...
defaultConfig
{
// This is the minSdkVersion of the Wear 1.x embedded app
minSdkVersion 23
...
}
buildTypes {...}
productFlavors {
wear1 {
// Use the defaultConfig value
}
wear2 {
minSdkVersion 25
}
}
}
As i recalled, wear 1.0 usually collect data from phone and wear 2.0 has ability to access data via the internet. Please correct me if i am wrong.
So if the wearable is 1.0, it uses Wearable.API and sync with the phone. Otherwise, the wearable sync with cloud.
I had a look on this post which seems useful but i do not quite understand.
PackageManager pm = getApplicationContext().getPackageManager();
pm.getPackageInfo(packagename, PackageManager.GET_ACTIVITIES);
Should i set a different packagename(or applicationId) for wear2 so that i can use this method?
is there any drawback when i put standalone version on play store? i suppose i have to create a new project in this way.
Please can anyone advise the best way to achieve my purpose?
If you want to distribute and maintain two separate APKs, then the build flavor is probably a reasonable way to go. But I would suggest that this won't be a good experience for either you or your users; it's more work for you, and it'll be confusing for them (which version do I install? why doesn't this app work after I my watch upgraded to Wear 2.0? and so on).
My suggestion would be to put it all in one APK, and simply choose which sync technique to use at run time:
if (Build.VERSION.SDK_INT < 24) {
// Wear 1.x
} else {
// Wear 2+
}
NativeScript 2.0.0, Windows 10
When trying to run more than one NativeScript application on the same android device the tns run android command stops with message:
Successfully deployed on device with identifier '192.168.99.100:5555'.
The application is not installed.
After some investigation, I tried to install the app on the android device using adb directly:
adb "-s" "192.168.99.100:5555" "install" "-r" "<path to apk>.apk"
The command responds with the following:
961 KB/s (15394490 bytes in 15.642s)
WARNING: linker: /system/lib/libhoudini.so has text relocations. This is wasting memory and prevents security hardening. Please fix.
pkg: /data/local/tmp/<app name>-debug.apk
Failure [INSTALL_FAILED_CONFLICTING_PROVIDER]
After some investigation on INSTALL_FAILED_CONFLICTING_PROVIDER and found the following links:
https://issues.apache.org/jira/browse/CB-10014
https://code.google.com/p/analytics-issues/issues/detail?id=784
Install shows error in console: INSTALL FAILED CONFLICTING PROVIDER
I can say it's an ugly problem.
Researching some more, in the NativeScript project, in the directory \platforms\android\build\intermediates\exploded-aar\com.google.android.gms\play-services-measurement\8.4.0 directory there is a manifest template that contains:
<provider
android:authorities="${applicationId}.google_measurement_service"
android:name="com.google.android.gms.measurement.AppMeasurementContentProvider"
android:exported="false"/>
But applicationId is never defined, so when more than one app with this provider is added, the second one fails to install.
I have multiple NS apps installed on my phone and emulators; however when you create a new app; check to see if somehow you have ended up with the same internal name. (This can easily happen if you duplicate your prior project)
Open up your main/primary package.json file that resides in the outermost root of your project folder.
Inside this package.json file you should have a key:
"nativescript": {
"id": "org.nativescript.test3",
"tns-android": {
"version": "2.0.0"
}
},
The "id" is the underlying name of the app that will be installed on the phone. In this case; this is the awesome "org.nativescript.test3" project.
If you get duplicate id's then the the app will overwrite the each other when deployed.
There is a second reason this can happen, and the actual cause of this issue was figured out by the author of the question also. But I will stick here for any future people who might run into this so that we have a valid answer.
The author was using Google Play Services plugin, it has a AppMeasurementContentProvider that if you don't have a applicationId set in your configuration it will default to a blank id; which then means it will conflict with any other app that is using GPS that also doesn't have a applicationId set.
The real nastyness of this bug is that it will conflict with ANY app from ANY other developer who also left their applicationId blank. And so then only ONE of the apps would be installable; any other app that has a blank applicationId would not be installable on that device.
The solution is to open up your /app/App_Resources/Android/app.gradle file and we will add a new value to it.
The current version as of NativeScript v2.00 looks something like this:
android {
defaultConfig {
generatedDensities = []
}
aaptOptions {
additionalParameters "--no-version-vectors"
}
}
If you recall the first part of this answer and about duplicate ids; the package.json we referenced gives you the name you want to use. So in my case I would add to the
defaultConfig {
applicationId = "org.nativescript.test3"
}
So the final file should look something like this:
android {
defaultConfig {
generatedDensities = []
applicationId = "org.nativescript.test3"
}
aaptOptions {
additionalParameters "--no-version-vectors"
}
}
This is related to:
Install shows error in console: INSTALL FAILED CONFLICTING PROVIDER
https://code.google.com/p/analytics-issues/issues/detail?id=784
This workaround worked for me:
in the app/App_Resources/Android/AndroidManifest.xml file add:
<provider
tools:replace="android:authorities"
android:name="com.google.android.gms.measurement.AppMeasurementContentProvider"
android:authorities="MY_APPLICATION_ID.gms.measurement.google_measurement_service"
android:exported="false" />
Where MY_APPLICATION_ID is the application's package (put it manually because __PACKAGE__ didn't work)
Don't forget to declare de tools namespace:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="__PACKAGE__" ...>