Android native binding library with Parse 1.9.2 issue. DLL is created but can not use in PCL project

AmitLimjeAmitLimje INMember
edited May 2015 in Xamarin.Android

Hi Team,
I am trying to implement push notifications with Parse 1.9.2 jar in xamarin android.
I was able to create the java Android native binding for Parse 1.9.2 jar. I created a new PCL project and and added a reference dll of parse binding library.
When i build the new PCL project, i get following errors:

**error: ParseCallback1 is not public in com.parse; cannot be accessed from outside package
com.parse.ParseCallback1

error: name clash: done(ParseException) in MainActivity overrides a method whose erasure is the same as another method, yet neither overrides the other
public void done (com.parse.ParseException p0)
first method: done(Throwable) in MainActivity
second method: done(T) in ParseCallback1
where T is a type-variable:
T extends Throwable declared in interface ParseCallback1

error: name clash: done(Throwable) in MainActivity and done(T) in ParseCallback1 have the same erasure, yet neither overrides the other
public void done (java.lang.Throwable p0)
where T is a type-variable:
T extends Throwable declared in interface ParseCallback1**

This is the main activity class:

**public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsApplicationActivity,Com.Parse.ISaveCallback
{
protected override void OnCreate (Bundle bundle)
{
base.OnCreate (bundle);
Parse.Initialize (this,"AppID","RESTAPIKEY");
ParseUser.EnableAutomaticUser();
ParseInstallation.CurrentInstallation.Save ();
ParsePush.SubscribeInBackground ("Android", this);
ParseInstallation.CurrentInstallation.Get ("deviceToken");
global::Xamarin.Forms.Forms.Init (this, bundle);
LoadApplication (new App ());
}
public void Done(Java.Lang.Throwable p0)
{

    }
    public void Done(Java.Lang.Object p1)
    {

    }
    public void Done(Com.Parse.ParseException p0)
    {

    }

}**

Below is the metadata.xml for the native binding libarary project:

    **<attr path="/api/package[@name='com.parse']/interface[@name='ParseCallback1']" name="visibility">public</attr>
        <attr path="/api/package[@name='com.parse']/interface[@name='ParseCallback2']" name="visibility">public</attr>
    <attr path="/api/package[@name='com.parse.codec.net']/class[@name='RFC1522Codec']" name="visibility">public</attr>
     <attr path="/api/package[@name='com.parse.codec.binary']/class[@name='Base32']/method[@name='isInAlphabet']" 
        name="visibility">protected</attr>
        <remove-node path="/api/package[@name='com.parse']/ class[@name='ParseACL.UserResolutionListener']" />
        <remove-node path="/api/package[@name='com.parse.signpost.http']/ class[@name='HttpParameters']" /> 
        <remove-node path="/api/package[@name='com.parse.signpost.basic']/ class[@name='HttpURLConnectionRequestAdapter']" />

**

I am really stuck. It would be really helpful if Xamarin support team can help me to resolve this issue.

Regards,
Amit

