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.
Related
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.
I have an app that started in eclipse. The package name starts with a capital, and it always compiled and installed correctly. Now that I have moved the project into android studio, while the app will compile, it won't install due to a malformed manifest. I looked up this problem, and the suggestion was to lowercase the package name. This dose solve the problem, and the app installs, but this makes no sense. Why would apps compiled in eclipse be fine with it, but the same code in Android Studio not work? This is a large problem, as the app is already in the play store, and I can't lowercase the package name, so I'm stuck in eclipse. Dose anyone know a work around?
Maybe google play is not case sensitive and thats why it doesn't recognize the upercase package name, you might be able to post an update with the same package name but lowercase. Have you tried it?
Had the same problem with capitals in old package name. In studio simply rename the package in build.gradle (Module:app) from com.abc.example to com.ABC.example sync the project and all should be well.
In Android Studio rename the package name and in build.gradle leave old applicationId.
Although your project's package name matches the application ID by default, you can change it. You should never change the application ID.
More: https://developer.android.com/studio/build/application-id.html#change_the.package_name
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
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.
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)