skip to Main Content

I had built my app with eas build to get the .aab file to upload to the Google Play Console. And I am getting this error

Your app currently targets API level 30 and must target at least API
level 31 to ensure it is built on the latest APIs optimized for
security and performance. Change your app’s target API level to at
least 31

When I followed this How to change api level 29 to 30 in expo react native App to upgrade expo and expo-cli, I ran into a brunch of dependency issues. The app didn’t work after the upgrade.

The working expo version is 44.0.6 and expo-cli version is 5.4.12. After upgrading to expo version 46.0.0 and expo-cli version 5.5.1, even the eas build command fails, probably due to the dependency issues.

build error:
🤖 Android build failed:
Gradle build failed with unknown error. See logs for the "Run gradlew" phase for more information.

Looking at the "Run gradlew" logs, there are quite a few different errors. Here are some samples:

[stderr] Note: Some input files use or override a deprecated API.
[stderr] Note: Recompile with -Xlint:deprecation for details.
[stderr] Note: /home/expo/workingdir/build/node_modules/@react-native-community/slider/android/src/main/java/com/reactnativecommunity/slider/ReactSliderManager.java uses unchecked or unsafe operations.
[stderr] Note: Recompile with -Xlint:unchecked for details.
Task :react-native-community_datetimepicker:compileReleaseJavaWithJavac
Task :react-native-async-storage_async-storage:compileReleaseJavaWithJavac
[stderr] Note: Some input files use or override a deprecated API.
[stderr] Note: Recompile with -Xlint:deprecation for details.
[stderr] Note: /home/expo/workingdir/build/node_modules/@react-native-async-storage/async-storage/android/src/main/java/com/reactnativecommunity/asyncstorage/AsyncStorageModule.java
uses or overrides a deprecated API.
[stderr] Note: Recompile with -Xlint:deprecation for details.
[stderr] Note: /home/expo/workingdir/build/node_modules/@react-native-async-storage/async-storage/android/src/main/java/com/reactnativecommunity/asyncstorage/AsyncStoragePackage.java
uses unchecked or unsafe operations.
[stderr] Note: Recompile with -Xlint:unchecked for details.

5

Answers


  1. Chosen as BEST ANSWER

    There are a couple of issues upgrading to expo sdk 46. Here is the blog about the upgrade https://blog.expo.dev/expo-sdk-46-c2a1655f63f7.

    Issue #1 - dependencies: follow the answer from this post ViewPropTypes will be removed from React Native. Migrate to ViewPropTypes exported from 'deprecated-react-native-prop-types

    Issue #2 - eas build failed: If you scroll all the way down to the end of the log, it tells you which package it's having issues with. Turned out, I have some packages that are deprecated (see the Deprecations, renamings, and removals section from the expo blog). I either temporary removed them or use other package/library and the build worked.

    The .aab file was also accepted by Google Play.


  2. Replying to @Ben Phung about not being able to see the android directory in your expo react native project, just run "expo eject" in your project directory and you should be able to see it

    Login or Signup to reply.
  3. Run "npx expo prebuild" This Command To Configure android Folder Into Ur

    Login or Signup to reply.
  4. Guys Just Upgrade Ur Expo SDK 44.0.0 To 45.0.0 It’s Will Support API Level 31 compileSdkVersion = 31 targetSdkVersion = 31. For More Info Please Refer Expo SDK 45.0.0 Offical Document.

    enter image description here

    Login or Signup to reply.
  5. You have to upgrade almost every dependency if you have only build the sdk 29/30 Levels. These are the changes i have made

    your build.gradle schould look like this

    ext {
            buildToolsVersion = "29.0.3" // 30.0.2 will automaically be used
            minSdkVersion = 26
            compileSdkVersion = 31
            targetSdkVersion = 31
            ndkVersion = "20.1.5948944"
            playServicesVersion = '17.0.0' // or find latest version
            androidMapsUtilsVersion = '2.3.0'
        }
    

    additionally add this into your repositories (also build.gradle)

    repositories {
      jcenter() 
      google()
      maven { url 'https://plugins.gradle.org/m2/' }
    }
    

    and this

    dependencies {
        classpath 'com.android.tools.build:gradle:4.2.0'
    }
    

    After that, you have to add

    android:exported="false"

    to every provider and receiver inside your androidManifest.xml

    Then upgrade your gradle to version to at least 6.9

    distributionUrl=https://services.gradle.org/distributions/gradle-6.9.2-all.zip

    Now, go to your Podfile and add these lines

      pod 'React-callinvoker', :path => "../node_modules/react- 
            native/ReactCommon/callinvoker"
      pod 'ReactCommon/turbomodule/core', :path => "../node_modules/react- 
            native/ReactCommon"
    

    After all that magic you just have to upgrade you local java JDK by at least version 11 (dont forget to change the enviremnet variable to use the new JDK)

    Have fun

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search