Quantcast
Channel: Active questions tagged react-native+android - Stack Overflow
Viewing all articles
Browse latest Browse all 28479

React Native app crash on start - Android

$
0
0

enter image description hereI have a live react native app which was working fine before I integrate firebase cloud messaging. After integration it started crashing app. After that I removed all firebase integration from app and it still kept on crashing everytime I run app on my Android device. It always crash on start on both debug as well as release version of the app.

Here is the logcat:

2019-11-27 18:16:25.292 24260-24280/? E/ReactNativeJS: TypeError: undefined is not an object (evaluating 'new f.ListView.DataSource')
2019-11-27 18:16:25.297 24260-24280/? E/ReactNativeJS: Invariant Violation: Module AppRegistry is not a registered callable module (calling runApplication)

    --------- beginning of crash
2019-11-27 18:16:25.299 24260-24281/? E/AndroidRuntime: FATAL EXCEPTION: mqt_native_modules
    Process: com.telehealthcare, PID: 24260
    com.facebook.react.common.JavascriptException: TypeError: undefined is not an object (evaluating 'new f.ListView.DataSource'), stack:
    <unknown>@881:701
    v@2:1474
    <unknown>@6:347
    v@2:1474
    d@2:876
    global code@1026:4

        at com.facebook.react.modules.core.ExceptionsManagerModule.reportException(ExceptionsManagerModule.java:71)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:371)
        at com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:150)
        at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)
        at android.os.Handler.handleCallback(Handler.java:789)
        at android.os.Handler.dispatchMessage(Handler.java:98)
        at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:26)
        at android.os.Looper.loop(Looper.java:164)
        at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(MessageQueueThreadImpl.java:225)
        at java.lang.Thread.run(Thread.java:764)

Project Level build file:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    ext {
        buildToolsVersion = "29.0.0"
        minSdkVersion = 21
        compileSdkVersion = 29
        targetSdkVersion = 29
        supportLibVersion = "27.1.1"
    }
    repositories {
        google()
        jcenter()
        maven { // <---- Add this block
            url "https://github.com/jitsi/jitsi-maven-repository/raw/master/releases"
        }
    }
    dependencies {
//        classpath 'com.android.tools.build:gradle:3.1.4'
        classpath 'com.android.tools.build:gradle:3.3.0'
        classpath 'com.google.gms:google-services:4.3.2'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        mavenLocal()
        google()
        jcenter()
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url "$rootDir/../node_modules/react-native/android"
        }
        maven { // <---- Add this block
            url "https://github.com/jitsi/jitsi-maven-repository/raw/master/releases"
        }
    }
}


task wrapper(type: Wrapper) {
    gradleVersion = '4.4'
    distributionUrl = distributionUrl.replace("bin", "all")
}

App Level build.gradle:

apply plugin: "com.android.application"
//apply plugin: 'com.google.gms.google-services'
//com.google.gms.googleservices.GoogleServicesPlugin
import com.android.build.OutputFile

project.ext.react = [
    entryFile: "index.js",
    enableHermes: false,
//    bundleAssetName: "app.bundle",
]

apply from: "../../node_modules/react-native/react.gradle"

def enableSeparateBuildPerCPUArchitecture = false

def enableProguardInReleaseBuilds = false

def jscFlavor = 'org.webkit:android-jsc:+'

def enableHermes = project.ext.react.get("enableHermes", false);

