React Expo changing target Android API - android

Recently we build Android Apps using react expo and build signed APK using bellow command expo build:android -t apk or Android App Bundle expo build:android -t app-bundle
After we build signed APK, we tried to upload to Playstore and some error appears that wanted us to upgrade target API from 26 to 28. Have explored and reading several QA at SO and many of them are intended for React Native. How we can publish our APK to Play Store?
Here are app.json
{
"expo": {
"name": "***",
"slug": "***",
"privacy": "public",
"sdkVersion": "32.0.0",
"platforms": [
"ios",
"android"
],
"version": "1.2.3",
"orientation": "portrait",
"icon": "./assets/logo.png",
"splash": {
"image": "./assets/splash.png",
"resizeMode": "contain",
"backgroundColor": "#ffffff"
},
"updates": {
"enabled": true,
"checkAutomatically": "ON_LOAD",
"fallbackToCacheTimeout": 0
},
"assetBundlePatterns": [
"**/*"
],
"ios": {
"supportsTablet": true
},
"android": {
"package": "com.qreatiq.foodmart",
"permissions": [
"CAMERA"
],
"googleServicesFile": "./google-services.json",
},
}
}
We've tried to check the documentation here and there are property for compileSDKVersion or related like native apps.
In Native app we can easily configure as bellow
compileSdkVersion 27
buildToolsVersion "27.0.3"
minSdkVersion 16
targetSdkVersion 27
How to do that at React Expo?
Update 1
after reading from developer.android.com
When you upload an APK, it needs to meet Google Play’s target API
level requirements. Starting August 1, 2019, Google Play requires that
new apps target at least Android 9.0 (API level 28), and that app
updates target Android 9.0 from November 1, 2019. Until these dates,
new apps and app updates must target at least Android 8.0 (API level
26).
Still doesn't have any idea for that things.

Follow these steps:
Close your Expo CLI server
In app.json, change sdkVersion to "34.0.0"
In package.json, change these dependencies:
react-native to "https://github.com/expo/react-native/archive/sdk-34.0.0.tar.gz"
expo to "^34.0.3"
react to "16.8.3" — (this exact version)
react-navigation to "^3.11.1"
jest-expo to "^34.0.0" (if you use it)
sentry-expo to "~1.13.0" (if you use it)
If you use react-navigation you should also run expo install react-native-gesture-handler react-native-reanimated
Delete your project’s node_modules directory and run npm install again or use yarn
Run expo start -c
After these steps, it should work.
Source: https://blog.expo.io/expo-sdk-34-is-now-available-4f7825239319

You need to change the sdkVersion property in your app.json and build the application again:
"sdkVersion": "34.0.0",
"platforms": [
"ios",
"android"
],
using the expo build:android -t app-bundle command.
Make sure you have the latest expo cli installed.
Here's the corresponding blog post.

Related

(EXPO) expo-build-properties ignored by eas-build

I'm on Expo SDK 44, did npx expo install expo-build-properties under my project directory, and added the following code in app.json:
"plugins": [
[
"expo-image-picker",
{
"photosPermission": "This app needs to access your photos to let you share them with your friends."
}
],
[
"expo-build-properties",
{
"android": {
"compileSdkVersion": 31,
"targetSdkVersion": 31,
"buildToolsVersion": "31.0.0"
},
"ios": {
"deploymentTarget": "13.0"
}
}
]
],
The app builds and runs fine, but when I upload the .aab file to the Google Play Console, I get "The current target API level of your app is 30, but the minimum target API level must be 31".
expo-build-properties does not exist in expo 44. You need to upgrade to expo 45 or higher

EAS ignoring local versionCode in build

