Embeddinator-4000 icon indicating copy to clipboard operation
Embeddinator-4000 copied to clipboard

Constructor with parameters result into errors during Android Embeddination.

Open emysa341 opened this issue 6 years ago • 1 comments

Steps to Reproduce

  1. Pass a parameter in a class constructor with export attribute, class inherits from Java.Lang.Object with register attribute.

Expected Behavior

Embeddination shouldn't fail.

Actual Behavior

Embeddination fails.

Environment

MacOs, Latest Visual Studio.

using System;
using Java.Interop;
using Android.Runtime;

namespace Testembedination
{
    [Register("testembedination.TEmbeded")]
    public class TEmbeded : Java.Lang.Object
    {
        [Export("tEmbeded")]
        public TEmbeded(int k)
        {
            
        }
    }
}

Build Logs

TEmbeded.java:20: error: constructor Object in class Object cannot be applied to given types;
		super (p0);
		^
  required: no arguments
  found: int
  reason: actual and formal argument lists differ in length
Note: ../../../../Native/Android/EmbedinatedFramework/src/testembedination/TEmbeded.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
1 error Failed to compile generated code.

Example Project (If Possible)

TestEmbedination.zip TestComand.bat.zip

emysa341 avatar Apr 24 '18 13:04 emysa341

Hi everyone!

I had the same issue (was incorrect register attribute), after I fixed it, the library was successfully compiled, sample:

https://github.com/wcoder/xamarin-embedding-starter-kit/blob/master/dotnet/DotNet.AndroidLibrary/XActivity.cs

wcoder avatar Oct 30 '18 20:10 wcoder