”“我尝试安装我的apk,但它给出了此消息。 程序包似乎已损坏。 这是我的build.gradle文件。”但是,当我将compilesdkversion更改为28时,它正在运行。直接从android studio运行该应用程序时,它正在运行,但是生成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'
}
答案 0 :(得分:0)
要完全测试您的应用与Android Q的兼容性并开始使用新的API,请打开您的 模块级 build.gradle
文件,并更新< strong> 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