无法解析 com.android.support:support-annotations:25.4.0

Posted

技术标签:

【中文标题】无法解析 com.android.support:support-annotations:25.4.0【英文标题】:Could not resolve com.android.support:support-annotations:25.4.0 【发布时间】:2018-02-06 06:34:10 【问题描述】:

我使用颤振制作应用程序。当我在控制台中执行 flutte run 时(我在控制台中使用 Tor 作为 http 和 https 代理导致谷歌限制和美国对某些国家的制裁),我收到这样的错误:

[iraj@iraj-pc app]$ flutter run

Launching lib/main.dart on LG K520 in debug mode...
Initializing gradle...                                0.5s
Resolving dependencies...                                 
Error running gradle: Exit code 1 from: /home/iraj/Public/dart/exercise_flutter/app/android/gradlew app:properties:
NDK is missing a "platforms" directory.
If you are using NDK, verify the ndk.dir is set to a valid NDK directory.  It is currently set to /home/iraj/Public/bin/android-sdk-linux/ndk-bundle.
If you are not using NDK, unset the NDK variable from ANDROID_NDK_HOME or local.properties to remove this warning.

Incremental java compilation is an incubating feature.
Failed to validate the XML for the repository at URL 'https://dl.google.com/android/repository/repository2-1.xml/repository-12.xml'
Errors during XML parse:
White spaces are required between publicId and systemId.
org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 62; White spaces are required between publicId and systemId.
javax.xml.bind.UnmarshalException
 - with linked exception:
[org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 62; White spaces are required between publicId and systemId.]
Additionally, the fallback loader failed to parse the XML.
Failed to validate the XML for the repository at URL 'https://dl.google.com/android/repository/repository2-1.xml/repository-12.xml/sys-img.xml'
Failed to validate the XML for the repository at URL 'https://dl.google.com/android/repository/repository2-1.xml/repository-12.xml/addon.xml'
Errors during XML parse:
White spaces are required between publicId and systemId.
org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 62; White spaces are required between publicId and systemId.
javax.xml.bind.UnmarshalException
 - with linked exception:
[org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 62; White spaces are required between publicId and systemId.]
Additionally, the fallback loader failed to parse the XML.

BUILD FAILED

Total time: 2 mins 24.903 secs

[Fatal Error] support-annotations-25.4.0.pom:2:10: Already seen doctype.
[Fatal Error] support-annotations-25.4.0.pom:2:10: Already seen doctype.

FAILURE: Build failed with an exception.

* Where:
Build file '/home/iraj/Public/dart/exercise_flutter/app/android/build.gradle' line: 26

* What went wrong:
A problem occurred evaluating root project 'android'.
> A problem occurred configuring project ':app'.
   > Could not resolve all dependencies for configuration ':app:_debugAndroidTestApkCopy'.
      > Could not resolve com.android.support:support-annotations:25.4.0.
        Required by:
            project :app
         > Could not resolve com.android.support:support-annotations:25.4.0.
            > Could not parse POM https://maven.google.com/com/android/support/support-annotations/25.4.0/support-annotations-25.4.0.pom
               > Already seen doctype.
      > Could not resolve com.android.support:support-annotations:25.4.0.
        Required by:
            project :app > com.android.support.test:runner:0.5
         > Could not resolve com.android.support:support-annotations:25.4.0.
            > Could not parse POM https://maven.google.com/com/android/support/support-annotations/25.4.0/support-annotations-25.4.0.pom
               > Already seen doctype.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
Running 'gradlew assembleDebug'...                        
[Fatal Error] support-annotations-25.4.0.pom:2:10: Already seen doctype.
[Fatal Error] support-annotations-25.4.0.pom:2:10: Already seen doctype.

FAILURE: Build failed with an exception.

* Where:
Build file '/home/iraj/Public/dart/exercise_flutter/app/android/build.gradle' line: 26

* What went wrong:
A problem occurred evaluating root project 'android'.
> A problem occurred configuring project ':app'.
   > Could not resolve all dependencies for configuration ':app:_debugAndroidTestApkCopy'.
      > Could not resolve com.android.support:support-annotations:25.4.0.
        Required by:
            project :app
         > Could not resolve com.android.support:support-annotations:25.4.0.
            > Could not parse POM https://maven.google.com/com/android/support/support-annotations/25.4.0/support-annotations-25.4.0.pom
               > Already seen doctype.
      > Could not resolve com.android.support:support-annotations:25.4.0.
        Required by:
            project :app > com.android.support.test:runner:0.5
         > Could not resolve com.android.support:support-annotations:25.4.0.
            > Could not parse POM https://maven.google.com/com/android/support/support-annotations/25.4.0/support-annotations-25.4.0.pom
               > Already seen doctype.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