Answers

  • Hi Amit. Thanks for using Parse! If it's Push Notification for Android you're looking for, we actually support it in our .NET 1.5.0 SDK. You can get it from the Xamarin Component Store/NuGet/our website: https://parse.com/docs/downloads.

    To get started: https://parse.com/apps/quickstart#parse_push/android/xamarin

    Let me know if you need any further help.

  • AmitLimjeAmitLimje INMember

    @ListiarsoWastuargo
    Hi Listiarso,

    Thanks for your reply.
    I Created a new project by adding Parse.Android.dll and Xamarin.Android.Support.v4.dll to Android project.
    I tried to run the app by initializing with app id and .Net key.
    Installation class of my Parse project was updated with one device. But it only contains installationId. There is no device token created.
    I don't think sending push is possible without device token.
    Could you please advise me on this?

    Regards,
    Amit

  • crossplatformercrossplatformer CAMember

    @ListiarsoWastuargo

    Cool that the .NET SDK finally supports push notifications, thanks for that!

    However, I am also unable to make it work with Xamarin.Android.

    When launching the app, I can see in the debug log:

    W/parse.ManifestInfo : Cannot use GCM for push because AndroidManifest.xml is missing: 
    W/parse.ManifestInfo : <service android:name="parse.ParsePushService" />.
    

    I am 100% sure the

    <service android:name="parse.ParsePushService" />

    as well as everything else that is needed, is included within the AndroidManifest.xml. No typos etc.

    However, since I am using Xamarin.Android 5.0, in the actual generated AndroidManifest.xml it is declared like:

    <service android:name="md558c46fa16d0b39f594789d5760860ef7.ParsePushService" />

    This is apparently because:

    With the 5.0 release, the default package names for Android Callable Wrappers will be based on the MD5SUM of the assembly-qualified name of the type being exported. This allows the same fully-qualified name to be provided from two different assemblies and not get a packaging error.
    developer.xamarin.com/releases/android/xamarin.android_5/xamarin.android_5.0/#Android_Callable_Wrapper_Naming

    Can this cause problems? Any ideas?

  • Yes, it doesn't work well with Xamarin.Android 5.0. Talking with the Xamarin team, trying to fix it now. I'll let you guys know immediately. Sorry for the inconvenience.

  • crossplatformercrossplatformer CAMember

    @ListiarsoWastuargo

    Thanks a lot!
    And no problem, I can fall back to the native Android JAR for the time being.
    Will then switch to the .NET version when it works.

    I don't know if it is of any help to you, but some details:

    1) I am able to see the installation at the Parse console.
    2) But no device token.
    3) And as mentioned, in the debug log the parse.ParsePushService is said to be missing from the app manifest.
    4) Maybe this is because in the generated manifest it is declared with the MD5SUM (md558c46fa16d0b39f594789d5760860ef7.ParsePushService), maybe not.

    In any case, very nice that the .NET SDK now supports push notifications.

  • AmitLimjeAmitLimje INMember

    Hi @crossplatformer ,

    I am stuck while using Parse Android jar native binding for push notifications.I've provided error details in my Initial post above. Could you please provide me any pointers for resolving it. Thanks.

    @ListiarsoWastuargo ,
    Looking forward to .NET version supporting Android/iOS push notifications.

  • crossplatformercrossplatformer CAMember

    Hey @AmitLimje,

    error: name clash: done(Throwable) in MainActivity and done(T) in ParseCallback1 have the same erasure, yet neither overrides the other

    Your problem is related to Java type erasure: ISaveCallback extends ParseCallback1, and they both have the same name method Done - during Java compilation the type information is erased, so you end up with "two same methods" and it cannot be decided which one to use. Search for Java type erasure etc. you will find information :) E.g. change the method name.

    This one you have already solved:

    error: ParseCallback1 is not public in com.parse; cannot be accessed from outside package com.parse.ParseCallback1

    The solution is in your metadata.xml:

    <attr path="/api/package[@name='com.parse']/interface[@name='ParseCallback1']" name="visibility">public</attr>

  • JoshEdwardsJoshEdwards USMember

    Bump. I'm also having this issue- on build I get
    05-30 03:08:01.181 W/parse.ManifestInfo( 9039): Cannot use GCM for push because AndroidManifest.xml is missing:
    05-30 03:08:01.181 W/parse.ManifestInfo( 9039):
    05-30 03:08:01.181 W/parse.ManifestInfo( 9039):
    05-30 03:08:01.181 W/parse.ManifestInfo( 9039):
    05-30 03:08:01.181 W/parse.ManifestInfo( 9039):
    05-30 03:08:01.181 W/parse.ManifestInfo( 9039):
    05-30 03:08:01.181 W/parse.ManifestInfo( 9039):
    05-30 03:08:01.181 W/parse.ManifestInfo( 9039):
    05-30 03:08:01.181 W/parse.ManifestInfo( 9039):

  • GarnishGarnish USMember
    edited June 2015

    I was getting the same notice about missing the parse.ParsePushService attribute but that's gone away, now it's saying something else:

    [parse.ManifestInfo] Cannot use GCM for push because AndroidManifest.xml is missing:
    [parse.ManifestInfo] uses-permission android:name="android.permission.INTERNET"
    [parse.ManifestInfo] uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"
    [parse.ManifestInfo] uses-permission android:name="android.permission.VIBRATE"
    [parse.ManifestInfo] uses-permission android:name="android.permission.WAKE_LOCK"
    [parse.ManifestInfo] uses-permission android:name="android.permission.GET_ACCOUNTS"
    [parse.ManifestInfo] uses-permission android:name="com.google.android.c2dm.permission.RECEIVE"
    [parse.ManifestInfo] permission android:name="com.garnish.app.permission.C2D_MESSAGE" android:protectionLevel="signature"
    [parse.ManifestInfo] uses-permission android:name="com.garnish.app.permission.C2D_MESSAGE"

    All the above permission attributes are in the manifest.

  • Hi all,

    We've just launched Parse 1.5.1 that should fixed the problem with Push Notification on Xamarin iOS and Xamarin Android. Tested that it worked on both Xamarin 4.x and 5.x, foreground or background.

    Let me know if you still encounter any problem.

  • crossplatformercrossplatformer CAMember

    @ListiarsoWastuargo

    Great, thanks!

    I will check it out and let you know if any problems should occur, thanks again : )

  • GarnishGarnish USMember
    edited June 2015

    Updated my component, cleaned the solution, removed the existing package, removed all the mono runtimes, restarted Xamarin, no change, same errors:

    [parse.ManifestInfo] Cannot use GCM for push because AndroidManifest.xml is missing:
    [parse.ManifestInfo] uses-permission android:name="android.permission.INTERNET"
    [parse.ManifestInfo] uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"
    [parse.ManifestInfo] uses-permission android:name="android.permission.VIBRATE"
    [parse.ManifestInfo] uses-permission android:name="android.permission.WAKE_LOCK"
    [parse.ManifestInfo] uses-permission android:name="android.permission.GET_ACCOUNTS"
    [parse.ManifestInfo] uses-permission android:name="com.google.android.c2dm.permission.RECEIVE"
    [parse.ManifestInfo] permission android:name="com.garnish.app.permission.C2D_MESSAGE" android:protectionLevel="signature"
    [parse.ManifestInfo] uses-permission android:name="com.garnish.app.permission.C2D_MESSAGE"

    I still get a device under Installations but no device token.

  • BugMaNBugMaN USMember

    Same problems also for me (I just update Parse to 1.5.1) and the error is the same:

    [parse.ManifestInfo] Cannot use GCM for push because AndroidManifest.xml is missing:
    [parse.ManifestInfo] .
    [parse.ManifestInfo]
    [parse.ManifestInfo]
    [parse.ManifestInfo]
    [parse.ManifestInfo]
    [parse.ManifestInfo]
    [parse.ManifestInfo]
    [parse.ManifestInfo]
    [parse.ManifestInfo]

  • LuukvandeWielLuukvandeWiel NLMember

    I also updated to 1.5.1 but noticed that there's no Xamarin.Android.Support.v4.dll included.

  • JaredLangguth.0107JaredLangguth.0107 GBMember
    edited June 2015

    Hi,

    I've also updated to 1.51. In Release config, I can't get the device to receive a push, but I don't get any parse.ManigetInfo errors anymore. In DEBUG config I do get the below error. I also see the same errors/behaviour in the parsexamarinpushsample project.

    Cannot use GCM for push because AndroidManifest.xml is missing:
    [parse.ManifestInfo] receiver android:name="parse.ParsePushBroadcastReceiver" .
    [parse.ManifestInfo] android:permission="com.google.android.c2dm.permission.SEND"
    [parse.ManifestInfo] intent-filter
    [parse.ManifestInfo] action android:name="com.google.android.c2dm.intent.RECEIVE"
    [parse.ManifestInfo] action android:name="com.google.android.c2dm.intent.REGISTRATION"
    [parse.ManifestInfo] category android:name="com.parse.parsexamarinpushsample"
    [parse.ManifestInfo] intent-filter
    [parse.ManifestInfo] receiver

  • GarnishGarnish USMember

    FYI, if you post those logs, kill the "<" and ">", it removes the content inside.

  • Nicolas77Nicolas77 CHMember ✭✭

    @Jared : same thing here. I don't have the exception anymore with 1.5.1 and I can register my devices. But I don't receive any push message.... I am on Xamarin.Android 4.x (but tried also 5.x). Do we need to sign the build with a prod certificate?

    @ListiarsoWastuargo : can you post a zip file with your working sample? Maybe the tutorial on parse.com telling what we need to put in the AndroidManifest.xml is wrong. If I look at the Android / Java tutorial there is more to put in the manifest file.

  • EdwardLowEdwardLow USMember

    @ListiarsoWastuargo Not working at all. I got the same error at application output:[parse.ManifestInfo] Cannot use GCM for push because AndroidManifest.xml is missing:
    [parse.ManifestInfo] receiver android:name="parse.ParsePushBroadcastReceiver"
    [parse.ManifestInfo] android:permission="com.google.android.c2dm.permission.SEND"
    [parse.ManifestInfo] intent-filter
    [parse.ManifestInfo] action android:name="com.google.android.c2dm.intent.RECEIVE"
    [parse.ManifestInfo] action android:name="com.google.android.c2dm.intent.REGISTRATION"
    [parse.ManifestInfo] category android:name="com.optisage.bniwinners"
    [parse.ManifestInfo] intent-filter
    [parse.ManifestInfo] receiver

  • ListiarsoWastuargoListiarsoWastuargo USMember
    edited June 2015

    Hi all,

    This is the project that I used and tested. https://www.dropbox.com/s/ci5i79dalybr47w/ParseXamarinPushSample.zip?dl=0 Hope it helps. I also added my own project there so it should totally work just by building it and deploying it directly to device.

  • @ListiarsoWastuargo thanks for making that available. I see your sample has a later version of the Parse.Android.dll (1.5.2). I ran your sample using the Release build on my Nexus 5 (api 22), and using my access keys, and successfully received messages. I then added the 1.5.2 dll to my project and my app now works as well.

    With 1.5.1 the GCM registration doesn't happen. With 1.5.2 it does.

    Is the 1.5.2 Parse.Android.dll ready for production?

    @Nicolas77 - You don't appear to need a prod cert...I was wondering the same thing. Note: I can only get it working using a Release build on a physical device.

  • Nicolas77Nicolas77 CHMember ✭✭

    @ListiarsoWastuargo : Thanks for the sample that works on the first try!

    @JaredLangguth : Same thing here. I successfully make it working in my own project with the dll included in the sample project. Thanks for the tip!

  • BugMaNBugMaN USMember

    @ListiarsoWastuargo

    Same for me with Parse 1.5.2 now its work.

    Is possible to have a date when version 1.5.2 go in production as a Xamarin Components?

    Thanks

  • Glad it works! The 1.5.2 has been submitted to Xamarin component store since yesterday. We'll just have to wait for their approval. Meanwhile, it's already available on NuGet https://www.nuget.org/packages/parse.

  • GarnishGarnish USMember

    Also confirming adding the 1.5.2 component worked for me. It didn't work at first though, I had to make a new solution and import all my work. I also had to play around with my manifest, for some reason I couldn't get Google Maps and Push to work together, one or the other worked at any given time. I finally took out all the lines related to GMaps so it was only Push and added them one at a time until it worked. My end file was no different from my copy/paste so I'm not sure what fixed it but I seem to be running fine now.

  • LuukvandeWielLuukvandeWiel NLMember
    edited June 2015

    For some reason the project @ListiarsoWastuargo provided worked here the day before yesterday, but today it immediately closes after running. Does anyone know what could cause this?
    I also tried to add Parse via NuGet to my own projects, but I get a runtime error everytime I run it in that way :(

  • EdwardLowEdwardLow USMember

    @ListiarsoWastuargo successfully register the device. But, when test the push notification, only can receive the notification sound, but no notification is display the the notification area. Any idea? TQ.

  • EdwardLowEdwardLow USMember

    @ListiarsoWastuargo it is working now after setting the android:name="bni" and android:label="BNI" attributes of the Application element in the androidManifest file. TQ.

  • crossplatformercrossplatformer CAMember

    @ListiarsoWastuargo
    Version 1.5.2 seems to work in the sense that it is able to receive and show the push notifications. Thanks for that! :)

    However, it took some time to figure out the "right configuration" in terms of the AndroidManifest and the Application class.
    Still not sure if what I have is 100% correct, but at least the notifications come through now.
    Following the documentation, it would not work, so what I have at the moment is gathered from comments here and there...

    I think Parse needs to check and clean up the documentation ASAP...

    I still have one problem: when sending JSON, the "uri" -field seems not to work anymore.
    For example, sending a JSON like...

    {
        "title":"An example title", 
        "alert":"An example message", 
        "uri":"http://www.xamarin.com"
    } 
    

    ...would before launch the browser with the given URL - but now it just takes me into my app.

    Also, just a side note: apparently, the push notification icon does not need to be mentioned in the AndroidManifest anymore, it seems to use the app icon automatically ? What if a different icon would like to be used ?

  • @LuukvandeWiel what kind of RuntimeError did you get?

    @crossplatformer if you take a look at the docs inside Parse.Android.dll (and mentioned in https://parse.com/apps/quickstart#parse_push/android/xamarin/existing) the handler provided in DefaultParsePushNotificationReceivedHandler is just a helper method to help you get started with app icon push notification. You can add another handler to ParsePush.ParsePushNotificationReceived to suit your requirement (such as displaying other icon/doing different action other than going to default activity).

    That said, I agree that we'll need to fix the documentation. And we'd love to get your help! You can send a PR to https://github.com/ParsePlatform/Docs if you feel that any part of our docs is lacking/not up to date.

  • crossplatformercrossplatformer CAMember

    @ListiarsoWastuargo

    Thanks for clarifying :)
    I was just wondering, because it was automatic before, i.e. when sending JSON with a proper URI, such as "http", "tel", "sms", it (the default handler) would automatically act upon those.

    But cool, this is no problem and gives me more freedom (custom icons, different JSON etc.) by providing my own handler, thanks.

    I will go through the docs and send a pull request / push fix, I think (at least in my case) the ParseClient.Initialize() is not enough - I had to subscribe to "all channels" and provide the default handler to make the push notifications to work.

  • LuukvandeWielLuukvandeWiel NLMember

    @ListiarsoWastuargo When I try to build your sample project on Debug, I get the following error: Deployment failed because of an internal error: Failure [INSTALL_FAILED_UPDATE_INCOMPATIBLE]. When I try it on release, the app starts up for half a second and closes afterwards.

    When I try to run the 1.5.1 example from the Parse site after updating Parse in the project, I get the following exception:

    Java.Lang.RuntimeException: java.lang.reflect.InvocationTargetException
    at --- End of managed exception stack trace ---
    at java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
    at at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
    at Caused by: java.lang.reflect.InvocationTargetException
    at at java.lang.reflect.Method.invoke(Native Method)
    at at java.lang.reflect.Method.invoke(Method.java:372)
    at at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
    at ... 1 more
    at Caused by: md52ce486a14f4bcd95899665e9d932190b.JavaProxyThrowable: System.TypeLoadException: Could not load type 'Android.OS.BaseBundle' from assembly 'Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065'.
    at at Parse.PlatformHooks.Initialize ()
    at at Parse.ParseClient.Initialize (string,string)
    at UMTCApp.App..ctor () [0x00008] in ...\App.cs:10
    at UMTCApp.MainActivity.OnCreate (Android.OS.Bundle) [0x0004b] in ...\MainActivity.cs:40
    at Android.App.Activity.n_OnCreate_Landroid_os_Bundle_ (intptr,intptr,intptr) [0x00011] in /Users/builder/data/lanes/1502/4ab8d98a/source/monodroid/src/Mono.Android/platforms/android-19/src/generated/Android.App.Activity.cs:2475
    at at (wrapper dynamic-method) object.dde690b6-fc19-4234-91d2-973b873c7219 (intptr,intptr,intptr)
    at at md50b5a9cbdf799836e962c32a4a9e2199a.MainActivity.n_onCreate(Native Method)
    at at md50b5a9cbdf799836e962c32a4a9e2199a.MainActivity.onCreate(MainActivity.java:28)
    at at android.app.Activity.performCreate(Activity.java:5990)
    at at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
    at at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2278)
    at at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
    at at android.app.ActivityThread.access$800(ActivityThread.java:151)
    at at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
    at at android.os.Handler.dispatchMessage(Handler.java:102)
    at at android.os.Looper.loop(Looper.java:135)
    at at android.app.ActivityThread.main(ActivityThread.java:5254)
    at ... 4 more

  • crossplatformercrossplatformer CAMember

    @LuukvandeWiel

    I think the first error means the application is already installed and was not uninstalled, for some reason or other - try to manually remove the app from device, restart VS or XS, whatever IDE you are using, etc.

    This one:

    System.TypeLoadException: Could not load type 'Android.OS.BaseBundle' from assembly 'Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065'.

    Is most probably just some version problem - check that your references are OK and correct versions.

  • sateeshtaddisateeshtaddi INMember

    I follow all the steps same like sample project .
    But when i run my app i Got exception
    "Could not load type 'Android.OS.BaseBundle' from assembly 'Parse.Android'."

  • sateeshtaddisateeshtaddi INMember

    I am facing same problem .

  • LuukvandeWielLuukvandeWiel NLMember
    edited July 2015

    When using Parse 1.5.3 (and following the Quick Start on the Parse website) now I get other issues.

    The error message is the following:

    Installing application on device
    Deployment failed because of an internal error: Unexpected install output: pkg: /data/local/tmp/com.umtc.app-Signed.apk
    Failure [INSTALL_PARSE_FAILED_MANIFEST_MALFORMED]

    Deployment failed. Internal error.

    I suppose this has something to do with my AndroidManifest.xml being corrupted. I googled a bit, and found that my package name can't start with caps. It doesn't, and has never done, however. This is my AndroidManifest.xml file :

    http://pastebin.com/bk5t82GU

    It could be just a little problem or something I did wrong. Could someone help me please?

  • Sateesh_taddiSateesh_taddi USMember

    TRY THIS ..
    I changed my target framework Android 4.4(kitkat)n to android 5.0(lollipop) .Now its working fine foe me .

Sign In or Register to comment.