在具有EMM限制AirWatch的PlayStore上发布应用程序时收到错误

问题描述 投票:1回答:1

因此,我一直在努力开发将使用EMM AirWatch的Android应用程序。如文档所述,这些限制非常简单。我必须在清单中添加一个元数据标签,并且必须添加一个带有限制的xml文件。 Java代码已相应完成。到目前为止,一切都很好。但是,当我尝试将其发布到PlayStore时,收到消息“ APK清单指定了应用程序限制架构,但未找到。”顺便说一句,我正在使用Titanium Appcelerator。要使此工作可行,可以做什么?

这是我的清单的摘要:

<?xml version="1.0" encoding="UTF-8"?>
<ti:module xmlns:ti="http://ti.appcelerator.org" 
xmlns:android="http://schemas.android.com/apk/res/android">
  <android xmlns:android="http://schemas.android.com/apk/res/android">
    <manifest>
        <application>
            <meta-data android:name="android.content.APP_RESTRICTIONS"
            android:value="/res/xml/app_restrictions" />
        </application>
   </manifest>
</android>

这里是app_restrictions.xml:

<?xml version="1.0" encoding="utf-8"?>
<restrictions xmlns:android="http://schemas.android.com/apk/res/android">
  <restriction
    android:key="AppLanguage"
    android:title="@string/AppLanguage"
    android:restrictionType=string/>
   <restriction
    android:key="AppUser"
    android:title="@string/AppUser"
    android:restrictionType="string"/>
   <restriction
    android:key="AppPassword"
    android:title="@string/AppPassword"
    android:restrictionType="string"/>
   <restriction
    android:key="AppStationID"
    android:title="@string/AppStationID"
    android:restrictionType="string"/>
   <restriction
    android:key="DeviceSerialNumber"
    android:title="@string/DeviceSerialNumber"
    android:restrictionType="string"/>
</restrictions>

这是我的Java文件:

public class AirwatchandroidModule extends KrollModule
{

private static final String LCAT = "AirwatchandroidModule";
private static final boolean DBG = TiConfig.LOGD;
public static final String APP_LANGUAGE = "AppLanguage";
public static final String APP_USER = "AppUser";
public static final String APP_PASSWORD = "AppPassword";
public static final String APP_STATION_ID = "AppStationID";
public static final String DEVICE_SERIAL_NUMBER = "DeviceSerialNumber";

public AirwatchandroidModule()
{
    super();
}

static KeyedAppStatesReporter rep;

@Kroll.onAppCreate
public static void onAppCreate(TiApplication app) 
{
    Context context = app.getApplicationContext();
    KeyedAppStatesReporter reporter = SingletonKeyedAppStatesReporter.getInstance(context);
    rep = reporter;
}
public String appLanguage;
public String appUser;
public String appPassword;
public String appStationID;
public String appDeviceSerialNumber;

@Kroll.method
public String LoadAirWatch()
{

    RestrictionsManager myRestrictionsMgr =
            (RestrictionsManager) getActivity()
                .getSystemService(Context.RESTRICTIONS_SERVICE);

    Bundle appRestrictions = myRestrictionsMgr.getApplicationRestrictions();

    if (appRestrictions.containsKey(APP_LANGUAGE)) {
        appLanguage = appRestrictions.getString(APP_LANGUAGE);
        System.out.println("appLanguage => " + appLanguage);
    }
    else
    {
        System.out.println("No appLanguage");
        appLanguage = "N";

    }

    if (appRestrictions.containsKey(APP_USER)) {
        appUser = appRestrictions.getString(APP_USER);
        System.out.println("appUser => " + appUser);
    }
    else
    {
        System.out.println("No appUser");
        appUser = "N";

    }

    if (appRestrictions.containsKey(APP_PASSWORD)) {
        appPassword = appRestrictions.getString(APP_PASSWORD);
        System.out.println("appPassword => " + appPassword);
    }
    else
    {
        System.out.println("No appPassword");
        appPassword = "N";

    }

    if (appRestrictions.containsKey(APP_STATION_ID)) {
        appStationID = appRestrictions.getString(APP_STATION_ID);
        System.out.println("appStationID => " + appStationID);
    }
    else
    {
        System.out.println("No appStationID");
        appStationID = "N";

    }

    if (appRestrictions.containsKey(DEVICE_SERIAL_NUMBER)) {
        appDeviceSerialNumber = appRestrictions.getString(DEVICE_SERIAL_NUMBER);
        System.out.println("appDeviceSerialNumber => " + appDeviceSerialNumber);
    }
    else
    {
        System.out.println("No appDeviceSerialNumber");
        appDeviceSerialNumber = "N";

    }

    return appLanguage + "|" + appUser + "|" + appPassword + "|" + appStationID + "|" + appDeviceSerialNumber;
}

 }

要使此应用程序与Airwatch配合使用,我缺少什么吗?

java android appcelerator-titanium airwatch android-restrictions
1个回答
0
投票

嗯,经过几天的痛苦和痛苦,我终于找到了解决方案。我不知道为什么,但是Android Studio(Android开发者网站所基于的)和Titanium Appcelerator上的某些代码之间几乎没有(几乎不是很少)差异。我试图将文件从一个地方移到另一个地方,几乎阅读了整个互联网以找到解决方案,但是整个过程一直困扰着我。Android开发者网站(https://developer.android.com/work/managed-configurations)告诉我们将以下内容添加到清单中:

<meta-data android:name="android.content.APP_RESTRICTIONS"
android:resource="@xml/app_restrictions" />

这可能适用于Android Studio,但不适用于Appcelerator。这是我提到的小差异。什么对我有用?这个:

<meta-data android:name="android.content.app_restrictions"
android:resource="@xml/app_restrictions" />

名称和资源的单词应该完全相同,没有大写字母。

就是这样。希望任何人阅读此书,在处理此错误时都可以节省时间和理智。

© www.soinside.com 2019 - 2024. All rights reserved.