找不到runtime.jar(android.arch.lifecycle:runtime:1.0.0)

boy*_*oyd 38 android gradle cordova ionic-framework

我跑步后ionic cordova build android得到这个错误:

FAILURE: Build failed with an exception.

* What went wrong:
Could not resolve all files for configuration ':debugCompileClasspath'.
> Could not find runtime.jar (android.arch.lifecycle:runtime:1.0.0).
  Searched in the following locations:
  https://jcenter.bintray.com/android/arch/lifecycle/runtime/1.0.0/runtime-1.0.0.jar
Run Code Online (Sandbox Code Playgroud)

这是对的.当我转到此URL时,https://jcenter.bintray.com/android/arch/lifecycle/runtime/1.0.0/runtime-1.0.0.jar我得到404 Not found error一个JSON.

我没有在该URL中看到任何特定于android/cordova的版本,因此我无法从我的cordova安装中说出它.

科尔多瓦版: 7.1.0

离子信息:

cli packages: (C:\Users\%User%\AppData\Roaming\npm\node_modules)

    @ionic/cli-utils  : 1.19.2
    ionic (Ionic CLI) : 3.20.0

global packages:

    cordova (Cordova CLI) : not installed // this is strange. I can run cordova in my terminal tho

local packages:

    @ionic/app-scripts : 3.1.8
    Cordova Platforms  : android 6.4.0
    Ionic Framework    : ionic-angular 3.9.2

System:

    Android SDK Tools : 26.1.1
    Node              : v8.4.0
    npm               : 5.3.0
    OS                : Windows 10

Environment Variables:

    ANDROID_HOME : C:\Users\%User%\AppData\Local\Android\Sdk

Misc:

    backend : pro
Run Code Online (Sandbox Code Playgroud)

另外,我没有任何cordova-android 文件夹C:\Users\%USER%\.cordova\lib\npm_cache(我不知道这是否有帮助.我看到有人在谈论这个文件夹)

这有什么问题?该URL来自哪里?如何更改它以及我可以更改它?

如果我不能轻易解决这个问题,还有最后一步:删除并重新安装所有内容.

谢谢!

Mor*_*itz 20

快速临时修复是在顶级gradle文件中包含google maven repo.

allprojects {
  repositories {
      mavenLocal()
      maven { url 'https://maven.google.com' } // <-- add this!
      jcenter()
Run Code Online (Sandbox Code Playgroud)


oct*_*ron 13

对我来说,AIT MANSOUR莫里茨的答案没有工作,因为我有这样的要求的其他依赖jcenter()jitpack,此外,对于react-native你所需要的node_modules.

所以,我的解决方案react-native

allprojects {
    repositories {
        // this is for native modules I'm developing
        mavenLocal()
        // for modules depending on jitpack.io
        maven { url "https://jitpack.io" }
        // add this one
        maven {
            url "https://maven.google.com"
        }
        maven {
            url "$rootDir/../node_modules/react-native/android"
        }
        // keep this at the end
        jcenter()
    }
}
Run Code Online (Sandbox Code Playgroud)

  • 这是唯一适用于本地反应的解决方案.他们说使用npm包,他们很容易说.浪费了这个小时!谢谢八面体! (2认同)

boy*_*oyd 6

我解决了这个问题(至少对我而言).

似乎jcenter有一些问题为项目提供了库(可能是暂时的).正如人们在这里建议的那样,你可以通过从maven获取这些库来解决这个问题.

转到你的build.gradle文件(对于离子开发者,它位于/ platforms/android中)并在上面的每一行代码中添加jcenter()这行maven { url 'https://maven.google.com' }.

对我来说这是两个地方:buildscriptallprojects.最后,build.gradle文件的顶部应如下所示:

apply plugin: 'com.android.application'

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

    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.0'
    }
}

allprojects {
    repositories {
        mavenLocal()
        maven { url 'https://maven.google.com' }
        jcenter()
    }
}
Run Code Online (Sandbox Code Playgroud)

它能做什么?它只是将库提供程序(在本例中为jcenter)更改为另一个,以便您的应用程序可以成功下载它们.其中的每一行都有一个带有回退的库提供者.

我不知道为什么它首先没有回退到maven因为回退提供程序在我的build.gradle文件中.