2017-02-21 89 views
0

我正在從Eclipse遷移到Android Studio。當我將Google-play-services集成到我的項目中時,我無法將APK安裝到設備上,並顯示以下錯誤消息:「INSTALL_PARSE_FAILED_MANIFEST_MALFORMED」。怎麼來eerrAppartrently Android Studio和這個庫與我的傳統應用程序的包名稱以大寫字母開頭的兼容性問題。當我將包名稱的第一個字母(Android Studio中的ApplicationId)更改爲較低時,一切都很好。請注意,我的基本包名稱全部爲小寫。問題出在ApplicationId上。Google-play-services和INSTALL_PARSE_FAILED_MANIFEST_MALFORMED

該應用程序已在商店中生活了幾年,我不想將其作爲新應用程序上傳。

真的停留在這 - 有解決方法嗎?

回答

0

請參考Naming Conventions

你不能簡單地使用產品包名稱大寫了。

+0

只是爲了澄清,這是我的ApplicationId,而不是清單中我的項目包名稱。在Eclipse中一切正常。在添加Google服務之前,它也在Android Studio中工作。我現在堅持與Eclipse?我不相信沒有解決方法來支持這一點。 –

0

這爲我工作:

,而不是導入Eclipse項目到Android的工作室,

(1)創建你已經提上了谷歌Play商店的包名稱的新的Android Studio項目但使用全部小寫字母。

(2)然後將所有文件複製到Android Studio項目中。 (3)將build.gradle(Module App)文件中的軟件包ID改爲大寫的原始軟件包名稱(見下文)和sync(這將在apk中創建軟件包名稱,其中原始軟件包名稱用大寫字符,它會上傳到谷歌Play商店並更換舊的!

(4)本安裝APK(大寫包名)在我的測試手機,它完美地工作。

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)作爲測試用例,這裏是彈出當前運行的應用程序包名稱以證明它的代碼:

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(); 
     } 
    }; 
相關問題