android eclipse custom version of same project - android

I want to try 2 difference version of the same app on my tablet.
So imported both project in eclipse with different project name.
I changed the name of the app in the manifest, I changed the icon to be able to recognize them on my desktop ...
I just can't get both on the phone at the same time. I can execute them both, but installing one is gonna erase the other.
I guess its the change I'm looking for is in the manifest.xml, still I can't find it.

You have to change your package name. A Package name must be unique for every app.
From the official doc
Package Name is the package namespace for your app (following the same
rules as packages in the Java programming language). Your package name
must be unique across all packages installed on the Android system.
For this reason, it's generally best if you use a name that begins
with the reverse domain name of your organization or publisher entity.

In Eclipse, in the Package Explorer select the com.xxxx.yyyy in the src/ directory of the project whose manifest you changed. Right click -> Refactor -> Rename. Enter a new package name, e.g. com.abc.test
Then, in the manifest XML, also replace all instances of "com.xxxx.yyyy" with the new "com.abc.test" package name.

Related

Android Studio - APK with capitalized package name - INSTALL_PARSE_FAILED_MANIFEST_MALFORMED

I know that almost identical question was asked here, but accepted answer doesn't work for me.
Make apk with Capitalized package name in android studio
Let me explain.
Our Android app was developed in Xamarin.Android, we did a mistake with package naming - Visual Studio and Xamarin configured our's app manifest with uppercased package name (this was a mistake which now I pay with my sanity). It worked for Xamarin version, but we decided to rewrite that app in Android Studio after some releases. Now the problem begins...
We are not able to directly deploy/install apk on devices older than Android 8.0, we get following error: INSTALL_PARSE_FAILED_MANIFEST_MALFORMED
It's funny that issue does not exists on devices with newest API.
It's clearly issue with our package name which is something like:
YES_We_Failed_On_It.We_Failed_Very_Badly
If I change it to lowercased everything works, but the case is we can't release another application with different package name.
Is there any possibility to fix this?
It will be self answer question.
If anyone else will be at my position, fix is quite simple.
As mentioned in docs: https://developer.android.com/studio/build/application-id.html
When you create a new project in Android Studio, the applicationId exactly matches the Java-style package name you chose during setup. However, the application ID and package name are independent of each other beyond this point. You can change your code's package name (your code namespace) and it will not affect the application ID, and vice versa (though, again, you should not change your application ID once you publish your app).
Application ID and Java package name are not the same.
So to fix this I renamed my package to be lowercased and stayed with uppercased Application ID. Problem disappeared.
At the end of build, build tools copy our Application ID into final APK's manifest, that's why it's still the same package I think.
Also from docs:
One more thing to know: Although you may have a different name for the manifest package and the Gradle applicationId, the build tools copy the application ID into your APK's final manifest file at the end of the build.

Rename Android Studio package error: Not a valid identifier name

Renaming from com.example.test to org.example.test: I have only found examples of changing the example part of this, but I need to change the com one.
I have tried Refactor then select Rename package, but I get the message Not a valid identifier name when I enter org.example.test.
Does anyone know the correct way?
The accepted solution did not work for me. I had to do the following:
Create a new package with the desired name (eg. org.example.test)
Move the files from the old package to the new one [android studio correct the package name automatically]
In AndroidManifest.xml, change package="..." to the new one (eg. org.example.test) [maybe this step is not obligatory]
Compile. You will see errors like imports to the old package. Simply correct them one by one [I just found one error]
That's all. It run perfectly after that!
I've had to do the same a few months ago. As far as I know, Android Studio does not bound java packages with the app package. That said, you may have to change your app package (if that's what you want) and your java package.
First, your Java package
Select the 1. Project tab in Android Studio. There's a Settings button. Click on it and check Flatten Packages.
Then, select the package you want to rename. Press Shift + F6 to rename the whole package. If you have more than one package inside com.example.test, Android Studio will warn you "Multiple directories correspond to package..." and ask if you want to rename package or directory. Choose package and it will do its magic.
Unless you have something else other than test under com.example, you're good to go.
Then, your Android app
For this one, I don't know any shortcuts. But if it helps, the app package is mentioned in AndroidManifest.xml and build.gradle for your module.

Install few APK files on phone - different versions of the same app.

