freshplanet / ANE-Push-Notification

Air Native Extension (iOS and Android) for Push Notification
Apache License 2.0
205 stars 104 forks source link

Missing android.support.v4 #61

Closed CarlitoLoco closed 7 years ago

CarlitoLoco commented 9 years ago

Hi,

I've been struggling for a while now trying to get this extension to work. It all comes down to a problem due to a missing library in the ANE (whatever the version):

Could not find class 'android.support.v4.app.NotificationCompat$Builder', referenced from method com.freshplanet.nativeExtensions.CreateNotificationTask.onPostExecute

The solution (described by smart contributers) is to tweak the build.xml and recompile the ANE.

For all those of us who don't know how to recompile this ANE (setting up a working environment to compile it is a pain), could you post a new revision of the extension including that library?

Thank you for sharing this great ANE with all of us. It's just a small step away from being perfect!

esdebon commented 9 years ago

You can try add the jar files to the ANE unzipping the AirPushNotification.ane file:

This some times work... try it

CarlitoLoco commented 9 years ago

Thanks for your answer esdebon. I did what you suggested and that doesn't work for me... I still get that "Could not find class" error.

I've noticed that in the Facebook Freshplanet ANE (that has the needed lib), the android-support-v4.jar isn't there either. However, the sources of the \android\support\v4 are in the libAirFacebook.jar, that is in the Facebook ANE.

Any help is appreciated. Thank you!

esdebon commented 9 years ago

Ok, try with this, compiled with the android-support-v4.jar and Android x86 support:

https://github.com/esdebon/ANE-Push-Notification/releases/download/20141217/AirPushNotification.ane

CarlitoLoco commented 9 years ago

Thank you for your help esdebon. Unfortunately, I can't compile my project with this ANE.

It gives me an error about duplicate content:

aapt tool failed:C:\Users\XXX\AppData\Local\Temp\aa5ce324-c946-4994- a6bf-58947c4faa5b\res\values\styles.xml: error: Duplicate file. C:\Users\XXX\AppData\Local\Temp\b32e7a0d-88a3-4055-b05e-6fbf2e6011f1\ap p_entry_res\values\styles.xml: Original is here.

Could this be due to the Android x86 support?

Let me know,

ate864 commented 9 years ago

