首页 > 解决方案 > 无法从 Android Studio 生成签名 apk,但我可以在我的手机上运行它

问题描述

从android studio生成签名apk时出错。

找不到满足版本约束的 'junit:junit' 版本:依赖路径 'helloworld:app:unspecified' --> 'com.googlecode.json-simple:json-simple:1.1.1' --> 'junit :junit:4.10' 约束路径 'helloworld:app:unspecified' --> 'junit:junit:{strictly 4.10}' 原因如下: debugRuntimeClasspath 使用版本 4.10 依赖路径 'helloworld:app:unspecified' --> ' com.android.support.test.espresso:espresso-core:2.2.2' --> 'com.android.support.test:runner:0.5' --> 'junit:junit:4.12'

这是我的 buld.gradle 文件

> apply plugin: 'com.android.application'
> 
> ext.android_support_version = '26.1.0' ext.arch_version = '1.0.0'
> ext.retrofit_version = '2.3.0'
> 
> android {
>     compileSdkVersion 26
>     defaultConfig {
>         applicationId "com.example.helloworlddeveloper"
>         minSdkVersion 16
>         targetSdkVersion 26
>         versionCode 5
>         versionName "2.0"
>         testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
>         vectorDrawables.useSupportLibrary = true
>         multiDexEnabled true
>     }
>     buildTypes {
>         release {
>             minifyEnabled false
>             proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
>         }
>     }
> 
> }
> 
> dependencies {
>     implementation fileTree(dir: 'libs', include: ['*.jar'])
>     androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2',
> {
>         exclude group: 'com.android.support', module: 'support-annotations'
>     })
>     implementation "com.android.support:appcompat-v7:$android_support_version"
>     implementation('com.mikepenz:materialdrawer:5.9.2@aar') {
>         transitive = true
>     }
>     implementation('com.googlecode.json-simple:json-simple:1.1.1') {
>         exclude group: 'org.hamcrest', module: 'hamcrest-core'
>     }
>     implementation "com.android.support:appcompat-v7:$android_support_version"
>     implementation "com.android.support:design:$android_support_version"
>     implementation "com.android.support:recyclerview-v7:$android_support_version"
>     implementation "com.android.support:cardview-v7:$android_support_version"
>     implementation "com.squareup.retrofit2:retrofit:$retrofit_version"
>     implementation 'com.squareup.retrofit2:converter-gson:2.3.0'
>     implementation 'com.squareup.okhttp3:logging-interceptor:3.8.0'
>     implementation 'com.github.bumptech.glide:glide:3.8.0'
>     implementation "com.android.support:support-v4:$android_support_version"
>     implementation "com.android.support:support-vector-drawable:$android_support_version"
>     testImplementation 'junit:junit:4.12'
>     implementation 'com.android.support:multidex:1.0.3'
>     implementation 'com.google.android.gms:play-services-ads:17.1.2'
>     implementation 'com.google.firebase:firebase-messaging:17.3.4'
>     implementation 'com.github.judemanutd:autostarter:1.0.3'
> 
> } apply plugin: 'com.google.gms.google-services'

标签: androidandroid-studiojunitandroid-install-apk

解决方案


尝试添加implementation 'com.android.support:support-annotations:26.0.0'和删除它exclude group: 'com.android.support', module: 'support-annotations'


推荐阅读