android {
    compileSdkVersion rootProject.ext.compileSdkVersion
    buildToolsVersion '29.0.0'

    defaultConfig {
        applicationId "com.telehealcare"
        minSdkVersion 21
        targetSdkVersion 29
        versionCode 9
        versionName "1.0"
        multiDexEnabled true
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
//        ndk {
//            abiFilters "armeabi-v7a", "x86"
//        }
    }
    splits {
        abi {
            reset()
            enable enableSeparateBuildPerCPUArchitecture
            universalApk false  // If true, also generate a universal APK
//            include "armeabi-v7a", "x86"
            include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
        }
    }

    buildTypes {
        debug {
            debuggable true
        }
        release {
            multiDexKeepFile file('multidex-config.txt')
            minifyEnabled enableProguardInReleaseBuilds
            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
            signingConfig signingConfigs.release
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    applicationVariants.all { variant ->
        variant.outputs.each { output ->
//            def versionCodes = ["armeabi-v7a":1, "x86":2]
            def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4]
            def abi = output.getFilter(OutputFile.ABI)
            if (abi != null) {  // null for the universal-debug, universal-release variants
                output.versionCodeOverride =
                        versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
            }
        }
    }

    packagingOptions {
        pickFirst '**/armeabi-v7a/libc++_shared.so'
        pickFirst '**/x86/libc++_shared.so'
        pickFirst '**/arm64-v8a/libc++_shared.so'
        pickFirst '**/x86_64/libc++_shared.so'
        pickFirst '**/x86/libjsc.so'
        pickFirst '**/armeabi-v7a/libjsc.so'
    }
}


dependencies {
    implementation project(':react-native-cardview')
    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
    implementation "com.facebook.react:react-native:+"  // From node_modules
    implementation 'com.facebook.fresco:animated-gif:1.10.0'
    implementation project(':react-native-contacts')
    implementation(project(':react-native-jitsi-meet'))

    // Jitsi Meet
    implementation ('org.jitsi.react:jitsi-meet-sdk:2.+') { transitive = true }


    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'androidx.appcompat:appcompat:1.1.0-alpha03'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.2.0'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
    implementation 'com.android.support:multidex:1.0.3'


    if (enableHermes) {
        def hermesPath = "../../node_modules/hermes-engine/android/";
        debugImplementation files(hermesPath + "hermes-debug.aar")
        releaseImplementation files(hermesPath + "hermes-release.aar")
    } else {
        implementation jscFlavor
    }
//    implementation "com.google.android.gms:play-services-base:15.0.1"
//    implementation "com.google.firebase:firebase-core:15.0.0"
//    implementation "com.google.firebase:firebase-auth:17.0.0"
//    implementation 'com.google.firebase:firebase-messaging:20.0.0'

//     Glide
//    implementation("com.github.bumptech.glide:glide:4.7.1") {
//        exclude group: "com.android.support", module: "glide"
//    }
//    implementation("com.github.bumptech.glide:annotations:4.7.1") {
//        exclude group: "com.android.support", module: "annotations"
//    }
}

// Run this once to be able to run the application with BUCK
// puts all compile dependencies into folder libs for BUCK to use
task copyDownloadableDepsToLibs(type: Copy) {
    from configurations.compile
    into 'libs'
}

configurations.all {
    resolutionStrategy.eachDependency { DependencyResolveDetails details ->
        def requested = details.requested
        if (requested.group == "androidx") {
            if (!requested.name.startsWith("multidex")) {
                details.useVersion "${targetSdk}.+"
            }
        }
    }
}
//apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)

package.json file:

{
  "name": "TeleHealCare",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start",
    "test": "jest",
    "android": "react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res && react-native run-android",
    "ios": "react-native run-ios"
  },
  "dependencies": {
    "moment": "^2.24.0",
    "react": "16.6.3",
    "react-moment": "^0.9.2",
    "react-native": "^0.61.4",
    "react-native-animatable": "^1.3.0",
    "react-native-calendars": "^1.21.0",
    "react-native-card-stack-swiper": "^1.1.0",
    "react-native-cardview": "^2.0.2",
    "react-native-circular-action-menu": "^0.5.0",
    "react-native-contacts": "^2.2.4",
    "react-native-datepicker-dialog": "0.0.9",
    "react-native-elements": "^1.0.0-beta7",
    "react-native-expandable-section-list": "^1.0.7",
    "react-native-jitsi-meet": "^1.2.0",
    "react-native-loader": "^1.2.1",
    "react-native-material-dropdown": "^0.11.1",
    "react-native-material-textfield": "^0.12.0",
    "react-native-modal-datetime-picker": "^6.0.0",
    "react-native-parallax-scroll-view": "^0.21.3",
    "react-native-swipeout": "^2.3.6",
    "react-native-switch": "^1.5.0",
    "react-native-tab-view": "^1.3.1",
    "react-native-table-component": "^1.2.0",
    "react-native-vector-icons": "^6.4.2",
    "react-navigation": "^2.18.2",
    "toggle-switch-react-native": "^2.0.2",
    "url-search-params": "^1.1.0"
  },
  "devDependencies": {
    "babel-jest": "23.6.0",
    "jest": "23.6.0",
    "metro-react-native-babel-preset": "0.51.1",
    "react-test-renderer": "16.6.3"
  },
  "jest": {
    "preset": "react-native"
  }
}

MainApplication.java:

public class MainApplication extends MultiDexApplication implements ReactApplication {

    private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
        @Override
        public boolean getUseDeveloperSupport() {
            return BuildConfig.DEBUG;
        }

        @Override
        protected List<ReactPackage> getPackages() {

            return Arrays.<ReactPackage>asList(
                    new MainReactPackage(),
                    new JitsiMeetPackage(),
                    new RNCardViewPackage(),
                    new ReactNativeContacts()
            );
        }

        @Override
        protected String getJSMainModuleName() {
            return "index";
        }

    };

    @Override
    public ReactNativeHost getReactNativeHost() {
        return mReactNativeHost;
    }

    @Override
    public void onCreate() {
        super.onCreate();
        SoLoader.init(this, /* native exopackage */ false);
    }
}

MainActivity.java:

public class MainActivity extends ReactActivity {
    private static MainActivity mainActivity;

    @Override
    protected String getMainComponentName() {
        return "TeleHealCare";
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mainActivity = this;
    }

    public static void callJitsi(){
        mainActivity.startActivity(new Intent(mainActivity,JitsiActivity.class));
    }
}

Please do let me know what is going wrong here. Any help will be appreciate!


Viewing all articles
Browse latest Browse all 28479

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>