Hello, I remember that i had just to include facebook ane (even if i don't use it) with push ane from freshplanet and all work great! Also, is there a plan on rebuilding the freshplanet ane for ios 64bit, (before february?)

CarlitoLoco commented 9 years ago

Thanks for the help ate864. That's exactly what I did to get it working.

BUT I'd like to have a more elegant solution than embedding a library that I don't use and thought it would be very useful to have a clean working ANE for all other users who, like me, can't recompile the ANE.

Cheers,

esdebon commented 9 years ago

I removed the styles.xml... maybe this is the solution:

https://github.com/esdebon/ANE-Push-Notification/releases/download/20141217/AirPushNotification.ane

I apologize, because right now I do not have the tools to test

CarlitoLoco commented 9 years ago

Thanks so much, and no need to apologize... I understand this is a free tool and you're a great help.

But it still can't compile: aapt tool failed:ERROR: input directory '--auto-add-overlay' does not exist

I have absolutely no experience in creating/compiling an ANE so sorry but I'm not much help... Cheers,

esdebon commented 9 years ago

New try:

https://github.com/esdebon/ANE-Push-Notification/releases/download/20141217/AirPushNotification.ane

I get the error:"aapt tool failed:ERROR: input directory '--auto-add-overlay' does not exist" when add <packagedDependency>android-support-v4.jar</packagedDependency> I removed the line.

About the 64 bits support... we are waiting the AIR SDK 16.0 http://labsdownload.adobe.com/pub/labs/flashruntimes/shared/air16_flashplayer16_releasenotes.pdf

CarlitoLoco commented 9 years ago

Sorry but it still does not work... This last version of the ANE compiles, but the app crashes with the same error about the missing class. Back to first base. Have you recompiled it or are you trying to include new stuff in the ANE archive?

As I mentioned, the Facebook ANE (which does have the v4 package) does not have a separate jar in the ANE archive. The v4 classes are compiled in the libAirFacebook.jar. You might want to try something similar?

Cheers,

esdebon commented 9 years ago

all attempts were recompiling...

esdebon commented 9 years ago

Although it is a good idea to try without compiling

My last try:

https://github.com/esdebon/ANE-Push-Notification/releases/download/20141217/AirPushNotification.ane

CarlitoLoco commented 9 years ago

That was worth trying, but it doesn't work... It compiles but gives the missing class error.

Thanks for your efforts!

esdebon commented 9 years ago

I finally have my test environment. I already tried the last file I sent and it works perfectly ...

Logcat: 12-23 14:26:43.451: I/GCM(2320): GCM message com.fluocode.app 0:1419366344650583%0c154cd5f9fd7ecd 12-23 14:26:43.491: I/GCM(2320): GCM message com.fluocode.app 0:1419366374067793%0c154cd5f9fd7ecd 12-23 14:26:43.521: I/GCM(2320): GCM message com.fluocode.app 0:1419366378717188%0c154cd5f9fd7ecd 12-23 14:26:43.551: I/GCM(2320): GCM message com.fluocode.app 0:1419366381365771%0c154cd5f9fd7ecd 12-23 14:26:43.551: D/ApplicationPolicy(2025): isStatusBarNotificationAllowed: packageName = com.fluocode.app

Output window [StatusEvent type="status" bubbles=false cancelable=false eventPhase=2 code="LOGGING" level="Registered successfully with token: APA123123123150FbEG4rC0GCyHFJPgzXLTu_LH1FJw5n_5T5YJ30ehvlkg82ErNsfkE1u-Bb2shg8oLVfJuV-weUa_Cp-6XsKMb123123120qrZ8o7_JIRG2Z0XbOeNiwKrL-f12312312_r7A"] Registered successfully with token: APA123123123150FbEG4rC0GCyHFJPgzXLTu_LH1FJw5n_5T5YJ30ehvlkg82ErNsfkE1u-Bb2shg8oLVfJuV-weUa_Cp-6XsKMb123123120qrZ8o7_JIRG2Z0XbOeNiwKrL-f12312312_r7A My push token is: APA123123123150FbEG4rC0GCyHFJPgzXLTu_LH1FJw5n_5T5YJ30ehvlkg82ErNsfkE1u-Bb2shg8oLVfJuV-weUa_Cp-6XsKMb123123120qrZ8o7_JIRG2Z0XbOeNiwKrL-f12312312_r7A Registered with registration idAPA123123123150FbEG4rC0GCyHFJPgzXLTu_LH1FJw5n_5T5YJ30ehvlkg82ErNsfkE1u-Bb2shg8oLVfJuV-weUa_Cp-6XsKMb123123120qrZ8o7_JIRG2Z0XbOeNiwKrL-f12312312_r7A [StatusEvent type="status" bubbles=false cancelable=false eventPhase=2 code="LOGGING" level="Received push notification with parameters: {"parameters":{"pictureUrl":"10012312312315004288"},"tickerText":"123123123150","collapse_key":"do_not_collapse","from":"86123129150","contentTitle":"123123123150","contentText":"MENSAJE MENSAJE MENSAJE MENSAJE MENSAJE MENSAJE MENSAJE MENSAJE MENSAJE MENSAJE "}"] Received push notification with parameters: {"parameters":{"pictureUrl":"10012312312315004288"},"tickerText":"123123123","collapse_key":"do_not_collapse","from":"86123129150","contentTitle":"123123123","contentText":"MENSAJE MENSAJE MENSAJE MENSAJE MENSAJE MENSAJE MENSAJE MENSAJE MENSAJE MENSAJE "}

CarlitoLoco commented 9 years ago

Thanks so much.

I've checked it again and that last version does not work for me... I still get the same error:

[ 12-24 01:50:56.261 25751:25751 E/dalvikvm ] Could not find class 'android.support.v4.app.NotificationCompat$Builder', referenced from method com.freshplanet.nativeExtensions.CreateNotificationTask.onPostExecute

I'm no expert here but I confirm this last version does not work for me... Are you sure you do not have these v4 classes embedded in another ANE or something?

Cheers and enjoy your holidays!

esdebon commented 9 years ago

Sure, I builded a quick flash project to test the ANE.Only use that component

rewb0rn commented 9 years ago

Hello, I receive the same issue with the latest version (downloaded a few minutes ago):

E/dalvikvm(2542): Could not find class 'android.support.v4.app.NotificationCompat$Builder', referenced from method com.freshplanet.nativeExtensions.CreateNotificationTask.onPostExecute W/dalvikvm(2542): VFY: unable to resolve new-instance 221 (Landroid/support/v4/app/NotificationCompat$Builder;) in Lcom/freshplanet/nativeExtensions/CreateNotificationTask; I/PowerManagerService(562): setBrightness mButtonLight 0. W/dalvikvm(2542): threadid=1: thread exiting with uncaught exception (group=0x40fee9a8) E/AndroidRuntime(2542): FATAL EXCEPTION: main E/AndroidRuntime(2542): java.lang.NoClassDefFoundError: android.support.v4.app.NotificationCompat$Builder E/AndroidRuntime(2542): at com.freshplanet.nativeExtensions.CreateNotificationTask.onPostExecute(Unknown Source) E/AndroidRuntime(2542): at com.freshplanet.nativeExtensions.CreateNotificationTask.onPostExecute(Unknown Source) E/AndroidRuntime(2542): at android.os.AsyncTask.finish(AsyncTask.java:631) E/AndroidRuntime(2542): at android.os.AsyncTask.access$600(AsyncTask.java:177) E/AndroidRuntime(2542): at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:644) E/AndroidRuntime(2542): at android.os.Handler.dispatchMessage(Handler.java:99) E/AndroidRuntime(2542): at android.os.Looper.loop(Looper.java:153) E/AndroidRuntime(2542): at android.app.ActivityThread.main(ActivityThread.java:5299) E/AndroidRuntime(2542): at java.lang.reflect.Method.invokeNative(Native Method) E/AndroidRuntime(2542): at java.lang.reflect.Method.invoke(Method.java:511) E/AndroidRuntime(2542): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833) E/AndroidRuntime(2542): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600) E/AndroidRuntime(2542): at dalvik.system.NativeStart.main(Native Method)