Gradle build failed: 1

颤振版本:

flutter --version  
Flutter • channel alpha • https://github.com/flutter/flutter.git
Framework • revision b156a0f054 (2 weeks ago) • 2017-08-11 22:01:40 -0700
Engine • revision fef7d827d6
Tools • Dart 1.25.0-dev.9.0

飞镖版本:

[iraj@iraj-pc app]$ dart --version
Dart VM version: 1.24.2 (Thu Jun 22 08:43:26 2017) on "linux_x64"

android 目标:

[iraj@iraj-pc app]$ android list target
Available Android targets:
----------
id: 1 or "android-23"
     Name: Android 6.0
     Type: Platform
     API level: 23
     Revision: 3
     Skins: HVGA, QVGA, WQVGA400, WQVGA432, WSVGA, WVGA800 (default), WVGA854, WXGA720, WXGA800, WXGA800-7in
 Tag/ABIs : no ABIs.
----------
id: 2 or "android-24"
     Name: Android 7.0
     Type: Platform
     API level: 24
     Revision: 2
     Skins: HVGA, QVGA, WQVGA400, WQVGA432, WSVGA, WVGA800 (default), WVGA854, WXGA720, WXGA800, WXGA800-7in
 Tag/ABIs : default/armeabi-v7a
----------
id: 3 or "android-25"
     Name: Android 7.1.1
     Type: Platform
     API level: 25
     Revision: 3
     Skins: HVGA, QVGA, WQVGA400, WQVGA432, WSVGA, WVGA800 (default), WVGA854, WXGA720, WXGA800, WXGA800-7in
 Tag/ABIs : google_apis/armeabi-v7a
----------
id: 4 or "Google Inc.:Google APIs:23"
     Name: Google APIs
     Type: Add-On
     Vendor: Google Inc.
     Revision: 1
     Description: Android + Google APIs
     Based on Android 6.0 (API level 23)
     Libraries:
      * com.android.future.usb.accessory (usb.jar)
          API for USB Accessories
      * com.google.android.media.effects (effects.jar)
          Collection of video effects
      * com.google.android.maps (maps.jar)
          API for Google Maps
     Skins: HVGA, QVGA, WQVGA400, WQVGA432, WSVGA, WVGA800 (default), WVGA854, WXGA720, WXGA800, WXGA800-7in
 Tag/ABIs : no ABIs.

在 maven 和 jcenter 存储库中甚至找不到 support-annotations-25.4.0。 有什么问题?

【问题讨论】:

看起来像是来自gradel的错误。您可以尝试将gradel标签添加到您的问题中。 我做了@EricSeidel @EricSeidel 我必须完全使用gradle 2.3.3 而不是gradle 3.3(我的系统上预装了3.3)。所以降级到 2.3.3 是解决方案。 【参考方案1】:

Android Support Library Setup docs 提到您可以通过 Android SDK 管理器获得支持库,但该功能很快就会被删除。

【讨论】:

【参考方案2】:

你可以查看官方文档。

从 25.4.0 开始:

重要提示:现在可以通过 Google 的 Maven 存储库获得支持库。如需更多信息,请参阅Support Library Setup。

确保存储库部分包含一个带有“https://maven.google.com”端点的 Maven 部分。

allprojects 
    repositories 
        jcenter()
        maven 
            url "https://maven.google.com"
        
    

【讨论】:

【参考方案3】:

我找到了解决方案。下面是buld.gradle 文件的一部分。我不得不将默认 gradle(gradle 3.3 在我的系统上)降级为gradle 2.3.3

buildscript 
    repositories 
        jcenter()
        maven 
            url "https://maven.google.com"
        
    

    dependencies 
        classpath 'com.android.tools.build:gradle:2.3.3'
    

【讨论】:

以上是关于无法解析 com.android.support:support-annotations:25.4.0的主要内容,如果未能解决你的问题,请参考以下文章

无法解析 com.android.support:support-annotations:25.4.0

无法解析 com.twitter.sdk.android:twitter:1.0.1 所需的 com.android.support:support-v4:21.0.0

Gradle构建失败,错误无法解析:com.android.support

无法在 Android Studio 新项目中解析 com.android.support:appcompat-v7:26.1.0

Build.gradle无法解析com.android.support

Cordova 构建错误:“无法解析配置 ':_debugApkCopy' > 的所有依赖项 > 找不到 com.android.support:appcompat-v7:27.0.2。”