| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- plugins {
- id 'com.android.application'
- id 'org.jetbrains.kotlin.android'
- }
- android {
- namespace 'com.example.myapp' // AGP 8.0+ 强制要求命名空间
- // 建议使用 34 或 35,AGP 9.0 支持最高 36
- compileSdk = 35
- defaultConfig {
- applicationId "com.example.myapp"
- minSdk = 21
- targetSdk = 35 // 建议与 compileSdk 保持一致
- versionCode 1
- versionName "1.0"
- testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
- }
- buildTypes {
- release {
- minifyEnabled false
- proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
- }
- }
- // 编译选项:AGP 9.0 + Gradle 9.1 推荐使用 Java 17 或 21
- compileOptions {
- sourceCompatibility = JavaVersion.VERSION_21
- targetCompatibility = JavaVersion.VERSION_21
- }
- kotlinOptions {
- jvmTarget = '21'
- }
- // 可选:启用构建特征预览 (如果需要使用新特性)
- // buildFeatures {
- // viewBinding true
- // }
- }
- dependencies {
- // Kotlin 标准库通常由插件自动引入,无需显式声明,除非需要特定版本
- // implementation "org.jetbrains.kotlin:kotlin-stdlib:2.0.21"
- implementation 'androidx.core:core-ktx:1.15.0' // 使用较新版本以适配 SDK 35
- implementation 'androidx.appcompat:appcompat:1.7.0'
- implementation 'com.google.android.material:material:1.12.0'
- testImplementation 'junit:junit:4.13.2'
- androidTestImplementation 'androidx.test.ext:junit:1.2.1'
- androidTestImplementation 'androidx.test.espresso:espresso-core:3.6.1'
- }
|