Changing android package directory structure - android

lets say i have a published app with package name com.test.app. I want to replace it with an updated app with the package name com.test.app.v3. In android studio, how to I change the updated apps package structure so that all the java code currently in the v3 directory will be placed into the app directory. I know I can manually do it but is their a quick way to do it in android studio.

In Android Studio, You can't change package name quickly.
1.You should change the package name in build.gradle(Module:app)
defaultConfig {
applicationId "com.test.app.v3"
minSdkVersion 11 // change the values as you want
targetSdkVersion 23
versionCode 2
versionName "1.1"
}
2.Also change the Package name in AndroidMAnifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.test.app.v3">
3.You must change the package name in all java files.
package com.test.app.v3;
Hope this helps.
Happy Coding :)

Related

Built APK has wrong metadata (packagename is 'android' instead of my real package name)

I think this is the weirdest problem I've come across while developing Android apps.
When I generate a release apk through android studio everything looks ok, but in apk's metadata instead my own package name, versionCode, and VersionName, I get this:
Package name
android
versionCode
14
versionName
4.0.1-eng.releases.20111219.201643
What could be the reason?

How to build 2 apps with the same project in android studio?

I've recently just imported my eclipse project into Android Studio, I haven't convert it into gradle yet. So some forum that offers me solution from gradle is not working. My problem is I have 2 application, where both has some slight difference. I want to use the same project when I deploy the application. I've tried to change the project name but that doesn't help. The moment the new application is installed, the previous version is overwritten. I thought of making some changes to the Manifest file(not sure if this is the right thing to do) but in android studio, I can't seem to locate where the file is. Please help.
Regards,
Dexter
Your application needs to have a different package name for it to be treated as a different app.
So instead of
com.yourcompany.apps.yourapp
You write
com.yourcompany.apps.yourapp1 and
com.yourcompany.apps.yourapp2
You can do that in your AndroidManifest.XML in the manifest tag
package="com.yourcompany.apps.yourapp1"
Also, instead of 2 separate apps, try seeing if you can solve this using Build variants and product flavors.
Use flavors on your build.gradle
productFlavors {
flavorName {
minSdkVersion 19
applicationId 'you.package.name'
targetSdkVersion 23
versionCode 1
versionName 'version_name'
}
}
Also you can modify a file with different changes by just adding a source folder for the flavor.
app
|--src
|--main
|--flavorName

Install duplicated Android app on your device

I want to install on my phone the production and development apks of my Android app, which initially are going to be exactly the same.
The only thing that I have changed so far is <application android:label="#string/app_name"> in the AndroidManifest.xml to a different string.
However, when I try to install the new APK on my device, it detects the app as an update of the production one.
What can I do to make my phone understand that these are two different apps?
You have to change the applicationId of the app.
That is used as a unique identifier in the play store and on your phone.
The applicationId is in your build.gradle in the main app folder:
defaultConfig {
applicationId "com.example.myapp"
During the build gradle will generate the package name in your manifest from the applicationId.
You have to change to package name of application. Then you can easy to install application different one.
com.something.somthing set on you application package.
Change at project/src/com.package.package
And chnage at manifest

How to change package name in android studio? [duplicate]

This question already has answers here:
Rename package in Android Studio
(55 answers)
Closed 7 years ago.
I have made an app and it is my very first app so when I started coding, I left the package name as com.example.stuff and now when I try to upload to the play store it wont let me due to the package name. I have tried refactor-> rename the package name and changed it in the AndroidManifst.xml then I tried to upload again. I am once again left with the same message time after time.
I appreciate any help and thanks in advance. :)
First click once on your package and then click setting icon on Android Studio.
Close/Unselect Compact Empty Middle Packages
Then, right click your package and rename it.
Thats all.
In projects that use the Gradle build system, what you want to change is the applicationId in the build.gradle file. The build system uses this value to override anything specified by hand in the manifest file when it does the manifest merge and build.
For example, your module's build.gradle file looks something like this:
apply plugin: 'com.android.application'
android {
compileSdkVersion 20
buildToolsVersion "20.0.0"
defaultConfig {
// CHANGE THE APPLICATION ID BELOW
applicationId "com.example.fred.myapplication"
minSdkVersion 10
targetSdkVersion 20
versionCode 1
versionName "1.0"
}
}
applicationId is the name the build system uses for the property that eventually gets written to the package attribute of the manifest tag in the manifest file. It was renamed to prevent confusion with the Java package name (which you have also tried to modify), which has nothing to do with it.
It can be done very easily in one step.
You don't have to touch AndroidManifest.
Instead do the following:
right click on the root folder of your project.
Click "Open Module Setting".
Go to the Flavours tab.
Change the applicationID to whatever package name you want. Press OK.

"com.example is restricted" when uploading APK to Play Store

I am trying to upload my finished android app to the android market and I am getting this error:
You need to use a different package name because "com.example" is restricted.
In Android Studio after renaming Package then go "build.gradle (Module:App)
defaultConfig {
applicationId "com.example.android.abc"
minSdkVersion 9
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
change the line
applicationId "com.example.android.abc"
to
applicationId "com.tanxe.android.abc"
relpace "tanxe" with the word you want or your Organization name i.e.
your new package name
and rebuild the project
The best way to solve this is by going to the AndroidManifest.xml: package="com.example.android.yts"
Cursor on example
press
Shift+f6
change Package name eg. example to boss
Click on refactor now `"com.boss.android.yts"``
2nd thing
open build.gradle (module:app) change applicationId "com.example.android.yts"
to "com.boss.android.yts"
The error message is telling it all. You need to use a package name of your own. The package name is the identitiy of the application.
To rename the package name, In eclipse right click on the project in project explorer. Then Android Tools > rename Aplication Package name. Then enter the new package name.
Also make sure that you are trying to upload a release build
Yes, com.example is the default package name for Android applications and is, as such, just a placeholder. You should replace it by a unique package name before uploading it to the Google Play Store. It doesn't particularly matter what it is, but it should relate to your application, cannot match any existing package name (so picking someone else's package name like com.android is not a good idea), and cannot be changed after publishing.
Double-tap **package** from AndroidManifest.xml, refactor-> rename.
Go to build.gradle and change applicationId under defaultConfig.
If you have google-services.json, go to google-services.json and rename package_name in two places.
That should work.
Write something else than the com.example
for ex:
com.gg.s etc will do(make that onj your name/firm name)

Categories

Resources