Android Studio项目重命名

5

我已经根据自己的发现和这里找到的所有内容对项目进行了重命名,它起作用了,但只是有点效果。

看起来已经重命名了,但当你在设备上检查应用程序信息或卸载它时,旧名称仍然存在。

我该如何进行完整的重命名?

旧名称是WifiHome,我想将其改为Wifi Sentinel。

build.gradle:

    apply plugin: 'com.android.application'

android {
    compileSdkVersion 22
    buildToolsVersion "21.1.2"

    defaultConfig {
        applicationId "org.grenderg.wifisentinel"
        minSdkVersion 14
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:22.0.+'
    compile 'com.android.support:gridlayout-v7:22.0.0'
    compile 'com.android.support:palette-v7:22.0.0'
    compile 'com.android.support:recyclerview-v7:22.0.0'
    compile 'com.android.support:cardview-v7:22.0.0'
    compile 'com.android.support:support-v4:22.0.0'
}

AndroidManifest.xml:

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

    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
    <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
    <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

    <application
        android:allowBackup="true"
        android:icon="@mipmap/icon"
        android:label="@string/appName"
        android:theme="@style/WifiSentinel">
        <activity
            android:name="org.grenderg.wifisentinel.activities.BaseActivity"
            android:label="@string/appName"
            android:screenOrientation="portrait">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <service
            android:name="org.grenderg.wifisentinel.services.WifiScanService"
            android:enabled="true"
            android:exported="false" >
        </service>
    </application>

</manifest>

应用名称 = Wifi Sentinel

已在其他地方更改名称,但信息中未更改:

enter image description here


项目名称没有显示在设备中,您是指应用程序名称还是应用程序包名称? - m0skit0
抱歉,我的意思是当您查看应用程序信息或卸载应用程序时的应用程序名称。(不仅仅是在清单上替换它那么简单) - Grender
检查清单中的 android:label,并根据您的需求进行更改。 - Subhalaxmi
完成了,但是它不起作用。 - Grender
6个回答

1
  1. 右键单击您的根项目目录
  2. 选择重构 -> 重命名
  3. 选择重命名项目并在那里更改名称。
  4. 还要选择重命名模块并在那里更改它。如果您收到消息说模块名称已更改,那没问题。
  5. 现在再次右键单击项目根文件夹,然后选择打开模块设置。
  6. 在模块部分下删除与旧项目名称相关联的任何文件夹。
  7. 应用设置,点击确定。并重新启动Android Studio。

Donde和not无法正常工作。 - Grender

0

我也遇到了这个问题,没有错误提示,但安装的apk文件名仍然是旧的。但是在测试游戏时,我注意到操作栏上显示的是旧名称,这给了我答案的线索。

进入你的资源文件夹,然后进入values文件夹,打开strings.xml文件。在这里,你应该看到类似于以下内容:

<resources>
    <string name="app_name">Rhg Timecard</string>

将此处(在我的情况下是 Rhg Timecard)更改为您的新名称。 现在应该一切就绪了。


0

在其他人的建议下,重构重命名和gradle文件编辑:

  1. 在Android Studio中前往顶部菜单栏: 文件 => 设置 => 构建、执行、部署 => 构建工具 => Gradle
  2. 现在您必须取消“离线工作”。

  3. 启用计算机上的网络。

  4. 清除项目(构建 => 清除项目)+运行它。 在确认 app_name/label 重命名无误之后再次勾选“离线工作” (我是在 android studio 1.2.2 上进行的这些操作)


0
在Android Studio中前往res>values>string.xml,然后更改应用程序。

enter image description here


2
两者在这里的作用相同,所以我选择了图像而不是代码。 - Irfan Ul Haq
4
不,实际上公司经常会屏蔽图片。另外,你也无法从图片中复制代码。你应该尽量发布文本内容。 - Tunaki

0
你的应用文件夹里有一个 build.gradle 文件。你需要在其中修改 applicationId,并且也要从 AndroidManifest 文件中进行修改。然后使用 gradle 同步你的项目,清理并重新构建它。

我已经尝试过了,但它没有起作用,请检查问题,我已经添加了一些信息。 - Grender

0

在之前安装了旧名称的设备上似乎存在一个错误,我已经尝试在从未安装过该应用程序的设备上安装,名称显示正确。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接