【问题标题】:Creating multiple custom versions of the same android app创建同一个安卓应用的多个自定义版本
【发布时间】:2015-04-15 14:56:58
【问题描述】:

我正在尝试为不同的客户创建我的应用的多个版本,并已完成以下步骤:

-在查找器中通过简单的复制和粘贴来复制所有文件夹,

-打开我刚刚创建的项目,

-更改了AndroidManifest.xml中的包名,

-重构所有失败的类和文件(使用重构选项),

-清除项目并运行。

我已经能够在设备中安装这 2 个应用程序,但每次我尝试运行任何应用程序时,操作系统都会向我显示:

如您所见,我已经安装并运行了 2 个应用程序:

每次我按下一个按钮时再问我一次:

这是第一个 AndroidManifest.xml

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="epinom.jm.smarthotel"
    android:versionCode="1"
    android:versionName="1.0" >

   <uses-sdk
        android:minSdkVersion="14"
        android:targetSdkVersion="16" />

    <permission android:name="epinom.jm.smarthotel.maps.googlev2.permission.MAPS_RECEIVE"
        android:protectionLevel="signature">

    </permission>

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.GET_TASKS" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
    <uses-permission android:name="android.permission.CALL_PHONE"/>
    <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
    <uses-permission android:name="epinom.jm.smarthotel.maps.googlev2.permission.MAPS_RECEIVE"/>


    <uses-feature android:glEsVersion="0x00020000"
                  android:required="true"/>

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

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

        <meta-data android:name="com.google.android.maps.v2.API_KEY"
               android:value="AIzaSyBjg8TtFgJTMuLFyiGlScVuEDNPjJnLxyM"/>

        <activity
            android:name=".SplashActivity"
            android:label="@string/title_activity_home"
            android:screenOrientation="portrait"
            android:launchMode="singleTask" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

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

         <activity
            android:name=".vcMainScreen"
            android:label="@string/title_activity_home"
            android:screenOrientation="portrait"
            android:launchMode="singleTask" >
            <intent-filter>
                <action android:name="vcMainScreen" />

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

</manifest>

这是第二个 AndroidManifest.xml

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="goSmart.guestperience.MoncloaDeSanLazaro"
    android:versionCode="1"
    android:versionName="1.0" >

   <uses-sdk
        android:minSdkVersion="14"
        android:targetSdkVersion="16" />

    <permission android:name="goSmart.guestperience.MoncloaDeSanLazaro.maps.googlev2.permission.MAPS_RECEIVE"
        android:protectionLevel="signature">

    </permission>

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.GET_TASKS" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
    <uses-permission android:name="android.permission.CALL_PHONE"/>
    <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
    <uses-permission android:name="goSmart.guestperience.MoncloaDeSanLazaro.maps.googlev2.permission.MAPS_RECEIVE"/>


    <uses-feature android:glEsVersion="0x00020000"
                  android:required="true"/>

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

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

        <meta-data android:name="com.google.android.maps.v2.API_KEY"
               android:value="AIzaSyDNqe1PO7pvZLtba_Vu3m5BvmOdJtqhU0M"/>

        <activity
            android:name=".SplashActivity"
            android:label="@string/title_activity_home"
            android:screenOrientation="portrait"
            android:launchMode="standard" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

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

         <activity
            android:name=".vcMainScreen"
            android:label="@string/title_activity_home"
            android:screenOrientation="portrait"
            android:launchMode="standard" >
            <intent-filter>
                <action android:name="vcMainScreen" />

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

</manifest>

我从 Android 开发开始,所以请告诉我我做错了什么,有什么我缺少配置的地方。

我在 Mac 上使用 Eclipse。

回答@David 的问题,这是我用来调用每个新屏幕的代码:

String IntentName = Util.getController(buttons
        .getJSONObject(arg2)
        .getString("ViewController"));

Intent intento = new Intent(IntentName);

intento.putExtra(
        "jsonConfig",
        buttons.getJSONObject(arg2).getString(
                "JsonConfigFile"));
intento.putExtra("title", buttons.getJSONObject(arg2)
        .getString("Label"));
intento.putExtra("icon", buttons.getJSONObject(arg2)
        .getString("ImageIconTitle"));

startActivity(intento);

【问题讨论】:

  • 如何处理点击按钮打开活动?在旁注中,停止使用 Eclipse,使用 Android Studio 和 Gradle,研究“风味”是如何工作的,你会为你完成很多这样的工作。
  • 嗨,由于意图过滤器,您遇到了问题,系统会尝试检查哪些应用程序可以处理您请求的意图类型,然后返回可以处理它的应用程序。我建议使用显式意图或将意图过滤器更改为更具体的应用程序。
  • @NimishChoudhary 对不起,我是 Android 开发的超级新手,我认为我不完全理解您要告诉我的内容,所以每次我开始一个新的活动时,呼叫都会发送到所有的妹子看看谁能回应??如果这是真的,有办法解决吗??
  • @MarcoAntonioUzcateguiPescoz 你的代码 String IntentName = Util.getController(buttons .getJSONObject(arg2) .getString("ViewController"));为两个应用程序返回相同的意图名称,因此请尝试为每个应用程序设置不同的名称。
  • @NimishChoudhary我刚刚做到了,你用你之前的评论给了我线索,谢谢我的朋友,我会在几分钟内将答案添加到我的具体代码中。

标签: android xml eclipse


【解决方案1】:

您有 2 个同名活动....在不同的应用程序中。

更改 1 个活动的名称。

【讨论】:

    【解决方案2】:

    感谢 Nimish Choudhary 和更多 Google 的评论,我的问题的答案是我必须为 2 个应用程序设置唯一的所有活动名称。

    所以在 AndroidManifest.xml 我已经更改了所有活动的所有名称,即:

         <activity
            android:name="app1.vcMainScreen"
            android:label="@string/title_activity_home"
            android:screenOrientation="portrait"
            android:launchMode="standard" >
            <intent-filter>
                <action android:name="app1.vcMainScreen" />
    
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>
    

    我在调用函数时更改了开关的返回:

        Util.getController(buttons
                .getJSONObject(arg2)
                .getString("ViewController")
    

    现在的回报是:

        switch (Integer.parseInt(num)) {
        case 0:
            return "app1.vcMainScreen";
        default:
            return null;
        }
    

    我希望有一天这对某人有所帮助。

    谢谢大家。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2010-11-16
      • 1970-01-01
      • 2014-01-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-10-21
      相关资源
      最近更新 更多