Raphael Corujo Moura
Raphael Corujo Moura

Reputation: 11

React Native Release app error in play console

I sent my application to the play store and in the play console appeared some clusters of error, after some downlaods. In my cellphone, this kind of failure has never happened.

Play Console Error:

java.lang.RuntimeException: 
    at android.app.ActivityThread.handleReceiver (ActivityThread.java:3334) 
    at android.app.ActivityThread.-wrap17 (Unknown Source) 
    at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1725) 
    at android.os.Handler.dispatchMessage (Handler.java:105) 
    at android.os.Looper.loop (Looper.java:164) 
    at android.app.ActivityThread.main (ActivityThread.java:6694) 
    at java.lang.reflect.Method.invoke (Native Method) 
    at com.android.internal.os.Zygote$MethodAndArgsCaller.run (Zygote.java:240) 
    at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:769)
Caused by: java.lang.ClassNotFoundException: 
    at dalvik.system.BaseDexClassLoader.findClass (BaseDexClassLoader.java:93)
    at java.lang.ClassLoader.loadClass (ClassLoader.java:379)
    at java.lang.ClassLoader.loadClass (ClassLoader.java:312)
  at android.app.ActivityThread.handleReceiver (ActivityThread.java:3329)

My Setting Gradle:

    rootProject.name = project_name
    include ':react-native-firebase'
    project(':react-native-firebase').projectDir = new     File(rootProject.projectDir, '../node_modules/react-native-firebase/android')
    include ':react-native-snackbar'
    project(':react-native-snackbar').projectDir = new         File(rootProject.projectDir, '../node_modules/react-native-snackbar/android')
    include ':react-native-vector-icons'
    project(':react-native-vector-icons').projectDir = new     File(rootProject.projectDir, '../node_modules/react-native-vector-icons/android')
    include ':react-native-text-input-mask'
    project(':react-native-text-input-mask').projectDir = new     File(rootProject.projectDir, '../node_modules/react-native-text-input-    mask/android')

    include ':app'

My build.gradle

    buildscript {
    repositories {
        google()
        maven {
            url 'https://maven.google.com/'
            name 'Google'
        }
        jcenter()
    }
        dependencies {
            classpath 'com.android.tools.build:gradle:3.1.3'
            classpath 'com.google.gms:google-services:4.0.1'
        }
    }

    allprojects {
        repositories {
            mavenLocal()
            maven {
                url "$rootDir/../node_modules/react-native/android"
            }
            maven {
                url 'https://maven.google.com/'
                name 'Google'
            }
            google()
            jcenter()
        }
    }

ext {
    buildToolsVersion = "26.0.3"
    minSdkVersion = 16
    compileSdkVersion = 26
    targetSdkVersion = 26
    supportLibVersion = "26.1.0"
}

My app/build.gradle

...
dependencies {
    implementation project(':react-native-firebase')
    compile project(':react-native-snackbar')
    implementation project(':react-native-vector-icons')
    compile project(':react-native-text-input-mask')
    compile fileTree(dir: "libs", include: ["*.jar"])
    compile "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
    compile "com.facebook.react:react-native:+"  // From node_modules

    implementation "com.google.android.gms:play-services-base:15.0.1"
    implementation "com.google.firebase:firebase-core:16.0.1"
    implementation "com.google.firebase:firebase-messaging:17.1.0"
    implementation 'me.leolin:ShortcutBadger:1.1.21@aar' 

}

I do not know what's going on and how to fix it. Can anyone help me to solve this problem?

Upvotes: 1

Views: 228

Answers (1)

Andrew
Andrew

Reputation: 28539

This looks like a dex issue. You need to enable multidex support.

As you are targeting a minSDKVersion of 16 you need to add the following to your dependencies

implementation 'com.android.support:multidex:1.0.3'

You will also need to enable multidex in your defaultConfig in your android/app/build.gradle

defaultConfig {
  // there will be other things here like applicationId, minSdkVersion, versionCode etc.
  multiDexEnabled true
}

You also need to change the following line in your MainApplication.java from

public class MainApplication extends Application implements ReactApplication {

to

public class MainApplication extends MultiDexApplication implements ReactApplication {

You can read more about enabling multidex here https://developer.android.com/studio/build/multidex as there are different ways to enable it depending on whether you override the Application class.

Upvotes: 1

Related Questions