question

desertdevil avatar image
desertdevil asked

ADM, Adobe AIR, the AndroidManifest.xml and you

Greetings, I wrote up this little guide for those looking to integrate ADM into an app built on top of Adobe AIR. I hope you will find it useful. If your app is built on top of Adobe AIR and you're trying to integrate ADM, you might have run into issues packaging your application (.apk). Specifically, after following the documentation listed here https://developer.amazon.com/sdk/adm/integrating-app.html under the section [i]Update Your App Manifest[/i], you were probably tempted to just edit your application descriptor (-app.xml) file and add everything requested under the android section. However, simply doing so will result in the following errors when packaging your app using Adobe's ADT (Air Developer Tool): [i]error 400: Current Android sdk version doesn't support xmlns:amazon as attribute error 402: Current Android sdk version doesn't support amazon:enable-feature as xml tag[/i] The problem here is that ADT is performing some sort of validation on the resulting AndroidManifest.xml file that it generates (using some template + the -app.xml) and that validation step is failing and causing the tool to not generate an .apk. I can only speculate, but I suspect the validation is based on the allowable attributes in an android manifest file as outlined here: http://developer.android.com/guide/topics/manifest/manifest-intro.html Ok, great, so how do I get around this? Well, at a high level, the solution is to package the .apk using ADT without the offending elements, unpack this .apk, add the missing elements into the AndroidManifest.xml, and re-package the .apk. The details on how precisely to do this follow. Note that I am running on Mac OSX Lion, so some of the details may be slightly different depending on your OS. 1. Follow the instructions on the Amazon Mobile App Distribution Portal here: https://developer.amazon.com/sdk/adm/integrating-app.html for updating your manifest by adding the appropriate elements to your application descriptor file (-app.xml) under the android section. Be sure to [b]exclude the addition of the amazon namespace (i.e., xmlns:amazon=...) and the tag for enabling ADM (i.e., ).[/b] 2. Build and package your .apk as you normally would using ADT. 3. Download the android-apk tool from http://code.google.com/p/android-apktool/. Be sure to follow the directions for installation on that page and make sure you can run the command [b]apktool[/b] from the command line. 4. Unpack the .apk you created in step 2) into a temp directory. For example: [i]apktool d -f .apk [/i] 5. Modify the /AndroidManfest.xml file to include the elements excluded in step 1). Use whatever means you want to do this. On the Mac, I just use sed. 6. Re-package the .apk using the apktool, i.e.: [i]apktool b .apk[/i] 7. Using the jarsigner tool, sign the re-packaged .apk as it has changed. More information on signing your application can be found here: http://developer.android.com/tools/publishing/app-signing.html. For example, your command might look like this: [i]jarsigner -verbose -storetype pkcs12 -keystore -storepass .apk [/i] 8. Align the .apk using zipalign. For example: [i]zipalign -f -v 4 .apk .apk[/i] And that's it! Justin W. Russell, Senior Software Engineer Row Sham Bow, Inc. Try out our easy-to-integrate analytics solution in your mobile app! Go to http://www.splyt.com for details.
amazon device messaging
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

rajareddyp avatar image
rajareddyp answered
Hi, i have integrated Adobe Device Messaging for push notification in my application. i had followed all the steps you mentioned above. this is the -app.xml file i had declared all the permission in manifest. still call back was not calling in receiver . there is know errors but still i am unable to see logs in Receiver call backs. this is the function for registration final ADM adm = new ADM(ctx.getActivity()); Log.i(TAG, " after ADM == "); try { if (adm.isSupported()) { String regId = adm.getRegistrationId(); if (regId == null || regId.equals("")) { Log.d("RegisterForPush", "if regID is empty string"); adm.startRegister(); } else { Log.d("RegisterForPush", "reg id found:" + regId); FREObject deviceInfoObject = null; deviceInfoObject = FREObject.newObject(regId); return deviceInfoObject; } } else { Log.i(TAG, " **** not supported**** "); } } catch (FREWrongThreadException e) { Log.i(TAG, "Error = " + e.toString()); e.printStackTrace(); ctx.dispatchStatusEventAsync(AppConstants.ERROR_EVENT, e.toString()+","+e.getMessage()+","+e.getLocalizedMessage()+","+Utils.getExceptionStackTraceAsString(e)); } this is the -app.xml file com.raja.pushapp azp_ane BT 0.0.5 [This value will be overwritten by Flash Builder in the output app.xml] false false true <manifest android:installLocation="auto"> <uses-sdk android:minSdkVersion="15" android:targetSdkVersion="15"/> <uses-permission android:name="android.permission.INTERNET"/> <uses-permission android:name="android.permission.WAKE_LOCK" /> <permission android:name="air.com.raja.pushapp.permission.RECEIVE_ADM_MESSAGE" android:protectionLevel="signature" /> <uses-permission android:name="air.com.raja.pushapp.permission.RECEIVE_ADM_MESSAGE" /> <uses-permission android:name="com.amazon.device.messaging.permission.RECEIVE" /> <application> <service android:name="com.bt.admpushnotify.SampleADMMessageHandler" android:exported="false" /> <receiver android:name="com.bt.admpushnotify.SampleADMMessageHandler$MessageAlertReceiver" android:permission="com.amazon.device.messaging.permission.SEND" > <intent-filter> <action android:name="com.amazon.device.messaging.intent.REGISTRATION" /> <action android:name="com.amazon.device.messaging.intent.RECEIVE" /> <category android:name="air.com.raja.pushapp" /> </intent-filter> </receiver> </application> </manifest> <key>UIDeviceFamily</key> <array> <string>1</string> <string>2</string> </array> high com.bt.admpushnotify
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