I recently updated our Expo project from sdk 44 to 46.
During that process, I switched from Expo build:android to eas build -p android.
Everything is running as expected, except the version code is not compiled into the aab/apk files correctly, so I cant push updates to google play.
The version code is already set to 26, as we did release previous versions, and the semVer is 1.1.1 currently. EAS also doesn't show the correct version codes in the dashboard.
I tried setting "appVersionSource": "local" as well as "remote", but neither works. (As far as I understand, local should be the correct parameter.
eas build generally seems to ignore other parameters from the app.config.js, like the splash images, app icons and background colors (I didn't include those lines in the code examples below to keep it short)
eas.json
{
"cli": {
"version": ">= 2.3.0",
"appVersionSource": "local"
},
"build": {
...
"production": {
"channel": "production",
"env": {
"APP_ENV": "production"
},
"android": {
"buildType": "app-bundle",
"image": "latest"
}
}
},
"submit": {
"production": {}
}
}
app.config.js
import 'dotenv/config';
module.exports = {
expo: {
name: '...',
slug: '...',
version: '1.1.1',
assetBundlePatterns: ['**/*'],
android: {
package: '...',
versionCode: 26,
softwareKeyboardLayoutMode: 'pan',
},
extra: {
eas: {
projectId: '...',
},
releaseChannel: process.env.APP_ENV,
},
},
};
Eas showing the wrong version nr
Try running npx expo prebuild or npx expo run:android That would generate the native Android project, which is basically like the Bare workflow.
See the following post for some more details and what you can do:
https://forums.expo.dev/t/should-i-exclude-ios/63094/4
If this helped you I would really appreciate it if you mark this as the answer. Thanks :)

In what situations is it convenient to use an expo:publish to update my app or release a new version?

I've been wondering when it's reasonable to use expo:publish or release a new version.
the question, I have an app in the playstore and they asked me to make some small changes, for example (remove certain images and upload a pdf where those images would be).
in this kind of situation is it enough to use an expo:publish or should I release a new version?
you will need to release a new version as Google Play Console doesn't allow an .aib file when the version is unchanged... Update your version under expo{} and versionCode under android{} in app.json
{
"expo": {
"version": "1.0.5",//Increase this to like 1.0.6
"orientation": "portrait",
"icon": "./assets/",
"backgroundColor" : "#1c1c1c",
"updates": {
"fallbackToCacheTimeout": 0
},
"android": {
"package" : "com.app",
"versionCode": 6,//Increase this to example 7
"permissions": ["ACCESS_FINE_LOCATION"],
"config" : {},
}

31.0.0 is not a valid SDK Version. Option are 26.0.0 Unversioned

I can no longer run my app after updating expo version to 31.0.0. I needed this upgrade to do due iOS version 12 support. Thou after trying to build the Android app it is no longer working.
my package.json looks as below:
{
"name": "myapp",
"version": "0.1.0",
"private": true,
"devDependencies": {
"react-native-scripts": "1.13.1",
"jest-expo": "^31.0.0",
"react-test-renderer": "16.3.0-alpha.1"
},
"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": "jest"
},
"jest": {
"preset": "jest-expo"
},
"dependencies": {
"axios": "^0.18.0",
"expo": "^31.0.4",
"react": "16.5.0",
"react-native": "https://github.com/expo/react-native/archive/sdk-31.0.1.tar.gz",
"react-native-image-slider": "^2.0.3",
"react-native-onesignal": "^3.1.4",
"react-native-progress": "^3.4.0",
"react-native-render-html": "^3.9.3",
"react-navigation": "^1.5.11"
}
}
app.json looks like:
{
"expo": {
"sdkVersion": "31.0.0",
"name": "myapp",
"slug": "myapp",
"version": "0.1.1",
"isDetached": true,
"detach": {
"scheme": "expe6b74e69f7904f4b8961fc359e0dc1ce",
"androidExpoViewUrl": "https://s3.amazonaws.com/exp-exponent-view-code/android-v2.4.0-sdk26.0.0-e63d9209-070c-4118-b06b-c60e82da0b66.tar.gz"
},
"android": {
"package": "com.myapp"
}
}
}
Android build.gradle app looks like this.:
android {
compileSdkVersion 27
buildToolsVersion '26.0.1'
defaultConfig {
applicationId 'com.ferrometal12'
targetSdkVersion 27
versionCode 1
versionName '0.1.1'
ndk {
abiFilters 'armeabi-v7a', 'x86'
}
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
// Deprecated. Used by net.openid:appauth
manifestPlaceholders = [
'appAuthRedirectScheme': 'host.exp.exponent'
]
}
Any idea why this is not working on Android anymore?
NOte: before i had expo 26.0.0 I also had targetSdkVersion to 26, after updating expo I also updated targetSdkVersion to 27
UPDATE: This error occurs on emulator, I havent yet tried on real device, but I have the feeling that the same would be on real device too.
You have to uninstall and then install the Expo on your Android device.
Updated mobile expo app from play-store in android. It worked for me.
see the upgrade walk-trough ...
{
"react-native": "https://github.com/expo/react-native/archive/sdk-31.0.0.tar.gz",
"expo": "^31.0.0",
"react": "16.5.0"
}
that sdkVersion which you've changed, most likely is the Android SDK version and should be:
"sdkVersion": "26.0.0"
the current maximum would be 28.0.0, but when it asks for 26.0.0, this should possibly be used.
Good day,
THIS IS WORKING
If you are using android studio
uninstall expo in the virtual android device.
If you are not sure how
to uninstall you can delete the virtual device in Android Virtual
Device Manager so that all things are refreshed.
Reinstall the virtual device again
If you are using a real android device
find the expo and uninstall it.
My app is detached / ejected and I am using ExpoKit. The following configuration worked for me:
in package.json
"expo": "^31.0.6",
"expokit": "31.0.2",
"react": "16.5.0",
"react-native": "https://github.com/expo/react-native/archive/sdk-31.0.1.tar.gz",
in app.json
"sdkVersion": "31.0.0"
and seeing the upgrade walk-through
I experienced this problem today ; my Expo Android app brought this error after playstore updated this app.
I resolved the problem by installing an older version of Expo APP (You can find older versions of playstore apps on apkpure.com) and downloading Expo Android App of version 2.12 which supports SDK 31.0.0
This step is for ejected expo projects:
If you have run expo update 35.0.0 or other version and it did not solve the error, and if you had ejected your expo project...
Check if you have the right detach properties in your app.json. Note the sdk number on the URL for both iosExpoViewURL and androidExpoViewURL keys.
"detach": {
"iosExpoViewUrl": "https://s3.amazonaws.com/exp-exponent-view-code/ios-v2.13.0-sdk35.0.0-a30ebc9b-3db4-42f4-b677-e468076baf18.tar.gz",
"androidExpoViewUrl": "https://s3.amazonaws.com/exp-exponent-view-code/android-v2.13.0-sdk35.0.0-b816b7af-88da-4ca9-87a5-7438f0c21b6e.tar.gz"
}
I was facing the same issue.The issue was solved by clearing data and cache of Expo app on Android device. It works fine now.
To solve this issue just migrate to the latest version of node and expo cli. Uninstall expo on your phone and make a fresh install from the app store. You should be good to go.

ReactNative: Uncaught TypeError: Cannot read property 'forEach' of undefined, while building KitchenSink demo

I am trying to compile a 'kitchen-sink' demo, for 'react-native':
NativeBase-KitchenSink
, and I have followed the following links already:
Solution to "React native: Android project not found. Maybe run react-native android first?"
Solution to "Expo : Cannot find a module LogReporter"
That is, from the installation of 'npm' till the installation of required tools using 'Yarn'.
And now I am stuck myself:
a. I run the command npm install in the 'root directory' of this project.
b. Then I run expo start, I see that the problems addressed in link 1 and 2 have gone away.
c. Then when the browser is up, I issue expo build:android
The following error shows up:
[11:14:44] Checking if current build exists...
[11:14:48] No currently active or previous builds for this project.
[11:14:50] Publishing to channel 'default'...
[11:14:56] Building iOS bundle
[11:15:09] Building Android bundle
[11:15:20] Analyzing assets
[11:15:27] Uploading assets
[11:15:27] No assets to upload, skipped.
[11:15:27] Processing asset bundle patterns:
[11:15:27] - D:\Projects\ReactNativeProjects\AwesomeProject\**\*
[11:15:27] Cannot read property 'forEach' of undefined
[11:15:27] TypeError: Cannot read property 'forEach' of undefined
at C:\xdl#51.4.0\src\Project.js:903:26
at Generator.next (<anonymous>)
at step (C:\Users\hp\AppData\Roaming\npm\node_modules\expo-cli\node_modules\xdl\build\Project.js:2033:191)
at C:\Users\hp\AppData\Roaming\npm\node_modules\expo-cli\node_modules\xdl\build\Project.js:2033:361
Please help me know where I am wrong? Some posts say the code is correct.
[EDIT]:
I also did a new thing in my 'app.json', just before executing command react-native eject, to create Android and iOS folders:
(Note: It is not mandatory to issue the react-native eject command, as this will cause permanent change according to the documentations)
{
"expo": {
"name": "AwesomeProject",
"description": "A Kitchen Sink project.",
"slug": "AwesomeProject",
"privacy": "public",
"sdkVersion": "30.0.0",
"platforms": [
"ios",
"android"
],
"ios": {
"supportsTablet": true
},
"android": {
"package": "com.abhsax.first"
},
"version": "1.0.0",
"orientation": "portrait",
"icon": "./assets/logo.png",
"splash": {
"image": "./assets/splashscreen.png",
"resizeMode": "contain",
"backgroundColor": "#ffffff"
},
"updates": {
"fallbackToCacheTimeout": 0
},
"assetBundlePatterns": [
"**/*"
]
},
"changes": "----below are the changes----",
"name": "AwesomeProject",
"displayName": "AwesomeProject"
}
That is, just when I added:
"name": "AwesomeProject",
"displayName": "AwesomeProject"
at the bottom of my 'app.json'
the command react-native eject started working, which was not working earlier, as the output was:
App name must be defined in the app.json config file to define the
project name. It must not contain any spaces or dashes.
Clearly, it is the hybrid of two different versions of the package managers: 'Expo' and 'npm'.
But the 'forEach' error in the concern here, did not go away.
Further efforts done were useless, so I am not putting them here.
I shall keep on trying until I figure it out.
you have to upgrade the expo cli version
do npm install -g expo-cli
and then expo start again
I resolved this by knowing that I was again mixing up with the package managers: 'npm' and 'yarn', and this time you do not need 'expo' for time being or all-together, so modify your 'app.json', removing expo section.
All I had to do was to issue the following commands in order.
Add React Base
yarn add react-base --save
Install Peer Dependencies
The peer dependencies included from any 'npm' packages does not automatically get installed. Your application will not depend on it explicitly.
react-native link
In the case of this demo project, one dependency was missing:
react-native link react-native-vector-icons
Start Yarn
yarn start
Run on android device or simulator.
react-native run-android
[Note:] Java 8 is recommended to be installed instead of higher versions of Java. see: What to install? Java 8 or Java 10
I wish it helps.
Happy coding :-)
Try changing:
"assetBundlePatterns": ["**/*"] to "assetBundlePatterns": ["assets/*"]
in your app.json file.

Categories

Resources