How to rename my Android app? - android

I wish to rename my android app and package name. I have successfully done the latter via refactoring, but I'm having trouble with the former.
I have renamed the Java project, and I've also edited strings.xml to reflect the new app_name. However, while the new app name is reflected in my main activity as well as in the app drawer/home screen, when I try to view the app on the device in application manager, the old app name is still displayed.
How do I update that?

It should be the temporary issue. If you uninstall and re-install the application I think it will be resolved. And when users update from the Play Store it should be updated as well.
The application name is received from the android:label value in the application tag in AndroidManifest.xml
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name" >

You need to change Application Name into android:label attribute of <application> tag in manifest.xml file
<application
android:icon="#drawable/logo"
android:label="#string/app_name"
>...</application>
And also change the Package into manifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="New Package Name"
android:versionCode="1"
android:versionName="1.0" >....</manifest>
And after this built your project again see here for more info:http://developer.android.com/guide/topics/manifest/application-element.html

Related

androidTest AndroidManifest.xml ignored

I have the same issue mentioned in this post AndroidTest Manifest permission not detected
and this post AndroidManifest in androidTest directory being ignored
--> If I put the test manifest in androidTest, debugAndroidTest, androidTestDebug, it never gets picked up and merged.
the answers about putting the AndroidManifest.xml in the debug folder are correct; that does seem to work. (put the test manifest in src/debug
What I want to know is why can't you put it in the androidTest directory? All the documentation I've read while trying to figure this out makes it sound like you should be able to, and that if you can't then I'm thinking that sounds like some bug in the manifest merger.
For what it's worth, I'm using Android Studio
That is correct and totally agree with you on the confusing documentation. The AndroidManifest.xml under androidTest* source sets would be packaged for the instrumentation APK that does your tests on your actual app APK. If you open the generated APKs for debug and androidTest under build/outputs/apk/ after compiling your app module with the command gradlew assembleDebugAndroidTest (assuming that you haven't changed the testBuildType in you build.gradle, more info here), you'll find that any AndroidManifest.xml configuration added under androidTest will be in the androidTest APK and not in your debug app APK.
And also as you said, in case you need test specific configurations like extra permissions, you'll have to place them in the AndroidManifest.xml under the debug source set instead of main, hence they'll only be available for testing your app but not in your release build. Of course you can always double check by opening the generated APKs after compiling to make sure that the configuration is right for each build variant.
If you need to add extra permissions for tests, you can do it.
You should set the same android:sharedUserId in default AndroidManifest.xml and androidTest/AndroidManifest.xml.
For example:
AndroidManifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:sharedUserId="com.yourpackagename.uid">
<application
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme"
tools:replace="android:allowBackup">
</application>
</manifest>
androidTest/AndroidManifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
android:sharedUserId="com.yourpackagename.uid">
<uses-permission android:name="android.permission.***" />
</manifest>
For details: https://stackoverflow.com/a/14196493/3901000

No resource identifier found for attribute 'fullBackupContent' in package 'android'

part of my AndroidManifest.xml
<application
android:allowBackup="true"
android:fullBackupContent="false"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppThemeCompat"
android:largeHeap="true" >
I'm newbie in android developer, i use eclipse mars with sdk 25.1.3 and i get this error. they are no '/xml' folder under 'res/' in my project.
what should i do to fix this issue?
sorry for my english.
Does your manifest tag look like this?
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.my.appexample">
I never used "fullBackupContent" but every attribute needs to be declared with the xmlns to use it.
Also, if you say you are new to android development. Why do you need "fullBackupContent" and "largeHeap"? Did you copy that from somewhere or is it on purpose?

Update Android app on Google Play

of course there are a lot similar questions and I really read through, but none of them completely answered my question:
I want to update my current app (already prod) on Google Play, but it says I need to change the versionCode -> 1 does already exist.
But I changed or added this in the AndroidManifest.xml, also the versionName.
You must know, I didn't add any versionCode or versionName in my first upload, could this cause the problem?
Do I have to delete the app now and re-upload it?
I surely used the same keystore and credentials
Steps done:
updated the AndroidManifest.xml
android:versionCode="2"
android:versionName="1.0">
created a new signed apk
tried to upload
Another question:
Do I really need to use the same apk-filename?
xml manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.ibma.ibmaapp"
android:versionCode="2"
android:versionName="1.0">
<uses-sdk
android:minSdkVersion="19"
android:targetSdkVersion="19"
android:maxSdkVersion="19" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.ibma.ibmaapp.MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
For the first question - Are you sure you saved the changes to the manifest? Seems silly, but it's a mistake I make all the time.
For the second question - You can change the .apk filename to whatever you'd like; there's no need to keep it the same.
finally it works...
updated Android Studio to 0.8.0
updated my APIs (to API 20: Android L)
changed following project settings: (under "File > Project Structure")
Compile SDK Version: android-L
Build Tools Version: 20.0.0
changed the selected API for the graphical Layout (see link below)
have a look at this blog
(Thank you, Thodoris Bais! ;-) )
Had to change the build.gradle file and add the correct VersionCode
this was the reason why I could not generate apk's with different VersionCodes
it was still set to versionCode=1 though in the manifest it was set to two
I checked the new apk file with the aapt command and the versionCode was set to 2, finally!
Now my last queston would be:
Do I always have to update the AndroidManifest.xml and the build.gradle file on my own - shouldn't they just synchronize?
Best regards,
Christian

How can I add additional Android permissions for my UI test project only?

I try to write files to the external SD card in a from InstrumentationTestCase2 derived test case for pure testing purposes. This works all well when android.permission.WRITE_EXTERNAL_STORAGE is configured in the AndroidManifest.xml file of the application under test, but does not work if this setting is only present in the AndroidManifest.xml file of the test project.
Naturally, I don't want to add this permission to the main manifest, since I only need this capability during my functional tests. How can I achieve that?
In short you should add the same android:sharedUserId for both application's manifest and test project's manifest and declare necessary permission for the test project.
This workaround comes from the fact that Android actually assigns permissions to linux user accounts (uids) but not to application themselves (by default every application gets its own uid so it looks like permissions are set per an application).
Applictions that are signed with the same certificate can however share the same uid. As a consequence they have a common set of permissions. For example, I can have application A that requests WRITE_EXTERNAL_STORAGE permission and application B that requests INTERNET permission. Both A and B are signed by the same certificate (let's say debug one). In AndroidManifest.xml files for A and B android:sharedUserId="test.shared.id" is declared in <manifest> tag. Then both A and B can access network and write to sdcard even though they declare only part of needed permissions because permissions are assigned per uid. Of course, this works only if both A and B are actually installed.
Here is an example of how to set up in case of the test project. The AndroidManifest.xml for application:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.testproject"
android:versionCode="1"
android:versionName="1.0"
android:sharedUserId="com.example.testproject.uid">
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="16" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name">
<activity
android:name="com.example.testproject.MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
And the AndroidManifest.xml for a test project
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.testproject.test"
android:sharedUserId="com.example.testproject.uid"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="8" />
<instrumentation
android:name="android.test.InstrumentationTestRunner"
android:targetPackage="com.example.testproject" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name" >
<uses-library android:name="android.test.runner" />
</application>
</manifest>
The drawback of this solution is that the application is able to write to external storage too when test package is installed. If it accidentally writes something to a storage it may remain unnoticed until release when the package will be signed with a different key.
Some additional information about shared UIDs can be found at http://developer.android.com/guide/topics/security/permissions.html#userid.
There is another easy answer.
Set the permission in src/debug/AndroidManifest.xml. If the file doesn't exist, create it.
By default, AndroidTest uses debug as BuildType, so if you define your testing permissions there, then the manifest merging process will add these permissions to your UI test build.
Here is the Manifest with new permissions. Note that I didn't include the package attribute because it will be inherited from lower priority level manifest.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
</manifest>
Also, if you want to apply these permissions to a buildType other than debug, then just move your new AndroidManifest.xml to the folder you want, and use this:
android {
...
testBuildType 'release' // or other buildType you might have like 'testUI'
}

Change application name and label

I would like to change the application name and label in the installer window (see the attached image). Name and label is, by default, the package name. Even though I added custom name and label in AndroidManifest.xml, it is not reflected in this installer window.
AndroidManifest.xml is given below.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.style"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="10" />
<application android:icon="#drawable/icon"
android:label="#string/app_name">
<activity android:name=".StylePageActivity"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
And the custom name in strings.xml (or /res/values/base-strings.xml) is
<string name="app_name">Demo Application</string>
You can change the name (or package) of your application in AndroidManifest.xml in the <manifest package="..." part and you can change the name of the app by changing the android:label attribute in the <application> tag in the same file.
Please note that changing the package of your application essentially registers as a totally different application from the previous one (as far as Android is concerned).
Can you post your Manifest file here. Below works well for me:
<application android:icon="#drawable/launcher_icon"
android:label="#string/app_name" android:theme="#android:style/ Theme.NoTitleBar">
in your activity
this.setTitle("your text");
this works for me
go to strings.xml in res/values folder and changed the value of "app_name"
<resources>
<string name="app_name">DESIRED_NAME</string>
</resources>
also, rename the name of the .apk file after building the apk.
I think this will solve your problem.
Within a Kotlin based android app you may search for the file: \app\build.gradle.kts and change: app_name string
After changing "app_name" to your needs, you must "Sync" the project (Click in Android Studio on top,right)

Categories

Resources