android - Nativescript gradle 项目级

标签 android gradle nativescript

我想在我的 NativeScript 应用程序中使用 Segment(与 Firebase)。所以我必须遵循这个指示:https://segment.com/docs/destinations/firebase但我必须修改两个文件:模块级 build.gradle:

buildscript {
    dependencies {
        // Add these lines
        compile 'com.segment.analytics.android:analytics:4.+'
        compile 'com.segment.analytics.android.integrations:firebase:+'
    }
}

// Add to the bottom of the file
apply plugin: 'com.google.gms.google-services'

和项目级 build.gradle :
buildscript {
    dependencies {
        // Add this line
        classpath 'com.google.gms:google-services:3.1.0'
    }
}

allprojects {
    repositories {
        // Add this line
        maven { url 'https://maven.google.com' }
    }
}

但是对于 NativeScript,我只有一个 build.gradle。那么,如何在 gradle 中实现这些行?

谢谢 !

最佳答案

我知道这个问题很老,但他们将来可能会帮助某人。 Nativescript Docs 不是最好的,这对我有用,所以它可能不适合你。
这适用于插件和常规应用程序。

构建脚本 Gradle .

  • App_Resources/Android/buildscript.gradle
  • 插件 buildscript.gradle
  • repositories {
        // Add this line
        maven { url 'https://maven.google.com' }
    }
    dependencies {
        classpath 'com.google.gms:google-services:3.1.0'
    }
    

    应用等级
  • 插件 include.gradle
  • App_Resources/Android/app.gradle
  • dependencies {
        compile 'com.segment.analytics.android:analytics:4.+'
        compile 'com.segment.analytics.android.integrations:firebase:+'
    }
    apply plugin: 'com.google.gms.google-services'
    

    然而

    The compile configuration still exists but should not be used as it will not offer the guarantees that the api and implementation configurations provide.https://docs.gradle.org/current/userguide/java_library_plugin.html



    你也可以这样写
    应用等级
  • 插件 include.gradle
  • App_Resources/Android/app.gradle
  • dependencies {
        implementation 'com.segment.analytics.android:analytics:4.+'
        implementation 'com.segment.analytics.android.integrations:firebase:+'
    }
    
    

    关于android - Nativescript gradle 项目级,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54791649/

    相关文章:

    android - 如何在我的 Maven 本地存储库中使用 gradle 发布现有的 aar?

    Nativescript ios 构建失败并出现错误 65

    android - 从 Delphi 调用 JNI_OnLoad

    android - 如何使用 ADB 终止所有 Activity 任务/应用程序?

    android - 为什么添加导航组件会导致Gradle错误 “error: resource android:attr/dialogCornerRadius not found.”

    gradle - 无法实例化 'InvalidJavadocPosition'类

    android - Spannable 与字体与 Html

    java - 如何在android中的textview顶部使用红色*符号

    javascript - 如何使用 Nativescript 从链接获取 ID

    css - NativeScript/NativeScript Angular - 如何为页面设置背景图片?