我正在尝试使用Google Play Services lib的某些功能,但我无法使其正常运行。我已将对google play服务库的引用添加到清单文件(来自Flash Builder)
<application android:enabled="true">
<meta-data android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
<activity android:excludeFromRecents="false">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>
在我的ANE中,我添加了对google-play-services_lib源代码的引用,但是当我尝试调用FREFunction来检查Google Play服务的可用性时
@Override
public FREObject call(FREContext context, FREObject[] args){
boolean result = false;
try{
Activity activitiy = context.getActivity();
activityContext = activitiy.getBaseContext();
result = isGooglePlayServiceExists();
}catch(IllegalStateException e){
Log.e(AneUtils.TAG, "Failed to get AIR current activity", e);
}
FREObject obj = null;
try{
obj = FREObject.newObject(result);
}catch(FREWrongThreadException e){
Log.e(AneUtils.TAG, "Failed to create FREObject from [" + result + "]");
}
return obj;
}
private boolean isGooglePlayServiceExists(Context activityContext){
int googlePlayServicesCheck = -1;
try{
googlePlayServicesCheck = GooglePlayServicesUtil.isGooglePlayServicesAvailable(activityContext);
}catch(Exception e){
Log.e(AneUtils.TAG, "Error getting googlePlayService state",e);
}
if(googlePlayServicesCheck == ConnectionResult.SUCCESS){
return true;
}
return false;
}
ANE在GooglePlayServicesUtil.isGooglePlayServicesAvailable(activityContext)行崩溃,所以我真的怀疑没有添加Google Play服务库。
有没有人成功将Google Play服务库导入Adobe AIR Android应用程序?
任何建议或帮助将不胜感激。谢谢。
答案 0 :(得分:1)
对于寻找答案的人,希望这会有所帮助: 为了让我们在ANE中使用任何Google Android库(或第三方Android库),您必须找到Android库的真实版本号,然后将该号码插入清单文件中。 例如,而不是
<meta-data android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
我们必须找出真实的版本号,你的清单数据应该是:
<meta-data android:name="com.google.android.gms.version"
android:value="4432145" />
在这种情况下,号码4432145是我们要使用的GooglePlayService库的版本号。您可以在Android库项目的资源中找到此编号。 将来,如果要升级以使用最新版本的GooglePlayService库,则必须重建ANE文件并将版本号更正为清单文件中库的新版本号。