0

I'm migrating from Eclipse to Android Studio. When I integrate Google-play-services into my project, I fail to install the APK to a device with the following error: "INSTALL_PARSE_FAILED_MANIFEST_MALFORMED". How come eerrApparently Android Studio and this library has a compatibility issue with my legacy app's package name which starts with an uppercase letter. When I change the first letter of the package name (ApplicationId in Android Studio) to lower, everything is fine. Note that my base package name is all lowercase. The problem is with ApplicationId.

The app is live on the store for a few years now and I don't want to upload it as a new app.

Really stuck on this - is there a workaround?

Noam Behar
  • 201
  • 2
  • 11

2 Answers2

0

Please refer to Naming Conventions

You can not simply use upper case with package name anymore.

Community
  • 1
  • 1
Abhinav Aggarwal
  • 416
  • 3
  • 14
  • Just to clarify, this is my ApplicationId and not my peoject's package name in the manifest. Everything works well in Eclipse. It also worked in Android Studio before I added Google services. Am I now stuck with Eclipse? I can't believe that there is no workaround to support that. – Noam Behar Feb 21 '17 at 17:01
0

This worked for me:

Instead of importing the eclipse project into Android Studio,

(1) Create a new Android Studio project with the package name that you have already put on the Google Play Store but use all lower case.

(2) Then copy all your files into the Android Studio project.

(3) Change the package ID in the build.gradle (Module App) file with the original package name with upper case (see below) and sync (this will create the package name in the apk with the original package name with upper case chars and it will upload to the Google Play Store and replace your old one!!!

(4) This installed the apk (with uppercase package name) onto my test phone and it worked perfectly.

apply plugin: 'com.android.application'
android {
    compileSdkVersion 21
    buildToolsVersion "21.1.2"
    defaultConfig {
        applicationId "DrWebsterApps.New.England.Patriots.Game"
        minSdkVersion 9
        targetSdkVersion 21
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}
dependencies {
    compile 'com.android.support:appcompat-v7:21.0.0'
    compile 'com.google.android.gms:play-services:7.0.0'
}

(5) as a test case here is code that pops up the currently running app's package name to proof it:

import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.app.Activity;
import android.app.ActivityManager;
import android.app.ListActivity;
import android.app.ActivityManager.RunningAppProcessInfo;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;
import java.util.List;

public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        /* put this in the manifest.xml file!!!
           <uses-permission android:name="android.permission.GET_TASKS"/>
*/
        ActivityManager am = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
        List<ActivityManager.RunningTaskInfo> taskInfo = am.getRunningTasks(1);

        createDialogAnswer(taskInfo.get(0).topActivity.getPackageName());


}

    public void createDialogAnswer(String msg) {

        AlertDialog.Builder adb;
        LinearLayout linear = new LinearLayout(this);
        linear.setBackgroundColor(Color.RED);
        linear.setOrientation(LinearLayout.VERTICAL);
        adb = new AlertDialog.Builder(this);
        // String team = (string)R.string.app_name;
        adb.setTitle("  Trivia App");
        adb.setView(linear);

        LayoutInflater mInflater = (LayoutInflater) this
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View PopUpView = mInflater.inflate(R.layout.scores, linear);
        TextView mytext = (TextView) PopUpView.findViewById(R.id.QPopUp);

      //  mytext.setTextColor(getResources().getColor(R.color.White));
      //  mytext.setTextSize(getResources().getDimension(R.dimen.aboutApp_text_size));

        mytext.append(msg + " \n");

        adb.setNegativeButton("Quit", myDialogOnClickListener);
        adb.show();

    }

    DialogInterface.OnClickListener myDialogOnClickListener = new DialogInterface.OnClickListener() {

        public void onClick(DialogInterface v, int x) {

        finish();
        }
    };