简体   繁体   English

Android Studio的重构软件包名称上的旧软件包名称未更改

[英]Old package name isn't being changed on refactor package name for Android Studio

I made a hundred copies of a project and went through a refactoring of the project name to try and change them to make them unique. 我制作了一个项目的一百个副本,并对项目名称进行了重构,以尝试对其进行更改以使其具有唯一性。 I, however, only managed to change it in the Android Manifest and the rest of the app... but in the emulator and on the google play store, it still has the origial package name. 但是,我只设法在Android Manifest和其他应用程序中对其进行了更改...但是在模拟器和Google Play商店中,它仍然具有原始包名称。 What is going on. 到底是怎么回事。 I followed guidethroughs on how to refactor the package name and that should have fixed it... but it still doesnt go through. 我遵循了有关如何重构程序包名称的指南,并且应该对此进行了修复……但是它仍然没有解决。 What am I missing here? 我在这里想念什么?

manifest: 表现:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.jakegosskuehn.crystalmaiden" >

top of all java files: 所有Java文件的顶部:

 package com.jakegosskuehn.crystalmaiden;

I realized what went wrong when I checked the build.gradle script for the module:app. 当我检查module:app的build.gradle脚本时,我意识到出了什么问题。

defaultConfig {
    applicationId "com.jakegosskuehn.***OLD_PACKAGE_NAME***"
    minSdkVersion 10
    targetSdkVersion 21
    versionCode 1
    versionName "1.0"
}

Just renaming the applicationId to be the same as everything else should fix the problems in the app. 只需将applicationId重命名为与其他所有名称相同,即可解决应用程序中的问题。

If you want change package name,this is a simple way: 如果要更改程序包名称,这是一种简单的方法:

1.Create a flavors.Step: 1.创建口味步骤:
Right click you project->'Open Module Settings'->Choice 'app'->Choce tab 'Flavors'->Then you can see a 'defaultConfig'.Cretae a new ,give a name you like. 右键单击您的项目->“打开模块设置”->选择“应用程序”->“选择”选项卡-“ Flavors”->然后您会看到一个“ defaultConfig”。

2.Then you will see a new flavos in you 'build.gradle',like this: 2.然后,您将在“ build.gradle”中看到一个新的flavor,如下所示:

    productFlavors {
    myflavor {
    }
}

you can add new config lick this: 您可以添加新的配置,点击:

productFlavors {
    myflavor {
        applicationId "cn.imengya.newpackagename"
        minSdkVersion 8
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
    }
}

3.Open the 'Gradle project',then your can find the some new task with you new flavors.Then new task can build .apk with new packagename. 3.打开``Gradle项目'',然后您可以找到具有新口味的新任务。然后新任务可以使用新的程序包名称构建.apk。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM