android 项目出现一些与 ANDROID_SDK_HOME 相关的错误

android project its getting some error related to ANDROID_SDK_HOME

(当我尝试 运行 项目时)错误是 构建文件 'C:\Users\jupun\Desktop\trid-7\codecanyon-22842942-trid-city-guide-android-native-with-admin-panel-firebase\Trid-Android-Package\Android code\Trid-CityGuide_v7\app\build.gradle' 行:1

评估项目“:app”时出现问题。

Failed to apply plugin 'com.android.internal.application'. ANDROID_SDK_HOME is set to the root of your SDK: C:\Users\jupun\AppData\Local\Android\Sdk ANDROID_SDK_HOME was meant to be the parent path of the preference folder expected by the Android tools. It is now deprecated.

gradle.build

 apply plugin: 'com.android.application'
apply plugin: 'com.google.firebase.crashlytics'
apply plugin: 'realm-android'
buildscript {
    repositories {
        jcenter()
        google()
    }

    dependencies {

        classpath 'com.android.tools.build:gradle:7.0.1'
        //        classpath 'io.fabric.tools:gradle:1.+'
//        classpath "io.realm:realm-gradle-plugin:4.2.0"
        classpath "io.realm:realm-gradle-plugin:5.11.0"
        classpath 'com.google.gms:google-services:4.3.3'
        classpath 'com.google.firebase:firebase-crashlytics-gradle:2.3.0'


    }
}

repositories {
    mavenCentral()
    jcenter()
    google()
    maven { url 'https://maven.fabric.io/public' }
    maven {
        url "https://oss.sonatype.org/content/repositories/snapshots"
    }
}


android {
    compileSdkVersion 28
    buildToolsVersion '31.0.0'
    defaultConfig {
      applicationId    "com.tripeka.travel"   // "com.bpackingapp.vietnam.travel"// "com.traveeva.android"//"com.rwandadestinations.android"
        //  "com.traveeva.android"// "com.rhodes.guide" "com.rwandadestinations.android"
        // com.bpackingapp.vietnam.travel
        minSdkVersion 21
        targetSdkVersion 28
        versionCode 21
        versionName "1.14"
        multiDexEnabled true
        resValue "string", "google_maps_key", (project.findProperty("GOOGLE_MAPS_API_KEY") ?: "")
    }
    dexOptions {
        jumboMode = true
        javaMaxHeapSize "4g" //specify the heap size for the dex process
    }
    buildTypes {
        release {
            minifyEnabled false
            shrinkResources false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            proguardFiles getDefaultProguardFile('proguard-android.txt')

            splits {
                abi {
                    enable true
                    reset()
                    include 'x86', 'x86_64', 'armeabi', 'armeabi-v7a', 'mips', 'mips64', 'arm64-v8a'
                    universalApk false
                }
            }

        }
    }

    packagingOptions {
//        exclude "lib/arm64-v8a/librealm-jni.so"
//        exclude "lib/armeabi/librealm-jni.so"
//        exclude "lib/mips/librealm-jni.so"
//        exclude "lib/x86_64/librealm-jni.so"
//        exclude "lib/x86/librealm-jni.so"
    }

    lintOptions {
        checkReleaseBuilds false
        abortOnError false
    }

    configurations.all {
        resolutionStrategy.force 'com.google.code.findbugs:jsr305:1.3.9'
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.google.firebase:firebase-crashlytics:17.2.1'
    implementation 'com.google.firebase:firebase-analytics:17.5.0'
    androidTestImplementation('androidx.test.espresso:espresso-core:3.1.0', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })

//    List view animation


    // Slider Image

    //    compile 'com.firebase:firebase-client-android:2.0.3+'

//    compile('com.facebook.android:facebook-android-sdk:4.23.0')

    //noinspection GradleCompatible
    implementation 'androidx.appcompat:appcompat:1.0.0'
//
    implementation 'com.google.android.material:material:1.0.0'
    implementation 'com.nhaarman.listviewanimations:lib-core:3.1.0@aar'
//
    implementation 'com.nhaarman.listviewanimations:lib-manipulation:3.1.0@aar'
//
    implementation 'com.nhaarman.listviewanimations:lib-core-slh:3.1.0@aar'
//
    implementation 'com.google.android.gms:play-services:11.6.2'
    implementation 'androidx.multidex:multidex:2.0.0'
    implementation 'com.google.firebase:firebase-core:11.6.2'
    implementation 'com.squareup.picasso:picasso:2.5.2'
    implementation 'com.nineoldandroids:library:2.4.0'
    implementation 'com.daimajia.slider:library:1.1.5@aar'
    implementation 'com.google.firebase:firebase-auth:11.6.2'
    implementation 'com.facebook.android:facebook-android-sdk:4.23.+'
    implementation 'com.nostra13.universalimageloader:universal-image-loader:1.9.4'
    implementation 'pl.charmas.android:android-reactive-location:0.10@aar'
    implementation 'com.google.android.gms:play-services-location:11.6.2'
    implementation 'com.google.android.gms:play-services-places:11.6.2'
    implementation 'io.reactivex:rxjava:1.2.0'
    implementation 'com.github.zurche:open-weather-map-android-wrapper:v0.1'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
//    compile 'io.realm:realm-android:4.2.0'
    implementation 'com.timehop.stickyheadersrecyclerview:library:[0.4.3]@aar'
    implementation 'org.florescu.android.rangeseekbar:rangeseekbar-library:0.3.0'
    implementation 'de.hdodenhof:circleimageview:2.1.0'
    testImplementation 'junit:junit:4.12'

    implementation 'org.solovyev.android.views:linear-layout-manager:0.5@aar'
    implementation 'com.google.maps.android:android-maps-utils:0.5+'


    implementation 'com.google.android.gms:play-services-ads:11.6.2'

}
// ADD THIS AT THE BOTTOM
apply plugin: 'com.google.gms.google-services'
Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

此错误主要发生在您更新 gradle.build 中的任何库时 尝试回滚您更新的任何最新库。

在我的情况下有所不同,我不得不更改为类似的东西:

export ANDROID_HOME=/home/$USER/Android
export ANDROID_SDK_ROOT=$ANDROID_HOME/Sdk

而androidsdk位于:/home/$USER/Android/Sdk

OS: Ubuntu 20.04