Android Runtime doesn't play nice with productFlavors

Đang mở
#1,597 0 bình luận 1 reaction 1 người được giao Xem trên GitHub

@vmutafov đang làm issue này rồi.

Từ ngày 19/5/2020.

Đánh giá

Issue này chưa được đánh giá.

Mô tả

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

Ngôn ngữ chính
C++
Star
563
Fork
144
Merge trung bình
10 giờ 46 phút
Pull request đã merge (30 ngày)
14

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của NativeScript/android

Tất cả issue của NativeScript/android

Issue tương tự

Thêm issue về C++

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.