在android studio中生成带有抖动的APK发布时发生错误

时间:2019-03-23 13:44:11

标签: gradle flutter

我可以毫无问题地构建调试apk,而且我可以在三个移动设备上尝试我的应用程序而没有任何错误,但是当我尝试构建已发布的apk时,我遇到了此错误:

D:\mis>flutter build apk
Initializing gradle...                                           1.0s
Resolving dependencies...                                        4.5s
Gradle task 'assembleRelease'...

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:lintVitalRelease'.
> Could not resolve all artifacts for configuration ':app:debugAndroidTestRuntimeClasspath'.
   > Could not resolve com.android.support:support-annotations:25.3.1.
     Required by:
         project :app
      > Cannot find a version of 'com.android.support:support-annotations' that satisfies the version constraints:
           Dependency path 'android:app:unspecified' --> 'com.android.support.test:runner:1.0.2' --> 'com.android.support:support-annotations:27.1.1'
           Dependency path 'android:app:unspecified' --> 'com.android.support.test:runner:1.0.2' --> 'com.android.support.test:monitor:1.0.2' --> 'com.android.support:support-annota
tions:27.1.1'
           Dependency path 'android:app:unspecified' --> 'com.android.support.test.espresso:espresso-core:3.0.2' --> 'com.android.support.test:runner:1.0.2' --> 'com.android.support
:support-annotations:27.1.1'
           Dependency path 'android:app:unspecified' --> 'com.alveliu.flutterfullpdfviewer:flutter_full_pdf_viewer:1.0.0' --> 'com.github.barteksc:android-pdf-viewer:2.8.2' --> 'com
.github.barteksc:pdfium-android:1.7.1' --> 'com.android.support:support-v4:25.3.1' --> 'com.android.support:support-compat:25.3.1' --> 'com.android.support:support-annotations:25.3.
1'
           Dependency path 'android:app:unspecified' --> 'com.alveliu.flutterfullpdfviewer:flutter_full_pdf_viewer:1.0.0' --> 'com.github.barteksc:android-pdf-viewer:2.8.2' --> 'com
.github.barteksc:pdfium-android:1.7.1' --> 'com.android.support:support-v4:25.3.1' --> 'com.android.support:support-media-compat:25.3.1' --> 'com.android.support:support-annotations
:25.3.1'
           Dependency path 'android:app:unspecified' --> 'com.alveliu.flutterfullpdfviewer:flutter_full_pdf_viewer:1.0.0' --> 'com.github.barteksc:android-pdf-viewer:2.8.2' --> 'com
.github.barteksc:pdfium-android:1.7.1' --> 'com.android.support:support-v4:25.3.1' --> 'com.android.support:support-core-utils:25.3.1' --> 'com.android.support:support-annotations:2
5.3.1'
           Dependency path 'android:app:unspecified' --> 'com.alveliu.flutterfullpdfviewer:flutter_full_pdf_viewer:1.0.0' --> 'com.github.barteksc:android-pdf-viewer:2.8.2' --> 'com
.github.barteksc:pdfium-android:1.7.1' --> 'com.android.support:support-v4:25.3.1' --> 'com.android.support:support-core-ui:25.3.1' --> 'com.android.support:support-annotations:25.3
.1'
           Constraint path 'android:app:unspecified' --> 'com.android.support:support-annotations' strictly '25.3.1' because of the following reason: debugRuntimeClasspath uses vers
ion 25.3.1
           Constraint path 'android:app:unspecified' --> 'com.android.support:support-annotations' strictly '25.3.1' because of the following reason: debugRuntimeClasspath uses vers
ion 25.3.1
           Constraint path 'android:app:unspecified' --> 'com.android.support:support-annotations' strictly '25.3.1' because of the following reason: debugRuntimeClasspath uses vers
ion 25.3.1
           Constraint path 'android:app:unspecified' --> 'com.android.support:support-annotations' strictly '25.3.1' because of the following reason: debugRuntimeClasspath uses vers
