簡體   English   中英

Android Studio“應用程序具有相同的程序包名稱”

[英]Android Studio “applications have the same package name”

我在Android Studio中的應用程序具有用於移動設備和Google眼鏡的單獨組件。 當我嘗試將移動版本加載到Nexus 10(Android版本4.4.2)時,出現以下錯誤:

Applications have the same package name com.example.carterpedersen.datatransfer:
mobile, glass

但是,我可以毫無問題地將應用程序加載到玻璃設備(XE19.1)上。

我發現這個錯誤令人困惑,因為我的應用程序運行了好幾周都沒問題,並且突然移動組件癱瘓了。 我最近確實在移動組件上添加了對glass R的依賴關系,但是即使在幾天后,此錯誤仍未顯示出來。

我嘗試重構移動目錄以及整個程序包,但均未成功。

我已經搜索了SO和其他資源,但沒有找到任何重復的內容。 如果在這一點上我錯了,請聯系我。 謝謝您的幫助。 提供的清單如下。

行動清單:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.carterpedersen.datatransfer" >

<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >

    <activity
        android:name="com.example.carterpedersen.datatransfer.FileRetrieval"
        android:label="@string/app_name" >
    </activity>

    <activity
        android:name="com.example.carterpedersen.datatransfer.BluetoothClient"
        android:label="@string/title_activity_bluetooth_client" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

</application>

玻璃櫃:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.carterpedersen.datatransfer" >

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name="com.example.carterpedersen.datatransfer.LauncherActivity"
        android:label="@string/title_activity_launcher" >
    </activity>
    <activity
        android:name="com.example.carterpedersen.datatransfer.LiveCardMenuActivity"
        android:theme="@style/MenuTheme" >
    </activity>

    <!-- Service responsible for maintaining LiveCard -->
    <service
        android:name="com.example.carterpedersen.datatransfer.LiveCardDataCollect"
        android:icon="@drawable/ic_glass_logo"
        android:label="@string/title_activity_live_card_data_collect" >
        <intent-filter>
            <action android:name="com.google.android.glass.action.VOICE_TRIGGER" />
        </intent-filter>

        <meta-data
            android:name="com.google.android.glass.VoiceTrigger"
            android:resource="@xml/voice_trigger" />
    </service>

    <!-- For content sharing permissions -->
    <provider
        android:name="android.support.v4.content.FileProvider"
        android:authorities="com.example.carterpedersen.datatransfer.fileprovider"
        android:exported="false"
        android:grantUriPermissions="true" >
        <meta-data
            android:name="android.support.FILE_PROVIDER_PATHS"
            android:resource="@xml/file_paths" />
    </provider>

    <!-- Selects file for sharing to client. -->
    <activity
        android:name="com.example.carterpedersen.datatransfer.FileShareActivity"
        android:label="@string/title_activity_file_share" >
        <intent-filter>
            <action android:name="android.intent.action.PICK" />

            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.OPENABLE" />

            <data android:mimeType="*/*" />
        </intent-filter>
    </activity>

    <activity
        android:name="com.example.carterpedersen.datatransfer.BluetoothHost"
        android:label="@string/title_activity_bluetooth_host" >
    </activity>

    <receiver android:name="com.example.carterpedersen.datatransfer.BluetoothHost$HostBroadRec" >
        <intent-filter>
            <action android:name="transapps.g6.new.alert" />
        </intent-filter>
    </receiver>

</application>

嘗試僅使用一個清單(結合在移動設備和Glass上使用-我假設一個apk正確嗎?)

只需完全關閉android studio並重新打開即可。 此后我的問題解決了。

順便說一下,您可以在cmd上嘗試以下命令:

adb uninstall com.your.package

嘗試更改每個AndroidManifest.xml文件中的package名稱。 因此,例如,更改為:

移動

<manifest 
    xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.carterpedersen.mobile.datatransfer" >

玻璃

<manifest 
    xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.carterpedersen.glass.datatransfer" >

程序包名稱在應用程序中應該是唯一的。 請參閱package屬性定義

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM