有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java“com.example restricted”谷歌播放错误;即使在更改包名时也是如此

我从安卓 Studio发布了我的第一个安卓应用程序。当我上传到Google Play时,我遇到了以下错误:

Upload failed: You need to use a different package name because "com.example" is restricted.

当我重命名包名时,它仍然给我错误消息。我试着制作一个新的包,并将所有的东西都移动到那个包,但错误仍然存在。我已经删除了com的任何痕迹。示例包。我还确保更改Android清单。将xml添加到新包中

唯一仍然显示旧包名称的是BuildConfig。java,其中包含此行,后跟我的旧包名称的其余部分:

public static final String PACKAGE_NAME = "com.example"

如果有人能帮我回答这篇文章,我将不胜感激。我使用的是Ubuntu Linux 14.04.1


共 (1) 个答案

  1. # 1 楼答案

    这与Android Gradle插件最近的一项更改有关,该插件将应用程序的标识符从Java包名称中分离出来

    Android使用应用程序的标识符来标识您的应用程序。它还用作Play Store URL中的标识符。这通常是,但并不总是与Java包名称相同

    从Gradle插件的版本0.11开始,应用程序ID在您的构建中设置。gradle使用applicationId设置,如下所示:

    android {
        defaultConfig {
            applicationId "com.yourdomain.yourapp"
        }
    }
    

    设置此选项可以解决您的问题

    开发人员控制台中的错误消息可能只是没有改变以反映新的术语

    从Gradle插件版本0.11release notes

    One of the user visible changes in 0.11 is that we've deprecated the packageName and packageNameSuffix settings, and have renamed them to applicationId and applicationIdSuffix. The purpose of this is to make it clear that this application id is decoupled from package declarations in your manifest, and in particular, the R class and the BuildConfig class, and all the implementation classes inside your app, can be renamed and refactored freely; you just need to keep applicationId the same. If you open your build.gradle file, lint is highlighting these deprecated calls and offering quickfixes to update them.