CodePush - Releasing an iOS bundle breaks Android and vice versa - android

Using react-native-code-push.
Whenever I release an iOS version (using code-push release-react ... ios), it breaks my Android code push. Next time I try to get an update I get the following error:
You attempted to set the key isPending with the value true on an
object that is meant to be immutable and has been frozen.
Then, if I release an Android version, it breaks my iOS, getting this error:
Update is invalid - A JS bundle file named "main.jsbundle" could not
be found within the downloaded contents. Please ensure that your app
is syncing with the correct deployment and that you are releasing your
CodePush updates using the exact same JS bundle file name that was
shipped with your app's binary.
It's very strange and the documentation doesn't say anything about collisions between the two platforms.

You need to setup an app for each platform
code-push app add [name]-ios
code-push app add [name]-android
i think the code-push release-react [app-name] [platform] ... the platform argument only tells the react-native bundler what entry file to use (index.ios.js or index.android.js) it doesnt work as "install only on ios"

Related

React Native Flipper Debugging Issue : "NO APPLICATION SELECTED"

I have managed to connect a device ( I see logs and see the tree of React Native elements), but now I have an issue with connecting the app - "NO APPLICATION SELECTED" is what I see. Any ideas to fix it?
Ran into the same problem on both iOS and Android with Flipper 0.135.0. Managed to make both work by following the steps below.
iOS
This answer solved the issue for me.
tl;dr
brew update && brew upgrade idb-companion
Also make sure you are installing the correct Cocoapod of Flipper by specifying the exact version in your Podfile with (for version 0.135.0)
use_flipper!({ 'Flipper'=> '0.135.0' })
Android
Ensure that ReactNativeFlipper.java is in the correct folder, as in this example project.
With for example the applicationId com.domain.appName, the correct path is
android/app/src/debug/java/com/domain/appName/ReactNativeFlipper.java
In my project this Java file was in the incorrect folder, which resulted in the Logcat error
java.lang.ClassNotFoundException: com.domain.appName.ReactNativeFlipper
Ensure that you are running the latest version of Flipper (0.120.0 as of this message) and then:
For Android:
Bump the FLIPPER_VERSION variable in android/gradle.properties, for example: FLIPPER_VERSION=0.120.0.
Run ./gradlew clean in the android directory.
For iOS:
Call use_flipper with a specific version in ios/Podfile, for example: use_flipper!({ 'Flipper' => '0.120.0' }).
Run pod install in the ios directory.
Reference: https://fbflipper.com/docs/getting-started/react-native/#using-the-latest-flipper-sdk
Go to settings and check if the path for your Sdk is correct
In my case issue was with the Emulator OS and API.
I used following combination and it worked:
Device: Pixel 4a
OS: Android 12
API: (Release Name: S, API level: 31, ABI: arm64-v8a, Target: Android 12
I also faced this issue, I was not seeing android simulator and the app to select, but it was working fine for iOS without any config.
The problem with my setup was that in the Flipper settings, the android SDK's path was not correct, after updating the path and restarting Flipper, it automatically detected the simulator and the app.
Hope this helps.
I was able to solve that on Android, open ReactNativeFlipper.java file
In the first line package com.yourappname; change it to exactly your package name inside AndroidManifest.xml
In the MainApplication.java there is a line like
initializeFlipper(this, getReactNativeHost().getReactInstanceManager());
inside onCreate() function. In my project this line was commented. I removed the comment and run react-native run-android and flipper get connected to the app

Cordova: cordova_plugins.js failed to load resource

I am learning to use cordova and i have been just doing a normal install of android platform in my cordova application, everything worked fine except for some errors i don't intent to fix just yet (which are external resource files loaded from javascript). I just installed phonegap-plugin-push for working on a push notification support, i believe i have to first register the device on which the notification should be recieved so i ran the app without any other configuration rather than downloading the libraries and putting the google-services.json file at the root application folder.
I try to find the commands for pushing but i am unabled to do so and i think it might be because of an error thrown in the console
Failed to load resource: net::ERR_FILE_NOT_FOUND /cordova_plugins.js
so i have been searching on google and i have found that i don't need to add anything but cordova.js as i have already done upon cordova application installation in order to work with cordova features.
I don't know if i have to add something else or if i am missing some code in order to make this plugin work, probably this plugin is not compatible with cordova but phonegap is built over cordova so i don't know.
in case it is necessary, this are the versions i am using:
Cordova-CLI: 7.1.0
Google Play Services: 46
Android support repository: 47
Android SDK: 26
I failed to say that the application running in cordova is done with angular and angular-ui-router.
After long hours of testing i've found out that the problem is caused by angular-ui-router, because i was using angular-ui-router i have set a <base href> tag in the head tag which is what is making cordova to fail, this is now actually how cordova is intended to work, it is because of how the files are placed. On android the files are placed in android_asset/www/, i don't know how the files are placed in other platforms, but when <base href> tag is set with a new value then the calls are now trying to be done in a directory where the files are not placed.
The solution in angular is to not set a <base href> tag and disable html5Mode in the config
app.config(["$stateProvider", "$locationProvider", "$urlRouterProvider",
function($stateProvider, $locationProvider, $urlRouterProvider){
// Set the default url state
// NOTE: Do not set <base href> tag, this breaks cordova calls
$urlRouterProvider.otherwise("/");
// Disable html5 native router mode
$locationProvider.html5Mode(false);
......
}
]);
I've realized this because in chrome device remote inspector i was getting error calls to wrong directories, by looking at the url where the application is running i saw that the calls were not in the proper directory

Two ane file conflict in one flex mobile application

I have two ane file for video recorder. One is for android and another is for ios device. Both have different package name and methods.
Now, i import both Native Extension in single project. And detect ios and android device following way:
if(Capabilities.version.indexOf('IOS') > -1) //for ios device
And
if(Capabilities.version.indexOf('AND') > -1) //for android device
And create object for each class. Now when i run that it gives error for another ane class not found.
Like Suppose i check in ios then gives error for android ane file class, Event not found. same for android.
If you have an ANE that only supports Android it won't be available at all when run in Ios (same is true for Ios). If it has a default implementation its classes will be available but if it doesn't then its classes will just not exist in that scope and error will be thrown if you try to reference them. When using ANE that only offer one platform implementation those ANE have to be used only when compiling for that platform. The way you can switch between ANEs easily is by using CONFIG constants.
EDIT: Defining constants. Right Click project and choose "properties", in "Actionscript compiler" add as many config lines as you see fit, for example:
-define=CONFIG::ANDROID,false
-define=CONFIG::IOS,false
Now wrap all code (including import statements) referencing the Android ANE and the IOS ANE with:
CONFIG::ANDROID
{
//android code here
}
CONFIG::IOS
{
//ios code here
}
Now your 2 config variables are set to false so no code in between "CONFIG::ANDROID" or "CONFIG::IOS" will be compiled with your app. Now if in "actionscript compiler" you change:
-define=CONFIG::ANDROID,true
All code that is in between "CONFIG::ANDROID" will be compiled (you can use "CONFIG::ANDROID" anywhere in your code as many times as you want).
So before compiling set one config to true and make sure the other is set to false and the right code for the right platform will be compiled.
Capabilities.version will tell you: "Specifies the Flash Player or AdobeĀ® AIRĀ® platform and version information." and not the OS version you are running on.
See here http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/system/Capabilities.html#version
You need to use Capabilities.os instead
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/system/Capabilities.html#os

Android Eclipse Switching between debug and release for XML file

I have an XML file that contains some config data for my Android App. In it there is config info that can be used for development and production. E.g. the link to our api can be set as follows:
For production:
<api>api.example.com</api>
For development:
<api>dev.example.com</api>
I keep this config file under /assets/app-config.xml
It is quite a hassle to keep having to remember which setting I have in the XML. Is there a way to automatically configure eclipse/ android so that it uses the production for runtime (export etc.) and the development when in debug mode.
Define multiple resources and use BuildConfig.DEBUG to conditionally get a resource or another:
<string name="url_api">api.example.com</string>
<string name="url_api_dev">dev.example.com</string>
When extracting the resource:
getString(BuildConfig.DEBUG ? R.string.url_api_dev : R.string.url_api);
This constant is set to true as long as you run from Eclipse. When you select the Export Signed Application Package option, it will be set to false.
If you use this method, it is a good idea to be aware of this bug.
Customize your build using ANT
Please refer the following link for more information
http://playaprogrammer.blogspot.com/2013/01/android-build-configuration-tutorial.html
I use this to create test and production builds from single source. You can have different configurations for development, QA, Production...

updating sencha touch 2 android app

I am trying to submit a update to the google play store for my sencha touch 2 app.
the following is my packager.json file.
{
"applicationName":"DBS",
"applicationId":"com.keshav.dbs",
"versionCode":"2",
"versionString":"1.0.1",
"iconName":"ic_launcher.png",
"inputPath":"./build/package/Android",
"outputPath":"./build/native/Android",
"configuration":"Release",
"platform":"Android",
"deviceType":"Universal",
"certificatePath":"/Developer/Android-Keystore/myAndroidKeyStore",
"certificateAlias":"myandroidkey",
"certificatePassword":"<password>",
"sdkPath":"/Developer/sdks/android-sdk-macosx",
"androidAPILevel":"16",
"orientations": [
"portrait"
]
}
I run the following command
sencha package run packager.json
this creates the apk file however when i try to upload the new apk i get a message saying the versonCode 1 is already in use.
The instruction of packaging on Senchas website dont include the "versionCode" property I added that my self
Does anyone know how to change the version code for sencha app?
I was able to edit platforms/cordova/android/AndroidManifest.xml and update the android:versionCode, then run sencha app build native
It built the new APK (signed, based on my config) and it was accepted by the Google Play store.
Much easier than un-packaging and repackaging.
well here it is ...
After looking around the internet i found this approach works....
After Sencah creates the package use apktool to un-package the apk then edit the AndroidManifest.xml and package it up again with apktool.
Note when you re-package the app tit will be unsigned so you will have to sign it again for it install on peoples devices

Categories

Resources