解决Android Studio高版本新建不了AIDL文件

4,885 阅读1分钟
偶尔一次升级了AS版本 然后发现在高版本的AS中创建AIDL文件如下图 :

置灰:Requires setting the buildFeatures.aidl to true in the build file

image.png

解决办法:

build.gradle(app) 添加 buildFeatures{aidl true}

android {
namespace 'com.example.testkotlin'
compileSdk 33

    defaultConfig {
        applicationId "com.example.testkotlin"
        minSdk 24
        targetSdk 33
        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
    }
    kotlinOptions {
        jvmTarget = '1.8'
    }
    buildFeatures {
        compose true
        // Disable unused AGP features
        buildConfig false
        aidl true
        renderScript false
        resValues false
        shaders false
    }
}