2

Before we start let me explain the assumptions:

  1. I realize it is bad convention to have capitalized package names. In my situation, we are dealing with an 3rd party published android app with capitalized package name, unfortunately app has millions download so republishing is not an option.

  2. I have done extensive research and cannot find solution, the closest SO questions are this and this and this.

The problem :

App was originally developed with eclipse, which can create signed app that has capitalized package name. App must be moved to AS now, which refuses to generate signed apk with capitalized package name. See error below:

enter image description here

Here are relevant parts of my manifest file:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="TESTING.CAPITALIZED"

...

<meta-data
        android:name="com.google.android.gms.version"
        android:value="@integer/google_play_services_version" />

<activity
        android:name="TESTING.CAPITALIZED.Activity_xxx"
...

Please note I have tried changing manifest activity tagged naming convention to: (but same error)

<activity
        android:name=".Activity_xxx"
...

The question:

We need a method/hack in Android Studio to get past this. I don't care how or if it involves magic such as editing dlls, need generate signed apk in AS.

Additional Findings: It appears that in Android Studio, as long as the 1st letter in the package is lower case, we can compile and generate apk. For example, in my example if I refactor my project to zTESTING.CAPITALIZED, I can successfully generate apk. However this doesn't fix my problem because my client's package name is all caps.

Bqin1
  • 467
  • 1
  • 9
  • 19
  • You shouldn't have any issue compiling it in Android Studio. Official document https://developer.android.com/guide/topics/manifest/manifest-element.html says package name can be "A full Java-language-style package name for the Android application. The name should be unique. The name may contain uppercase or lowercase letters ('A' through 'Z'), numbers, and underscores ('_'). However, individual package name parts may only start with letters. " – Amod Gokhale Aug 10 '17 at 05:25
  • @amod, yes I know I can compile, but my question asks for generating signed apk. We need to update this app, compiling on one machine is not helpful. Generate apk then upload to play store is our goal. – Bqin1 Aug 10 '17 at 05:28
  • as per official document it shouldn't be any issue whether we use Android Studio or Eclilpse. It allows combination of lowercase or uppercase. Can you post what exact error you are receiving? – Amod Gokhale Aug 10 '17 at 05:36
  • Documentation doesn't always reflect reality though, you can see what I mean if you try a quick example. Try creating an hello world android project with capitalized package name, then generate a signed apk. AS won't allow you... I am not near a computer, will provide you a screenshot of exact error code tomorrow – Bqin1 Aug 10 '17 at 05:40
  • I just tried package COM.RACHITTECHNOLOGY.MYDEMOAPP; with Android 2.3.3 and signed release apk was created without any issue. – Amod Gokhale Aug 10 '17 at 05:55
  • Very interesting, you sure you generated a signed apk? Using a keystore? So you got no errors and received the apk file in the folder? I will go to lab tomorrow and screenshot the error for you. I am pretty sure I have tried AS 2.3.3 because I even tried up to AS 3.0 canary preview. But I will double check tomorrow my version as well. – Bqin1 Aug 10 '17 at 06:03
  • Per SO recommendation, Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/151565/discussion-between-moonpire00-and-amod-gokhale). – Bqin1 Aug 10 '17 at 06:08
  • @Amod I have updated my question screenshots, manifest, and more details – Bqin1 Aug 11 '17 at 04:30
  • 1
    @Bquin1 - refer to this link for reply from google - https://issuetracker.google.com/issues/64595077 – Amod Gokhale Oct 10 '17 at 16:44

2 Answers2

2

If anyone is looking for an answer, this issue has been resolved in Android Studio 3.0 RC1. Refer to google issue tracker and update if you face any issues https://issuetracker.google.com/issues/64595077

Amod Gokhale
  • 2,346
  • 4
  • 17
  • 32
  • I shall try this ASAP when I get home, if it works, you will definitely be accepted answer. My fingers are crossed! – Bqin1 Oct 10 '17 at 19:52
  • make sure you have correct version of Android Studio installed as mention by google in Google Issue tracker – Amod Gokhale Oct 11 '17 at 09:51
  • Hey Amod, actually it did not work :( This new version fixed building an application with capital letters, but when I try to apk install it, it failed with Failure [INSTALL_PARSE_FAILED_MANIFEST_MALFORMED] – Bqin1 Nov 07 '17 at 05:37
  • can you please update issuetracker https://issuetracker.google.com/issues/64595077 with complete stacktrack and package name so that they can take a look? – Amod Gokhale Nov 07 '17 at 05:40
  • please make sure your AS version is > 3.0 RC 1 – Amod Gokhale Nov 07 '17 at 05:41
  • @Bqin1 - just tested with one of our apps and its working fine after apk generation as well.. no problem with AS 3.0. In your case it might be some other issue – Amod Gokhale Nov 09 '17 at 10:03
  • okay I will try uninstall AS and reinstalling it tonight and see if it still breaks. – Bqin1 Nov 09 '17 at 17:11
  • Btw It didn't work, but the other comment about using apktool did work. It was a long process and very hacky but it was the one that worked. – Bqin1 Sep 10 '18 at 19:55
1

I found solution for INSTALL_PARSE_FAILED_MANIFEST_MALFORMED The difference between the eclipse and android studio project just in AndroidManifest.xml

in Eclipse path to activity:

<activity android:name="WinActivity">

in Android Studio :

<activity android:name="Com.my.package.WinActivity">

And problem with capital letter in AS only in path to all Activityes in AndroidManifest; Because Android Studio always merge manifest file, and fill full path to all Activityes;

If you get compiled apk from AS, open it it apktools, change AndroidManifest.xml (change path to <activity android:name="WinActivity">) and make apk with apktools back. All will work.

Second way to fix this problem: Move all java files into another package with lowercase letter. for example some.new.package. Package with capital letter will stay empty. In AndroidManifest.xml - you need to set full path to all Activityes.

<activity android:name="some.new.package.WinActivity">`

Package in manifest you stay old;

<manifest xmlns:android="http://schemas.android.com/apk/res/android"

    package="Com.my.package"

and in build.gradle you stay old package to:

applicationId "Com.my.package"

If you see and error with R class in your classes. Just import Com.my.package.R in all class when need it.

  • This worked, for those with similar problems, the following 2 links will also help you greatly. https://stackoverflow.com/questions/30590242/convert-unsigned-apk-into-signed-apk http://akashkhaitan.soulastral.com/android/unpackingandrepackingapk – Bqin1 Sep 10 '18 at 19:56