I did not recompile the ane, just took the one from the bin folder. (Not the multimsg, the other one)

CarlitoLoco commented 9 years ago

Hi there,

Are there any plans to fix this issue? My project still gives this "Could not find class 'android.support.v4.app.NotificationCompat$Builder' " error, when using the latest build. Now, even including the latest FaceBook ANE, doesn't make it work anymore (It seems the v4 libs are not in the facebook ANE anymore)...

As I need to include all iOS 64bit support and have to update all my ANEs, this is blocking.

I'm aware it is a free ANE and I really appreciate your work and open-mindness to give this to us ignorant folks, but I would really appreciate a fix so that I can continue to use it.

Thanks!

s2hago commented 9 years ago

Hi thaks for your build is really helpfull but i get the same "Could not find class 'android.support.v4.app.NotificationCompat$Builder' " please update this we really appreciate

irinelpascu commented 9 years ago

I think I managed to fix it. It works for my app. Let me know. https://drive.google.com/folderview?id=0B6nEmghkuTbZMWc4VGw5alp5Zms&usp=sharing

s2hago commented 9 years ago

Hey thank you so much it works!!!!

irinelpascu commented 9 years ago

You're welcome

s2hago commented 9 years ago

Sorry but now I have a problem changing icons... How can I do that? the easy way please I have no idea compiling anes

irinelpascu commented 9 years ago

open the ane with winrar or something like it and replace the 4 images in AirPushNotification.ane\META-INF\ANE\Android-ARM\res with your ones but keep the same name. If you alter the structure (add or remove folders or the images have other names) it may not compile.

s2hago commented 9 years ago

I already tried that but don't work I changed the extension to zip extract the folders change the icons then add to a rar file change to ane and nothing please any help will be appreciated

irinelpascu commented 9 years ago

don't change the extension and don't extract. create your images with the same names in a folder somewhere, open the archive (i use winrar to open ane archives), go to the res folder and drag and drop the new images in that folder (which will replace the old ones with yours). Good luck!

s2hago commented 9 years ago

ok now it works!! thanks man really helpfull

roby65 commented 9 years ago

How did you fix this issue? I need to recompile it from source as i modified the iOS source code!

irinelpascu commented 9 years ago

I added platform.xml and the android-support-v4.jar in the Android-ARM folder

LucaIaco commented 9 years ago

@pascomach00 I tried your method, but still seems to return me the Could not find class 'android.support.v4.app.NotificationCompat$Builder. I'm using the Adobe Flash CC 2014, and when the apk is built, i tried to decompile that, so i discovered that all the source exist ( like com/something/else, com/google/android/gms/..... ) BUT not the android/support/v4/.... . Instead, seems that the build apk contains only the android/support/v7/appcompat/R.java ( .java because is decompiled ). In the .ane file i have the android-support.v4.jar, and also the contained platform.xml at /META-INF/ANE/Android-ARM/. In the eclipse project i tried to include the support-v4 library in all the possible ways, like dependency project, external jar, or kept as defult library in the libs folder. It's like if flash remove it in the apk compilation step... o.O I can't figure out how to fix it....

irinelpascu commented 9 years ago

download and try mine https://drive.google.com/folderview?id=0B6nEmghkuTbZMWc4VGw5alp5Zms&usp=sharing

LucaIaco commented 9 years ago

@pascomach00 Tried now, and seems that your ane file is 'accepted' somehow, i mean, including your ane, and then, decompiling the resulting apk, i see the android/support/v4... i really don't understand what is my problem, maybe the android.support.v4.jar version?

LucaIaco commented 9 years ago

@pascomach00

It really crazy..... It was the version of android.support.v4.jar. I made a test now, for some magic reason, using the one i had before (i got it, in Eclipse, with right click on the library project, Android Tools > Add Support Library ) it wasn't recognized. i used the android.support.v4.jar included in your ane file, and i test also with a version of another ane project, and this solved the problem! Just to say, using the Add Support Library method, the android.support.v4 file size was 1.2 MB, yours is 759KB, and the other one i tested was 628KB, depending on their version. I was expecting that this library was properly added by eclipse, also relying on the androd target in the project.properties, but seems not. Hope this could help someone

RobertNelson commented 8 years ago

Just worked through a similar issue. Are you including AndroidSupport.ane in your project? We weren't.