ion 25.3.1

   > Could not resolve com.android.support:support-annotations:27.1.1.
     Required by:
         project :app > com.android.support.test:runner:1.0.2
         project :app > com.android.support.test:runner:1.0.2 > com.android.support.test:monitor:1.0.2
      > Cannot find a version of 'com.android.support:support-annotations' that satisfies the version constraints:
           Dependency path 'android:app:unspecified' --> 'com.android.support.test:runner:1.0.2' --> 'com.android.support:support-annotations:27.1.1'
           Dependency path 'android:app:unspecified' --> 'com.android.support.test:runner:1.0.2' --> 'com.android.support.test:monitor:1.0.2' --> 'com.android.support:support-annota
tions:27.1.1'
           Dependency path 'android:app:unspecified' --> 'com.android.support.test.espresso:espresso-core:3.0.2' --> 'com.android.support.test:runner:1.0.2' --> 'com.android.support
:support-annotations:27.1.1'
           Dependency path 'android:app:unspecified' --> 'com.alveliu.flutterfullpdfviewer:flutter_full_pdf_viewer:1.0.0' --> 'com.github.barteksc:android-pdf-viewer:2.8.2' --> 'com
.github.barteksc:pdfium-android:1.7.1' --> 'com.android.support:support-v4:25.3.1' --> 'com.android.support:support-compat:25.3.1' --> 'com.android.support:support-annotations:25.3.
1'
           Dependency path 'android:app:unspecified' --> 'com.alveliu.flutterfullpdfviewer:flutter_full_pdf_viewer:1.0.0' --> 'com.github.barteksc:android-pdf-viewer:2.8.2' --> 'com
.github.barteksc:pdfium-android:1.7.1' --> 'com.android.support:support-v4:25.3.1' --> 'com.android.support:support-media-compat:25.3.1' --> 'com.android.support:support-annotations
:25.3.1'
           Dependency path 'android:app:unspecified' --> 'com.alveliu.flutterfullpdfviewer:flutter_full_pdf_viewer:1.0.0' --> 'com.github.barteksc:android-pdf-viewer:2.8.2' --> 'com
.github.barteksc:pdfium-android:1.7.1' --> 'com.android.support:support-v4:25.3.1' --> 'com.android.support:support-core-utils:25.3.1' --> 'com.android.support:support-annotations:2
5.3.1'
           Dependency path 'android:app:unspecified' --> 'com.alveliu.flutterfullpdfviewer:flutter_full_pdf_viewer:1.0.0' --> 'com.github.barteksc:android-pdf-viewer:2.8.2' --> 'com
.github.barteksc:pdfium-android:1.7.1' --> 'com.android.support:support-v4:25.3.1' --> 'com.android.support:support-core-ui:25.3.1' --> 'com.android.support:support-annotations:25.3
.1'
           Constraint path 'android:app:unspecified' --> 'com.android.support:support-annotations' strictly '25.3.1' because of the following reason: debugRuntimeClasspath uses vers
ion 25.3.1
           Constraint path 'android:app:unspecified' --> 'com.android.support:support-annotations' strictly '25.3.1' because of the following reason: debugRuntimeClasspath uses vers
ion 25.3.1
           Constraint path 'android:app:unspecified' --> 'com.android.support:support-annotations' strictly '25.3.1' because of the following reason: debugRuntimeClasspath uses vers
ion 25.3.1
           Constraint path 'android:app:unspecified' --> 'com.android.support:support-annotations' strictly '25.3.1' because of the following reason: debugRuntimeClasspath uses vers
ion 25.3.1

   > Could not resolve com.android.support:support-annotations:25.3.1.
     Required by:
         project :app > com.android.support:support-compat:25.3.1
         project :app > com.android.support:support-media-compat:25.3.1
         project :app > com.android.support:support-core-utils:25.3.1
         project :app > com.android.support:support-core-ui:25.3.1
      > Cannot find a version of 'com.android.support:support-annotations' that satisfies the version constraints:
           Dependency path 'android:app:unspecified' --> 'com.android.support.test:runner:1.0.2' --> 'com.android.support:support-annotations:27.1.1'
           Dependency path 'android:app:unspecified' --> 'com.android.support.test:runner:1.0.2' --> 'com.android.support.test:monitor:1.0.2' --> 'com.android.support:support-annota
