Search code examples
javaandroidruntimeexception

Android Caused by: java.lang.RuntimeException


I got an error message just like in the title but there is no context to it its just Caused by: java.lang.RuntimeException how am I supposed to know what to fix if I don't know what caused it. The code is here: https://bitbucket.org/Hellscythe94/meet-up/src/master/

The error showed when I added this line to the Login Fragment: alertDialog.show();

But it doesn't work even after I comment it...

Please help I'm just starting with android.

OK I made a new blank project and just added the dependencies and tried to build it but got the same problem.

This is my project/build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {

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


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

allprojects {
    repositories {
        google()
        jcenter()
    }
}

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

and this is my project/app/build.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    defaultConfig {
        multiDexEnabled true
        applicationId "com.example.michalwolowiec.meetup"
        minSdkVersion 19
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

dependencies {
    def lifecycle_version = "1.1.1"
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    //MultiDex
    implementation 'com.android.support:multidex:1.0.3'
    //App compat
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support:support-v4:28.0.0'
    implementation 'com.android.support:support-media-compat:28.0.0'
    implementation 'com.android.support:design:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    //ViewModel and LiveData
    implementation "android.arch.lifecycle:extensions:$lifecycle_version"
    //Lifecycles only (no ViewModel or LiveData).
    //Support library depends on this lightweight import
    implementation "android.arch.lifecycle:runtime:$lifecycle_version"
    //firebase Authentication
    implementation 'com.google.firebase:firebase-core:16.0.6'
    implementation 'com.google.firebase:firebase-auth:16.1.0'
    //firebase cloud Firebase
    implementation 'com.google.firebase:firebase-firestore:17.1.4'
    //butterknife and lombok
    implementation 'com.jakewharton:butterknife:9.0.0-rc1'
    annotationProcessor 'com.jakewharton:butterknife-compiler:9.0.0-rc1'
    compileOnly 'org.projectlombok:lombok:1.18.4'
    annotationProcessor 'org.projectlombok:lombok:1.18.4'
    //google shit
    implementation 'com.google.android.gms:play-services-maps:16.0.0'
    implementation 'com.google.android.gms:play-services-location:16.0.0'
    //RX
    implementation 'io.reactivex.rxjava2:rxandroid:2.1.0'
    implementation 'io.reactivex.rxjava2:rxjava:2.2.3'
    //libraries
    implementation 'io.nlopez.smartlocation:library:3.3.3'
    implementation 'io.nlopez.smartlocation:rx:3.3.1'
    implementation 'com.google.code.gson:gson:2.8.5'
    //tests
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
apply 
plugin: 'com.google.gms.google-services'

So now can someone tell what am I doing wrong ?

The problem


Solution

  • enter image description hereDelete this from your gradle:

      compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
      }
    

    and add the configurations.all in your gradle:

    configurations.all {
    resolutionStrategy.eachDependency { DependencyResolveDetails details ->
        def requested = details.requested
        if (requested.group == 'com.android.support') {
            if (!requested.name.startsWith("multidex")) {
                details.useVersion '28.0.0'
            }
        }
    }
    }
    

    enter image description here