将插件添加到本地jar的gradle buildscript中

Ahm*_* na 8 java android gradle

我想使用google-services插件与Firebase配合使用,但是由于其中一台笔记本电脑无法上网,我无法连接到jecenter并添加该插件。

我已经下载了google-services-3.0.0.jar,但不知道在哪里添加它以及如何实现

这个项目build.grdle

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.1.2'
        classpath 'com.google.gms:google-services:3.0.0' <---i have the jar

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
    }
}
Run Code Online (Sandbox Code Playgroud)

Ahm*_* na 9

我可以通过将jar添加到我的lib文件夹中,然后从项目gradle依赖项中调用它来从jar添加插件:

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.1.2'
        classpath fileTree(include: ['*.jar'], dir: 'app/libs')
        classpath files('app/libs/google-services-3.0.0.jar')

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}
Run Code Online (Sandbox Code Playgroud)

  • 我已经添加了相同的行,但我的应用插件仍然没有解决,你能提出一些建议吗 (2认同)

Ali*_*sel 5

您应该创建您的目录*.jar库和添加flatDir {}repositories {}模块初始化,保持JAR-库的储存库的目录:

buildscript {
    repositories {
        jcenter()
        flatDir { dirs 'jarlibs' } // *.jar libs are keep in 'app/jarlibs' dir
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.1.2'
        classpath 'com.google.gms:google-services:3.0.0' // now it works
    }
}
Run Code Online (Sandbox Code Playgroud)