简体   繁体   中英

Make apk with Capitalized package name in android studio

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:

在此处输入图片说明

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.

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM