Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Question
Thursday, January 23, 2014 12:50 AM
I've created a java binding project for iSpeech. Had to a couple of things (not relevant I don't think) and can build it fine. But when I go to run it, I get an error in a generated java file:
SpeechSynthesis_StateChangedListenerImplementor.java(30,30): Error: org.ispeech.SpeechSynthesis.StateChangedListener is not public in org.ispeech.SpeechSynthesis; cannot be accessed from outside package org.ispeech.SpeechSynthesis.StateChangedListener
This java file is found at \obj\Debug\android\src\mono\org\ispeech\SpeechSynthesis_StateChangedListenerImplementor.java
Here's the java snippet from that file:
public class SpeechSynthesis_StateChangedListenerImplementor
extends java.lang.Object
implements
mono.android.IGCUserPeer,
org.ispeech.SpeechSynthesis.StateChangedListener
{
Here's the (relevant portions, I think...) generated C#:
public partial class SpeechSynthesis : global::Java.Lang.Object, global::Org.Ispeech.ISynthesizer
{
[Register ("org/ispeech/SpeechSynthesis$StateChangedListener")]
public abstract class StateChangedListener
{
internal StateChangedListener ()
{
}
// Metadata.xml XPath field reference: path="/api/package[@name='org.ispeech']/interface[@name='SpeechSynthesis.StateChangedListener']/field[@name='CANCELED']"
[Register ("CANCELED")]
public const int Canceled = (int) 5;
// Metadata.xml XPath field reference: path="/api/package[@name='org.ispeech']/interface[@name='SpeechSynthesis.StateChangedListener']/field[@name='CLOSED']"
[Register ("CLOSED")]
public const int Closed = (int) 1;
}
}
I've tried making it public by adding this to my Metadata.xml:
<attr path="/api/package[@name='org.ispeech']/interface[@name='SpeechSynthesis.StateChangedListener']" name="visibility">public</attr>
And also removing it (although I do need it eventually) with this:
<remove-node path="/api/package[@name='org.ispeech']/interface[@name='SpeechSynthesis.StateChangedListener']"/>
But no dice... any ideas?
All replies (16)
Thursday, January 23, 2014 12:53 AM
"Had to a couple of things" == Had to <remove-node>
Thursday, January 30, 2014 2:23 PM
I'm having the same problem with a different java library. Like you, I've tried everything I could think of to remove, rename, change access but with no results. I've sent it to Support and I am hopefull I will get a response. If so, I will post the solution here.
Thursday, January 30, 2014 3:50 PM
I take that back - I was creating Java Bindings for 3 .jars, one of which shouldn't have had bindings created. The other two work OK, so I guess I won't be any help after all.
Friday, February 7, 2014 11:02 PM
hey @akevan, any luck with this error? I'm having the same issue, but with a different class.
Error: android.support.v4.view.ViewPager.OnAdapterChangeListener is not public in android.support.v4.view.ViewPager; cannot be accessed from outside package
android.support.v4.view.ViewPager.OnAdapterChangeListener
I tried changing the visibility by adding
<attr path="/api/package[@name='android.support.v4.view']/class[@name='ViewPager.OnAdapterChangeListener']" name="visibility">public</attr>
to Metadata.xml to no avail.
The section in api.xml that declares ViewPager.OnAdapterChangeListener
looks like this:
<interface abstract="true" deprecated="not deprecated" final="false" name="ViewPager.OnAdapterChangeListener" static="true" visibility="">
The java file is found at obj/Debug/android/src/mono/android/support/v4/view/ViewPager_OnAdapterChangeListenerImplementor.java
the snippet that causes the error is:
public class ViewPager_OnAdapterChangeListenerImplementor
extends java.lang.Object
implements
mono.android.IGCUserPeer,
android.support.v4.view.ViewPager.OnAdapterChangeListener
{
...
}
and the C# converted code looks like this:
// Metadata.xml XPath interface reference: path="/api/package[@name='android.support.v4.view']/interface[@name='ViewPager.OnAdapterChangeListener']"
[Register ("android/support/v4/view/ViewPager$OnAdapterChangeListener", "", "Android.Support.V4.View.ViewPager/IOnAdapterChangeListenerInvoker")]
public partial interface IOnAdapterChangeListener : IJavaObject {
// Metadata.xml XPath method reference: path="/api/package[@name='android.support.v4.view']/interface[@name='ViewPager.OnAdapterChangeListener']/method[@name='onAdapterChanged' and count(parameter)=2 and parameter[1][@type='android.support.v4.view.PagerAdapter'] and parameter[2][@type='android.support.v4.view.PagerAdapter']]"
[Register ("onAdapterChanged", "(Landroid/support/v4/view/PagerAdapter;Landroid/support/v4/view/PagerAdapter;)V", "GetOnAdapterChanged_Landroid_support_v4_view_PagerAdapter_Landroid_support_v4_view_PagerAdapter_Handler:Android.Support.V4.View.ViewPager/IOnAdapterChangeListenerInvoker, ZDK.Android.MiSocial")]
void OnAdapterChanged (global::Android.Support.V4.View.PagerAdapter p0, global::Android.Support.V4.View.PagerAdapter p1);
}
Ideas anyone?
Friday, February 7, 2014 11:33 PM
I've noticed that the interface that's causing the error doesn't explicitly declare its visibility on the original java file: interface OnAdapterChangeListener
. Where as another interface declared on the same source file explicitly declares its visibility: public interface OnPageChangeListener
.
And the only place I could find where these interfaces are use is in android-sdk-mac_x86/extras/android/support/v4/src/java/android/support/v4/view/PagerTitleStrip.java
snippet:
private class PageListener extends DataSetObserver implements ViewPager.OnPageChangeListener,
ViewPager.OnAdapterChangeListener
Am I right to think that this issue is related to the interface's visibility?
Monday, February 10, 2014 11:27 PM
My error went away after I removed the reference to android-support-v4.jar
I had in my test project.
The error in particular was pointing out the fact that ViewPager.OnAdapterChangeListener
was declared in android.support.v4.view
package but was being used in mono.android.support.v4.view
. Hence the error cannot be accessed from outside package
.
Tuesday, August 19, 2014 4:32 PM
Am I right to think that this issue is related to the interface's visibility?
Yes.
In C#, internal
types cannot be accessed outside of the declaring assembly.
Java has the concept of "package-private" types which similarly cannot be accessed from outside of the declaring package. android.support.v4.view.ViewPager.OnAdapterChangeListener
is package-private, as is org.ispeech.SpeechSynthesis.StateChangedListener
.
Thou shalt not bind package-private
types. Attempting to do so will result in the javac
errors mentioned in this thread.
In short, don't do this:
<attr path="/api/package[@name='android.support.v4.view']/class[@name='ViewPager.OnAdapterChangeListener']" name="visibility">public</attr>
Like you, I've tried everything I could think of to remove, rename, change access but with no results.
For sanity, you should remove the bin
and obj
directories whenever changing Metadata.xml, as if you add/change ` elements/alter visibility/etc. the set of generated files will change, and types that aren't generated may not be cleaned up.
Tuesday, October 14, 2014 10:27 PM
Hi Jonathan, I'm facing a similar issue binding the Esri ArcGIS SDK. What's the best approach to handle the member 'cannot be accessed from outside package' error?
Thursday, October 16, 2014 1:13 AM
bump! Same here, last hint isn't quite helpful as doesn't help at all..
Friday, November 28, 2014 7:02 PM
We are trying to use parse for sending push notifications for the mobile app that we are building. I have downloaded the parse Android SDK jar and have successfully created a java bindings project. However when I refer the java binding project in my Android Application project and the try to build the same, I am getting below error
Error: com.parse.PushService.LifecycleListener is not public in com.parse.PushService; cannot be accessed from outside package com.parse.PushService.LifecycleListener
The Jars that I have included in my binding projects are
bolts-android-1.1.3.jar Parse-1.7.1.jar
My metadata.xml file looks as below
<attr path="/api/package[@name='com.parse']/class[@name='ParseCallback']" name="visibility">public</attr><attr path="/api/package[@name='com.parse.codec.binary']/class[@name='Base32']/method[@name='isInAlphabet']" name="visibility">protected</attr>
<attr path="/api/package[@name='com.parse']/class[@name='ParseACL.UserResolutionListener']/method[@name='done']/parameter[@name='p0']" name="type">java.lang.Object</attr>
<attr path="/api/package[@name='com.parse.codec.net']/class[@name='RFC1522Codec']" name="visibility">public</attr>
<attr path="/api/package[@name='com.parse']/class[@name='RFC1522Codec']" name="visibility">public</attr>
<attr path="/api/package[@name='com.parse']/class[@name='PushService.LifecycleListener']" name="visibility">public</attr>
<remove-node path="/api/package[@name='com.parse.signpost.basic']/class[@name='HttpURLConnectionRequestAdapter']"/>
<remove-node path="/api/package[@name='com.parse.signpost.http']/class[@name='HttpParameters']"/>
Please let me know how to resolve this
Friday, December 5, 2014 10:11 AM
@ShashankEL did you find solution for your issue? I have exactly the same problem with you
Friday, December 5, 2014 10:36 AM
Hi,
Added the below line the my meta xml fixed the issue for me
<remove-node path="/api/package[@name='com.parse']/interface[@name='PushService.LifecycleListener']" />
Friday, December 26, 2014 10:58 AM
Thank you @ShashankEL but we found the app crashes at runtime with the parse default receiver. So we have to use a custom receiver to overcome it. And there is one important note about the namespace of custom receiver class: use the android app's package name as the namespace, otherwise it won't be found at runtime. Some helpful references:
Parse Android doc: https://parse.com/tutorials/android-push-notifications
Custom Receiver reference: http://stackoverflow.com/questions/26154855/exception-when-opening-parse-push-notification
Java package name V.S. C# namespace: http://www.javacamp.org/javavscsharp/namespace.html
Thursday, April 9, 2015 5:41 AM
Ok, I have a similar situation that I am not sure how to deal with:
There are 2 java interfaces in the .jar. They are as declared as:
abstract interface AckReceiverListener abstract interface MessageSenderListener
Since they don't declare public, I assume they are package-private, which is fine since I don't need access to them directly.
so I added: <remove-node path="/api/package[@name='com.customerpackage.impl']/interface[@name='MessageSenderListener']" /> <remove-node path="/api/package[@name='com.customerpackage.impl']/interface[@name='AckReceiverListener']" />
I then get the following warnings: 1>BINDINGSGENERATOR : warning BG8C00: For type Com.CustomerPackage.Impl.EPointsAckDecoder, base interface com.customerpackage.impl.AckReceiver.AckDecoder is invalid. 1>BINDINGSGENERATOR : warning BG8C00: For type Com.CustomerPackage.Impl.Impl, base interface com.customerpackage.impl.AckReceiverListener does not exist. 1>BINDINGSGENERATOR : warning BG8C00: For type Com.CustomerPackage.Impl.Impl, base interface com.customerpackage.impl.MessageSenderListener does not exist. 1>BINDINGSGENERATOR : warning BG8C00: For type Com.CustomerPackage.EPointsAckDecoder, base interface com.customerpackage.impl.AckReceiver.AckDecoder is invalid. 1>BINDINGSGENERATOR : warning BG8C00: For type Com.CustomerPackage.Impl.Impl, base interface com.customerpackage.impl.AckReceiverListener does not exist. 1>BINDINGSGENERATOR : warning BG8C00: For type Com.CustomerPackage.Impl.Impl, base interface com.customerpackage.impl.MessageSenderListener does not exist.
And when I run, I get a Null Reference exception: 4-08 22:30:34.620 E/mono (10601): Unhandled Exception: 04-08 22:30:34.620 E/mono (10601): Java.Lang.NullPointerException: Exception of type 'Java.Lang.NullPointerException' was thrown. 04-08 22:30:34.620 E/mono (10601): at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () <IL 0x00011, 0x00068> 04-08 22:30:34.620 E/mono (10601): at Android.Runtime.JNIEnv.CallBooleanMethod (intptr,intptr,Android.Runtime.JValue[]) [0x00064] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.21-series/9e05e39f/source/monodroid/src/Mono.Android/src/Runtime/JNIEnv.g.cs:229 04-08 22:30:34.620 E/mono (10601): at Com.CustomerPackage.Api.IGradInvoker.Start (int,string) [0x0003a] in e:\AndroidPTest\Bindings\obj\Debug\generated\src\Com.CustomerPackage.Api.IGrad.cs:302 04-08 22:30:34.620 E/mono (10601): at AndroidPTest.MainActivity.OnResume () [0x00016] in e:\AndroidPTest\AndroidPTest\MainActivity.cs:38 04-08 22:30:34.620 E/mono (10601): at Android.App.Activity.n_OnResume (intptr,intptr) [0x00009] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.21-series/9e05e39f/source/monodroid/src/Mono.Android/platforms/android-14/src/generated/Android.App.Activity.cs:3095 04-08 22:30:34.620 E/mono (10601): at (wrapper dynamic-method) object.049e88cb-a63d-4aa5-8666-e77459d7ccf1 (intptr,intptr) <IL 0x00011, 0x0003b> 04-08 22:30:34.620 E/mono (10601): 04-08 22:30:34.620 E/mono (10601): End of managed exception stack trace 04-08 22:30:34.620 E/mono (10601): java.lang.NullPointerException 04-08 22:30:34.620 E/mono (10601): at com.customerpackage.impl.AckReceiver.receive(AckReceiver.java:117) 04-08 22:30:34.620 E/mono (10601): at com.customerpackage.impl.AckReceiver.receiveBarcodeAck(AckReceiver.java:106) 04-08 22:30:34.620 E/mono (10601): at com.customerpackage.impl.Impl.startBeaming(Impl.java:158) 04-08 22:30:34.620 E/mono (10601): at androidptest.MainActivity.n_onResume(Native Method) 04-08 22:30:34.620 E/mono (10601): at androidptest.MainActivity.onResume(MainActivity.java:40) 04-08 22:30:34.620 E/mono (10601): at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1185) 04-08 22:30:34.620 E/mono (10601): at android.app.Activity.performResume(Activity.java:5318) 04-08 22:30:34.620 E/mono (10601): at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2732) 04-08 22:30:34.620 E/mono (10601): at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2771) 04-08 22:30:34.620 E/mono (10601): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2235) 04-08 22:30:34.620 E/mono (10601): at android.app.ActivityThread.access$600(ActivityThread.java:141) 04-08 22:30:34.620 E/mono (10601): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234) 04-08 22:30:34.620 E/mono (10601): at android.os.Handler.dispatchMessage(Handler.java:99) 04-08 22:30:34.620 E/mono (10601): at android.os.Looper.loop(Looper.java:137) 04-08 22:30:34.620 E/mono (10601): at android.app.ActivityThread.main(ActivityThread.java:5048) 04-08 22:30:34.620 E/mono (10601): at java.lang.reflect.Method.invokeNative(Native Method) 04-08 22:30:34.620 E/mono (10601): at java.lang.reflect.Method.invoke(Method.java:511) 04-08 22:30:34.620 E/mono (10601): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:908) 04-08 22:30:34.620 E/mono (10601): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:675) 04-08 22:30:34.620 E/mono (10601): at dalvik.system.NativeStart.main(Native Method)
It looks like I can't remove the nodes because they are implemented by AckReceiver.AckDecoder.
Anybody know what to do next?
Friday, August 14, 2015 10:20 AM
Hi everyone, I am facing this issue - member interface declared as 'PRIVATE interface AccessTokenListener' in java. After binding the jar file, C# throws build error - AccessTokenListener is private. Can't access.
public class PayPalCard_AccessTokenListenerImplementor
extends java.lang.Object
implements
mono.android.IGCUserPeer,
ly.kite.payment.PayPalCard.AccessTokenListener
In some other threads people mentioned to change the java source code. For once I can change the source as I have the code. But I am worried about other JAR files which my source code refers. If the JARs have internal member PRIVATE interfaces how can I change them?
Thanks, Venkat V R
Tuesday, September 12, 2017 8:37 AM
For me, deleting the obj and the bin folder in the App (! not the binding library) project resolved the issue.