rajpixelmags avatar image
rajpixelmags answered
Hi, Is it possible to get ANE for implementing the push notifications with Adobe AIR?? Thank you, Rajkumar
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Sujoy@Amazon avatar image
Sujoy@Amazon answered
Hi Rajpixelmags, Adobe ANE is not officially supported at this moment. Sorry for the inconvenience.
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Bob Scherne avatar image
Bob Scherne answered
Thanks for the guide! We're having a bit of trouble, though. We've published in Flash Pro CS6, using a .p12 generated by Flash's certificate tool. It took a while, but I did eventually find out that the keystore alias for those .p12's is "1", so I was able to complete the process. However, I'm unable to actually install the resulting APK file (getting an "Application not installed" error). At first I thought perhaps I was adding the stuff to the manifest incorrectly, and played around with that a bit. Nothing worked, so I tried going through the process and completely skipping step 5, which theoretically should produce an APK that is the same as the original. Unfortunately, that won't install either. I'm using the same cert that the original app was signed with, so that's not the problem. I tried uninstalling the app from the device and retrying though, just to make sure, and still no go. I did notice that on step 4, however, I get this in my output: S: Could not decode file, replacing by FALSE value: raw/mms_cfg.png S: Could not decode file, replacing by FALSE value: raw/ss_sgn.png S: Could not decode file, replacing by FALSE value: drawable/icon.png S: Could not decode file, replacing by FALSE value: raw/ss_cfg.png S: Could not decode file, replacing by FALSE value: raw/ debugger.info Could this be the problem? If so, any ideas on how I could fix that?
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Bob Scherne avatar image
Bob Scherne answered
Ok, I've discovered why I couldn't install. I'm using JDK 1.7, so jarsigner isn't configured for Android. Here's what I had to change for step 7: [i]jarsigner -sigalg MD5withRSA -digestalg SHA1 -verbose -storetype pkcs12 -keystore -storepass .apk [/i] I'm still not getting any subscribers when I run the app, but that's another problem...
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

raj-215 avatar image
raj-215 answered
Hi, I am able to decompile the apk but again its failing on recompiling. /usr/local/bin/aapt: /usr/local/bin/aapt: cannot execute binary file Exception in thread "main" brut.androlib.AndrolibException: brut.androlib.AndrolibException: brut.common.BrutException: could not exec command: [aapt, p, --min-sdk-version, 8, --target-sdk-version, 14, -F, /var/folders/yj/dtcp51ld08jgnfg95qxbdvdm0000gn/T/APKTOOL8938749821681715291.tmp, -I, /Users/rajakumar/Library/apktool/framework/1.apk, -S, /Users/rajakumar/Desktop/tem/res, -M, /Users/rajakumar/Desktop/tem/AndroidManifest.xml] also is this only way to get amazon:enable-feature working? because we have more than 300 apks to do this. Please let me know, if there is any other way to get this working. Thank you, Raj.
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

desertdevil avatar image
desertdevil answered
aapt is the Android Asset Packaging Tool (see http://developer.android.com/tools/building/index.html). Few questions: 1) Do you have your Android sdk installed correctly (i.e., does aapt exist in /usr/local/bin and can you run it from the command line?) 2) Which version of the apktool are you using? 3) Which Revision of the Android SDK Build-tools do you have installed?
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

raj-215 avatar image
raj-215 answered
Hi , Thanks for your help. Finally I'm able to decompile and recompile the apk. After signing the apk, i have installed apk on device. But still the push notifications are not working. I'm using the ANE provided by PushWoosh. If any one tried using PushWoosh please let me know. Thank you, Raj.
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

shadernz avatar image
shadernz answered
Hi, I think I have replied you here: https://github.com/shaders/push-notifications-sdk/issues/33#issuecomment-28816384 Pushwoosh team
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

RajaReddy avatar image
RajaReddy answered
I tried this way what you explained in the above procedure. still i am unable to install app in the device.
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.