I decided to have few versions of the same app on the phone.
I clicked 'run' on first version of app in eclipse and apk was installed with the name: 'p2'. Then I changed package statement in Manifest to 'p5' , and changed all links in application classes and xmls, rebuilded app and clicked 'run' again to install next apk on the same phone.
To my astonishment I have two applications with name 'p2'.
I expected to see 'p2' and 'p5'.
I was looking for an occurence of 'p2' in my code but there was no such place.
Can you guide me to solve this?
To install the same application on the same device do followed steps:
change Application package (where your main Activity is located)
change Application Name (optional, doesn't seem good two equal names on the same device)
If you compile applications from Eclipse, you must change also .project file:
<projectDescription>
<name>Appl</name>
otherwise you can't import second application with the same name

Google play says: "You need to use a different package name" - why?

I have already published an app called com.mycompany.mygame on google play.
I then decided to publish an ad free version of it. I did not change the package name in eclipse because I noticed that in the "export" process you have the opportunity to have the final apk set as anything you like. So I set it there as com.mycompany.mygameaf - note the additional "af" on the end. But then when tried to upload it to the market, google said:
You need to use a different package name because "com.mycompany.mygame" is already used by one of your other applications
So now I'm confused. Is the complaint because I'm not allowed to have an apk that is a name which is and extension of a previous app? Or does the final apk somehow have knowledge of what the original name was?
What is the easiest way to resolve this?
Apart from correcting app name in the Manifest I also had to change applicationId in the app's gradle.build file.
defaultConfig {
applicationId "com.example.changednameofmyapp"
...
}
Also, if you're using ProGuard, do not forget to change appropriate rules in your proguard-rules.pro
Just search the old package name in the whole project and change it.
Regardless of the name of the .apk file, the package name of the Application contents inside it must be unique.
You can use refactor-rename to change this, though make sure that the change penetrates to the manifest file, proguard configuration, etc.
The name of the APK doesn't matter, its the package name within the AndroidManifest file that counts.
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.yourcompany.yourapp"
There can only be one app on the market with that package name so in order to publish your ad free version you would have to change the package name in the manifest file, e.g. add the af onto the end of the package name within your manifest.
As mentioned in other answers, you're development would be simpler if you put all the shared code and assets a common library project that is a dependency of your paid and free versions.
You may also wish to play with the new Gradle build system (in Android Studio) which allows you to dynamically set things like the package name at runtime. It also allows you to switch resources during build time, which is extremely convenient; You could have a boolean resource that represents whether the current app is the paid version. This allows you to enable/disable app features based on a check to that value.
The filename of the APK is irrelevant, the package name of your app is used as a unique identifier - it is in the root element in the AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.packagename"
android:versionCode="1"
android:versionName="1.0" >
When you initially create your project in Eclipse it creates an actual package structure which matches this package name for you to put your source files in.
You can actually chnage your package name by modifiying this manifest value and you can just keep the folder/package structure as is - it does not need to match your actual application package name.
Alternatively, right click your project in Eclipse, go to "Android Tools" and then select "Rename Application Package"
After you do this you should be able to submit your binary
The package name in the manifest is used to identify the application within Android and within Google Play. So different apps need different names.
The easiest workaround might be to just create a new package, with no code in it, and use that as the app's package name in the manifest.
What I've done to solve my many-apps-from-one-codebase problem is put all the apps' code in a library project, and then I have several app projects that use that library. The app projects contain no code, just a manifest and custom resources.

building android lite version - full and lite versions get mixed on emulator

I'm trying to build lite version of an android project..so far, I've read that renaming application package (I've used eclipse option for renaming app package) should be enough. I've checked in manifest.xml, package is renamed, but when I install my app on phone (or on a emulator) it seams to mix somehow versions, specially after pressing home button and then re-entering the application (it switches to previously installed full version).
what am I missing? Is there something else to change in order to get different version of application? Should I change application name or maybe source packages?
When changing a package name you also need to change the name of your files. So if your app was originally my.app.full then the files under src will be my/app/full. If you change your package name to my.app.lite then you need to change the film names under src to my/app/lite.
Also at the top of all your classes you should have a package declaration ie. package my.app.full, which also needs to be changed to your new package name - package my.app.lite
If you are still having problems, try refreshing the build, and then if that doesn't work delete the gen file (don't worry it will reappear when you build your project)

Categories

Resources