>"我试图安装我的apk,但它给出了这条消息。包似乎已损坏。这是我的build.gradle文件"。但是,当我将 compilesdkversion 更改为 28 时,它正在运行。在直接从安卓工作室运行该应用程序时,它正在运行,但在生成 apk 后它没有安装?
apply plugin: 'com.android.application'
android {
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
compileSdkVersion 'android-Q'
defaultConfig {
applicationId "com.example.deskneedui"
minSdkVersion 21
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'com.wdullaer:materialdatetimepicker:4.2.0'
implementation 'com.google.android.material:material:1.0.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
implementation 'com.android.volley:dc-volley:1.1.0'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'com.wdullaer:materialdatetimepicker:4.2.0'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'com.google.android.gms:play-services-maps:16.1.0'
implementation 'com.google.android.gms:play-services-location:16.0.0'
}
要全面测试您的应用与 Android Q 的兼容性并开始使用新的 API,请打开模块级build.gradle
文件并更新compileSdkVersion and targetSdkVersion
,如下所示
android {
compileSdkVersion 29
defaultConfig {
targetSdkVersion 29
}
}
仅供参考
您的classpath
将是
classpath 'com.android.tools.build:gradle:3.4.1'
distributionUrl
将是
distributionUrl=https://services.gradle.org/distributions/gradle-5.1.1-all.zip