Android 引起的:java.lang.RuntimeException [英] Android Caused by: java.lang.RuntimeException

查看:66
本文介绍了Android 引起的:java.lang.RuntimeException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到了一条错误消息,就像标题一样,但没有上下文,它只是由:java.lang.RuntimeException 如果我不知道是什么原因引起的,我怎么知道要修复它.代码在这里:

解决方案

从你的 gradle 中删除:

 compileOptions {sourceCompatibility JavaVersion.VERSION_1_8targetCompatibility JavaVersion.VERSION_1_8}

并在您的gradle中添加configuration.all:

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

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 ?

解决方案

Delete 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'
        }
    }
}
}

这篇关于Android 引起的:java.lang.RuntimeException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