简体   繁体   中英

App stopped working when i start the app

I made a app for login with google, facebook and email app using firebase. But when i test it it comes "Unfortunately, this app has stopped working.". It doesn't even start during start-up only the pop up appears. I actually got a few errors in the logcat but i don't know how to solve it so ended up here to get help. The error causing this is this i think Didn't find class "com.google.firebase.provider.FirebaseInitProvider"

I tried doing all multidex things but nothing worked.

Please help me!

logcat

04-27 10:51:15.304 2731-2731/thenerdimite.userauthentication D/dalvikvm: Not late-enabling CheckJNI (already on)
04-27 10:51:15.314 2731-2731/thenerdimite.userauthentication D/AndroidRuntime: Shutting down VM
04-27 10:51:15.314 2731-2731/thenerdimite.userauthentication W/dalvikvm: threadid=1: thread exiting with uncaught exception (group=0xa4ffb678)
04-27 10:51:15.314 2731-2731/thenerdimite.userauthentication E/AndroidRuntime: FATAL EXCEPTION: main
    java.lang.RuntimeException: Unable to get provider com.google.firebase.provider.FirebaseInitProvider: java.lang.ClassNotFoundException: Didn't find class "com.google.firebase.provider.FirebaseInitProvider" on path: DexPathList[[zip file "/data/app/thenerdimite.userauthentication-1.apk"],nativeLibraryDirectories=[/data/app-lib/thenerdimite.userauthentication-1, /vendor/lib, /system/lib]]
    at android.app.ActivityThread.installProvider(ActivityThread.java:4882)
    at android.app.ActivityThread.installContentProviders(ActivityThread.java:4485)
    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4425)
    at android.app.ActivityThread.access$1300(ActivityThread.java:141)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1316)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:137)
    at android.app.ActivityThread.main(ActivityThread.java:5103)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:525)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
    at dalvik.system.NativeStart.main(Native Method)
    Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.firebase.provider.FirebaseInitProvider" on path: DexPathList[[zip file "/data/app/thenerdimite.userauthentication-1.apk"],nativeLibraryDirectories=[/data/app-lib/thenerdimite.userauthentication-1, /vendor/lib, /system/lib]]
    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:53)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
    at android.app.ActivityThread.installProvider(ActivityThread.java:4867)
    at android.app.ActivityThread.installContentProviders(ActivityThread.java:4485) 
    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4425) 
    at android.app.ActivityThread.access$1300(ActivityThread.java:141) 
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1316) 
    at android.os.Handler.dispatchMessage(Handler.java:99) 
    at android.os.Looper.loop(Looper.java:137) 
    at android.app.ActivityThread.main(ActivityThread.java:5103) 
    at java.lang.reflect.Method.invokeNative(Native Method) 
    at java.lang.reflect.Method.invoke(Method.java:525) 
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737) 
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553) 
    at dalvik.system.NativeStart.main(Native Method) 
04-27 10:51:18.284 2731-2731/thenerdimite.userauthentication I/Process: Sending signal. PID: 2731 SIG: 9

MainActivity.java

package thenerdimite.userauthentication;

import android.support.multidex.MultiDex;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

import com.firebase.ui.auth.AuthUI;
import com.google.firebase.auth.FirebaseAuth;

public class MainActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    MultiDex.install(this);

    FirebaseAuth auth = FirebaseAuth.getInstance();
    startActivityForResult(AuthUI.getInstance().createSignInIntentBuilder().setProviders(AuthUI.FACEBOOK_PROVIDER, AuthUI.EMAIL_PROVIDER, AuthUI.GOOGLE_PROVIDER).build(), 1);
}

}

App level gradle file

    apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.2"
    defaultConfig {
        applicationId "thenerdimite.userauthentication"
        minSdkVersion 16
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    defaultConfig {
        applicationId "thenerdimite.userauthentication"
        minSdkVersion 16
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
    }

}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:25.3.1'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    testCompile 'junit:junit:4.12'
    compile 'com.google.firebase:firebase-core:10.2.1'
    compile 'com.google.firebase:firebase-auth:10.2.1'
    compile 'com.google.firebase:firebase-database:10.2.1'
    compile 'com.google.firebase:firebase-storage:10.2.1'
    compile 'com.firebaseui:firebase-ui:0.4.4'
    compile 'com.google.android.gms:play-services-auth:10.2.1'
    compile 'com.google.android.gms:play-services:10.2.1'
    compile 'com.android.support:design:25.3.1'
    compile 'com.android.support:mediarouter-v7:25.3.1'
    compile 'com.android.support:cardview-v7:25.3.1'
    compile 'com.android.support:customtabs:25.3.1'
    compile 'com.android.support:multidex:1.0.1'

}

apply plugin: 'com.google.gms.google-services'

Project level gradle

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

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.1'
        classpath 'com.google.gms:google-services:3.0.0'

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

allprojects {
    repositories {
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="thenerdimite.userauthentication">

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme"
        android:name="android.support.multidex.MultiDexApplication">
    </application>

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

Any help would be greatly appreciated! Thanks!

Include this in your project level Gradle

allprojects {
    repositories {
        jcenter()
        mavenLocal()
        maven { url 'https://maven.fabric.io/public' }
    }
}

And you need this in your app level Gradle

compile 'com.firebaseui:firebase-ui-auth:1.2.0'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM