同期に失敗するJavaVersion 1.8原因のGradleに設定compileOptions

Woutervh:

私は私のアプリ(JSONライブラリの使用方法、すなわち)にいくつかのJava 8つの機能を使用したいです

しかし、私が追加したとき

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

私へbuild.gradleのGradleのプロジェクト同期failes:

A problem occurred configuring project ':app'.
java.lang.NullPointerException (no error message)

私がインストールされている次のバージョンのJavaでのUbuntu 19.04にAndroidのスタジオを使用しています

wouter@Wouter-Laptop:~/Android/Sdk$ sudo update-alternatives --config java 
There are 2 choices for the alternative java (providing /usr/bin/java).

  Selection    Path                                            Priority   Status
------------------------------------------------------------
* 0            /usr/lib/jvm/java-11-openjdk-amd64/bin/java      1111      auto mode
  1            /usr/lib/jvm/java-11-openjdk-amd64/bin/java      1111      manual mode
  2            /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java   1081      manual mode

Press <enter> to keep the current choice[*], or type selection number: 0
update-alternatives: using /usr/lib/jvm/java-11-openjdk-amd64/bin/java to provide /usr/bin/java (java) in auto mode
wouter@Wouter-Laptop:~/Android/Sdk$ sudo update-alternatives --config javac
There are 2 choices for the alternative javac (providing /usr/bin/javac).

  Selection    Path                                          Priority   Status
------------------------------------------------------------
* 0            /usr/lib/jvm/java-11-openjdk-amd64/bin/javac   1111      auto mode
  1            /usr/lib/jvm/java-11-openjdk-amd64/bin/javac   1111      manual mode
  2            /usr/lib/jvm/java-8-openjdk-amd64/bin/javac    1081      manual mode

Press <enter> to keep the current choice[*], or type selection number: 0
update-alternatives: using /usr/lib/jvm/java-11-openjdk-amd64/bin/javac to provide /usr/bin/javac (java

私のbuild.gradleように見えます

    apply plugin: 'com.android.application'

    android {
        signingConfigs {
        }
        compileSdkVersion 29
        buildToolsVersion "29.0.2"
        defaultConfig {
            applicationId "nl.wouter.cycleweatherapp"
            minSdkVersion 21
            targetSdkVersion 29
            versionCode 1
            versionName "1.0"
            testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        }
        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
            }
        }
        compileOptions {
            sourceCompatibility JavaVersion.VERSION_1_8
            targetCompatibility JavaVersion.VERSION_1_8
        }
    }

    repositories {
        mavenCentral()
    }


    dependencies {
        implementation fileTree(include: ['*.jar'], dir: 'libs')
        implementation 'androidx.appcompat:appcompat:1.0.0-beta01'
        implementation 'com.google.android.gms:play-services-maps:17.0.0'
        implementation 'org.osmdroid:osmdroid-android:6.1.2'
        implementation 'androidx.constraintlayout:constraintlayout:1.1.2'
        implementation 'com.google.android.material:material:1.0.0-beta01'
        testImplementation 'junit:junit:4.12'
        androidTestImplementation 'androidx.test:runner:1.1.0-alpha4'
        androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0-alpha4'
    }

でJava 1.8の部分を削除しbuild.gradleたファイルと、エラーを除去するが、何のjavaに1.8の機能を付与するものではありません。私はGradleのキャッシュを無効にして再生成しようとしているJavaのバージョンを切り替えてインストールする次。

私はどのように、缶誰の助けに私を続行する見当もつかない?

Woutervh:

私は最終的にvitrualboxにUbuntuのLTSをインストールし、開発を行うためにこれを使用することによってそれを修正します

おすすめ

転載: http://43.154.161.224:23101/article/api/json?id=333120&siteId=1