NativeScript / NativeScript/android

Android Runtime doesn't play nice with productFlavors

オープン
#1,597 コメント 0 件 リアクション 1 件 担当者 1 名 GitHub で見る

@vmutafov がすでに取り組んでいます。

2020年5月19日 から。

主要言語
C++
スター
563
フォーク
144
平均マージ
10時間 46分
マージ済み PR(30日)
14

説明

Environment

  • CLI: 6.5.0
  • Cross-platform modules: 6.5.1
  • Android Runtime: 6.5.0

Describe the bug
When adding productFlavors to your build.gradle, something odd seems to happen in the metadata generation and some classes aren't available to NativeScript anymore.

To Reproduce

  • Create a sample project where you call console.log(com.tns.NativeScriptApplication.getInstance()); from Typescript
  • Test the app, it should work and return the application instance
  • Now add productFlavors (they don't even have to include any specific settings) to your project, like this:
android {
  defaultConfig {
    minSdkVersion 17
    generatedDensities = []
  }

  flavorDimensions "api"

  productFlavors {
    minApi21 {
      dimension "api"
      versionNameSuffix "-minApi21"
    }

    minApi17 {
      dimension "api"
      versionNameSuffix "-minApi17"
    }
  }

  aaptOptions {
    additionalParameters "--no-version-vectors"
  }
}

android.variantFilter { variant ->
    // Don't build minApi21 apk for debug.
    if(variant.buildType.name.endsWith('debug') && variant.name.contains("minApi21")) {
        variant.setIgnore(true);
    }
}
  • Remove your platforms folder
  • Run the app again, now the com.tns.NativeScriptApplication.getInstance() will result in a Cannot read property 'getInstance' of undefined error.

Expected behavior
Behavior should be the same as without productFlavors.

Sample project
https://github.com/jerbob92/nativescript-productflavor-bug

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。