找不到参数[android.arch.lifecycle:extensions:1.1.1]的方法Implementation()

时间:2018-07-20 11:37:52

标签: android reactjs react-native

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="com.uiyoutube">
    <uses-sdk
        tools:overrideLibrary="com.uiyoutube, com.pierfrancescosoffritti.androidyoutubeplayer" />
    <application android:allowBackup="false" tools:replace="android:allowBackup"/>
</manifest>

我尝试过工具LifecycleOwner

所以我导入了:

import android.arch.lifecycle.Lifecycle;
import android.arch.lifecycle.LifecycleOwner;

我必须:

@Override
 public Lifecycle getLifecycle () {
     return null;
 }
  

无法解析配置':app:_debugApkCopy'的所有依赖项。

     

找不到android.arch.lifecycle:extensions:1.1.1。

     

要求者:

     

ProvaMaterialModule:app:unspecified> ProvaMaterialModule:react-native-material-letter-icon:unspecified

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

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

apply plugin: 'com.android.library'

android {
    compileSdkVersion 27
    buildToolsVersion "27.0.3"

    defaultConfig {
        minSdkVersion 16
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
    }
    lintOptions {
        abortOnError false
    }
}

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

allprojects {
    repositories {
        jcenter()
        maven { url 'https://maven.google.com' }
    }
}

dependencies {
    def lifecycle_version = "1.1.1"

    // ViewModel and LiveData
    compile "android.arch.lifecycle:extensions:$lifecycle_version"

    compile  'com.pierfrancescosoffritti.androidyoutubeplayer:core:8.0.1'
    compile  'com.facebook.react:react-native:+'
}

我尝试将compile替换为 implementation "android.arch.lifecycle:extensions:$lifecycle_version"

但出现以下错误:

Could not find method implementation() for arguments [android.arch.lifecycle:extensions:1.1.1] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependenc
yHandler.

一些建议?

1 个答案:

答案 0 :(得分:0)

来自https://developer.android.com/topic/libraries/architecture/adding-components

要将其添加到项目中,请打开项目的build.gradle文件(而不是应用程序或模块的文件),然后添加google()存储库,如下所示:

allprojects {
    repositories {
        jcenter()
        google()
    }
}