tions:27.1.1'
           Dependency path 'android:app:unspecified' --> 'com.android.support.test.espresso:espresso-core:3.0.2' --> 'com.android.support.test:runner:1.0.2' --> 'com.android.support
:support-annotations:27.1.1'
           Dependency path 'android:app:unspecified' --> 'com.alveliu.flutterfullpdfviewer:flutter_full_pdf_viewer:1.0.0' --> 'com.github.barteksc:android-pdf-viewer:2.8.2' --> 'com
.github.barteksc:pdfium-android:1.7.1' --> 'com.android.support:support-v4:25.3.1' --> 'com.android.support:support-compat:25.3.1' --> 'com.android.support:support-annotations:25.3.
1'
           Dependency path 'android:app:unspecified' --> 'com.alveliu.flutterfullpdfviewer:flutter_full_pdf_viewer:1.0.0' --> 'com.github.barteksc:android-pdf-viewer:2.8.2' --> 'com
.github.barteksc:pdfium-android:1.7.1' --> 'com.android.support:support-v4:25.3.1' --> 'com.android.support:support-media-compat:25.3.1' --> 'com.android.support:support-annotations
:25.3.1'
           Dependency path 'android:app:unspecified' --> 'com.alveliu.flutterfullpdfviewer:flutter_full_pdf_viewer:1.0.0' --> 'com.github.barteksc:android-pdf-viewer:2.8.2' --> 'com
.github.barteksc:pdfium-android:1.7.1' --> 'com.android.support:support-v4:25.3.1' --> 'com.android.support:support-core-utils:25.3.1' --> 'com.android.support:support-annotations:2
5.3.1'
           Dependency path 'android:app:unspecified' --> 'com.alveliu.flutterfullpdfviewer:flutter_full_pdf_viewer:1.0.0' --> 'com.github.barteksc:android-pdf-viewer:2.8.2' --> 'com
.github.barteksc:pdfium-android:1.7.1' --> 'com.android.support:support-v4:25.3.1' --> 'com.android.support:support-core-ui:25.3.1' --> 'com.android.support:support-annotations:25.3
.1'
           Constraint path 'android:app:unspecified' --> 'com.android.support:support-annotations' strictly '25.3.1' because of the following reason: debugRuntimeClasspath uses vers
ion 25.3.1
           Constraint path 'android:app:unspecified' --> 'com.android.support:support-annotations' strictly '25.3.1' because of the following reason: debugRuntimeClasspath uses vers
ion 25.3.1
           Constraint path 'android:app:unspecified' --> 'com.android.support:support-annotations' strictly '25.3.1' because of the following reason: debugRuntimeClasspath uses vers
ion 25.3.1
           Constraint path 'android:app:unspecified' --> 'com.android.support:support-annotations' strictly '25.3.1' because of the following reason: debugRuntimeClasspath uses vers
ion 25.3.1


* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 5s
 6.4s
Gradle task assembleRelease failed with exit code 1

我下载了新的Gradle,但是仍然存在相同的问题吗?

这是我的build.gradle文件:

def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
    localPropertiesFile.withReader('UTF-8') { reader ->
        localProperties.load(reader)
    }
}

def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
    throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
    flutterVersionCode = '1'
}

def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
    flutterVersionName = '1.0'
}

apply plugin: 'com.android.application'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
    keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}


android {
    compileSdkVersion 28

    lintOptions {
        disable 'InvalidPackage'
    }

    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "com.example.mis"
        minSdkVersion 16
        targetSdkVersion 28
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }

   signingConfigs {
    release {
        keyAlias keystoreProperties['keyAlias']
        keyPassword keystoreProperties['keyPassword']
        storeFile file(keystoreProperties['storeFile'])
        storePassword keystoreProperties['storePassword']
    }
}
buildTypes {
    release {
        signingConfig signingConfigs.release
        minifyEnabled true
            useProguard true

            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
}

flutter {
    source '../..'
}

dependencies {
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}

我从哪里知道这个问题?以及如何解决呢?它来自Gradle吗?还是什么?

1 个答案:

答案 0 :(得分:1)

添加

lintOptions {
        disable 'InvalidPackage'
        checkReleaseBuilds false
}

android/app/build.gradle