android - Android Studio中带有Gradle的参数的方法

标签 android android-studio gradle android-gradle-plugin

在android studio中将项目文件与gradle文件同步会导致以下错误

Error:(14, 0) Could not find method applicationId() for arguments [com.amazon.mysampleapp] on project ':app' of type org.gradle.api.Project.

gradle文件读取的位置
android {
    compileSdkVersion 23
    buildToolsVersion "23.0.1"
    applicationId "com.amazon.mysampleapp"
    minSdkVersion 15
    targetSdkVersion 23
    versionCode 1
    versionName "1.0"
    multiDexEnabled = true
}

这是怎么回事删除applicationID会将错误移至minSdkVersion

最佳答案

applicationId不在android块中,而是在buildConfig块中:

apply plugin: 'com.android.application'
android {
    compileSdkVersion 19
    buildToolsVersion "19.1"

    defaultConfig {
        applicationId "com.example.my.app"
        minSdkVersion 15
        targetSdkVersion 19
        versionCode 1
        versionName "1.0"
    }
}

从此页面获取有关applicationId的信息:http://tools.android.com/tech-docs/new-build-system/applicationid-vs-packagename

关于android - Android Studio中带有Gradle的参数的方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39965356/

相关文章:

android - 新建Android项目的大小

java - Libgdx - 使用TexturePacker时出现错误

android - 从不同线程 Android 更新 View

android - 在自己创建的应用程序而不是浏览器中启动链接

android - 如何将 utf-16 字符放入 Android 字符串资源中?

Gradle 多个 Maven 存储库

android - gradle如何获取库

Android: "Failed to execute ' 上的 'HTMLMediaElement' play':API 只能由用户手势启动

android - 在 Android 应用程序中嵌入 YouTube 直播

java - 从 5.4 升级到 6.8.3 后如何解决 gradle tls 连接?