【问题标题】:tns run android with a specific sdktns 使用特定的 sdk 运行 android
【发布时间】:2019-01-03 14:24:22
【问题描述】:

我刚刚创建了一个新应用程序并添加了 android 平台。由于我几天未能安装 API 28,我想针对工作的 SDK 21 运行项目。如何配置应用程序以使用 sdk 21 运行?

我的 app/App_resources/android/app.gradle 是默认的:

 android {  
  defaultConfig {  
    generatedDensities = []
  }  
  aaptOptions {  
    additionalParameters "--no-version-vectors"  
  }  
} 

在platforms/android/.gradle/我看到4.10.2

而我的 build.gradle 是:

buildscript {

    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.1'
    }
}

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

task clean(type: Delete) {
    delete rootProject.buildDir
}

当我运行 tns 时运行 android --emulator

消息是:

Gradle build...
         + setting applicationId
         + applying user-defined configuration from D:\pyworks\agrigo7\mobileapp\agrigo\app\App_Resources\Android\app.gradle
Using support library version 28.0.0
         + adding nativescript runtime package dependency: nativescript-optimized-with-inspector
         + adding aar plugin dependency: D:\pyworks\agrigo7\mobileapp\agrigo\node_modules\tns-core-modules-widgets\platforms\android\widgets-release.aar

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':app'.
> Failed to find Platform SDK with path: platforms;android-28

在我的 Android SDK 中,我尝试安装 API 28,但它不断失败。我当前的 SDK 如下所示:

鉴于已安装 API 21,我尝试了:

  tns run android --compileSdk 21 --emulator

它首先显示 28.0.0。然后给出了很多错误:

       + setting applicationId
         + applying user-defined configuration from D:\pyworks\agrigo7\mobileapp\agrigo\app\App_Resources\Android\app.gradle
**Using support library version 28.0.0**
         + adding nativescript runtime package dependency: nativescript-optimized-with-inspector
         + adding aar plugin dependency: D:\pyworks\agrigo7\mobileapp\agrigo\node_modules\tns-core-modules-widgets\platforms\android\widgets-release.aar

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:processDebugResources'.
> Android resource linking failed
  Output:  error: resource android:style/TextAppearance.Material.Widget.Button.Borderless.Colored not found.
  error: resource android:style/TextAppearance.Material.Widget.Button.Colored not found.

【问题讨论】:

    标签: nativescript


    【解决方案1】:

    我认为您对支持库和 SDK 版本感到困惑。它们是不同的,您的支持库的主要版本应始终与您的 SDK 的主要版本匹配,这意味着您不能将支持库 28.x 与 SDK 21.x 一起使用。

    @Jenlooper 已经简要介绍了这个breaking change at the 5.0 launch,您必须在 gradle 文件 (project.ext.supportVersion) 中指定正确的支持库版本。

    此外,Google Play 将所有新应用提交限制为目标 SDK 26 (Android 8.0),因此我建议您尝试使用 SDK 26 而不是无法用于发布的 21。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-12-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-12-25
      • 2020-11-27
      相关资源
      最近更新 更多