TXW.create() different behavior on jdk and android? - android

I've created webservice on desktop (jdk, working good) and i'm trying to move it to android (make it running on android device). But i'm having some issues and after debugging for few days i've found different behaviour of the next code:
Schema schema = TXW.create(Schema.class,ResultFactory.createSerializer(result));
Passed result object is almost empty before invocation and has only systemId property. On JDK created schema has not null nsUri property, but on Android it's just empty!
JDK:
Android:
What's the reason and how can i fix it?
It makes schema invalid and it throws exception in cxf later:
javax.xml.ws.WebServiceException: java.lang.RuntimeException: Invalid schema document passed to AbstractDataBinding.addSchemaDocument, not in W3C schema namespace: schema
Update1:
I'v found TXW code pkg.getAnnotation(XmlNamespace.class) return null in android but instance value in jdk:
if(nsUri.equals("##default")) {
Package pkg = c.getPackage();
if(pkg!=null) {
XmlNamespace xn = pkg.getAnnotation(XmlNamespace.class); // xn = null in android
if(xn!=null)
nsUri = xn.value();
}
}
if(nsUri.equals("##default"))
nsUri = "";
return new QName(nsUri,localName);

The reason was in TXW.java:
Package pkg = c.getPackage();
XmlNamespace xn = pkg.getAnnotation(XmlNamespace.class);
if(xn!=null) // always null in android as it does not support package annotations
nsUri = xn.value();
So i had to hack it - create public static variable and set it before:
public static java.lang.String XmlNamespaceAnnotationValue = null;
...
Package pkg = c.getPackage();
if(pkg!=null) {
if (XmlNamespaceAnnotationValue != null) {
nsUri = XmlNamespaceAnnotationValue;
} else {
XmlNamespace xn = pkg.getAnnotation(XmlNamespace.class);
if(xn!=null)
nsUri = xn.value();
}
}
Before usage:
TXW.XmlNamespaceAnnotationValue = "http://www.w3.org/2001/XMLSchema";

Related

The setter 'featureFlag' isn't defined for the type 'JitsiMeetingOptions'

I am using the jitsi meet package for flutter and I have typed the code as per the documentation https://pub.dev/packages/jitsi_meet of the package, but still, there is some error in the app. The error says
The setter 'featureFlag' isn't defined for the type 'JitsiMeetingOptions'.
Try importing the library that defines 'featureFlag', correcting the name to the name of an existing setter, or defining a setter or field named 'featureFlag'.
And this is the joinMeeting function
joinMeeting() async {
print(code);
try {
FeatureFlag featureFlag = FeatureFlag();
featureFlag.welcomePageEnabled = false;
featureFlag.resolution = FeatureFlagVideoResolution.MD_RESOLUTION;
featureFlag.addPeopleEnabled = false;
featureFlag.calendarEnabled = false;
featureFlag.callIntegrationEnabled = false;
featureFlag.inviteEnabled = false;
featureFlag.kickOutEnabled = false;
featureFlag.liveStreamingEnabled = false;
featureFlag.meetingPasswordEnabled = false;
featureFlag.recordingEnabled = false;
featureFlag.serverURLChangeEnabled = false;
featureFlag.tileViewEnabled = false;
featureFlag.videoShareButtonEnabled = false;
if (Platform.isIOS) {
featureFlag.pipEnabled = false;
}
var options = JitsiMeetingOptions()
..room = code // Required, spaces will be trimmed
..userDisplayName = username == null ? 'Unidentified' : username
..audioMuted = false
..videoMuted = false
..featureFlag = featureFlag;
await JitsiMeet.joinMeeting(options);
} catch (err) {
print(err);
}
}
The error is in the line ..featureFlag = featureFlag; which says
The setter 'featureFlag' isn't defined for the type 'JitsiMeetingOptions'.
Try importing the library that defines 'featureFlag', correcting the name to the name of an existing setter, or defining a setter or field named 'featureFlag'.
I have typed everything as per the documentation https://pub.dev/packages/jitsi_meet of the package but still the code does not seems to work. Any help on how to fix this error and make the code working would be of great help.
The featureflag has been changed in new version of jitsi meet plugin 3.0.0, but the changed code hasn't been mentioned in the main page of pub dev I.e https://pub.dev/packages/jitsi_meet. So please check out the example page where new changed syntax has been mentioned i.e https://pub.dev/packages/jitsi_meet/example .
For example your code should look like this, find out which syntax needs to be changed according to new version:-
_joinMeeting() async {
String serverUrl =
serverText.text?.trim()?.isEmpty ?? "" ? null : serverText.text;
// Enable or disable any feature flag here
// If feature flag are not provided, default values will be used
// Full list of feature flags (and defaults) available in the README
Map<FeatureFlagEnum, bool> featureFlags = {
FeatureFlagEnum.WELCOME_PAGE_ENABLED: false,
};
if (!kIsWeb) {
// Here is an example, disabling features for each platform
if (Platform.isAndroid) {
// Disable ConnectionService usage on Android to avoid issues (see README)
featureFlags[FeatureFlagEnum.CALL_INTEGRATION_ENABLED] = false;
} else if (Platform.isIOS) {
// Disable PIP on iOS as it looks weird
featureFlags[FeatureFlagEnum.PIP_ENABLED] = false;
}
}
// Define meetings options here
var options = JitsiMeetingOptions()
..room = roomText.text
..serverURL = serverUrl
..subject = subjectText.text
..userDisplayName = nameText.text
..userEmail = emailText.text
..iosAppBarRGBAColor = iosAppBarRGBAColor.text
..audioOnly = isAudioOnly
..audioMuted = isAudioMuted
..videoMuted = isVideoMuted
..featureFlags.addAll(featureFlags)
..webOptions = {
"roomName": roomText.text,
"width": "100%",
"height": "100%",
"enableWelcomePage": false,
"chromeExtensionBanner": null,
"userInfo": {"displayName": nameText.text}
};

Config Transformations From Visual Studio (Xamarin)

I'm trying to implement a pre-build transformation to my Android.Manifest file within a Xamarin.Android project within Visual Studio - The purpose is simply to change the bundleID of my app depending on whether I build a debug or release version.
I've added a new .netFramework project to my solution, referenced Microsoft.Build and then added a new class named BuildTask and referenced the DLL in my Xamarin.Android project.
I then intend to add a UsingTask to my Xamarin.Android project's .csproj file at the very bottom, just above the closing tag - I presume this is correct.
Before I add the UsingTask I wanted to make sure the Xamarin.Android project builds, but unfortunately I'm getting errors about a missing reference in my Xamarin.Android project saying I'm missing a reference to System.Collections, but the error disappears the second I remove the reference to my new BuildTask.DLL
I've never done this before so I may be heading down the rabbit hole... If anyone's got any advise, it'd be greatly appreciated.
Here's my BuildTask class for reference:
using System;
using Microsoft.Build.Utilities;
using Microsoft.Build.Framework;
using System.Xml;
public class BuildTask : Task
{
private const string AndroidNamespace = "http://schemas.android.com/apk/res/android";
[Required]
public string PackageName { get; set; }
[Required]
public string ApplicationLabel { get; set; }
[Required]
public string ManifestFilename { get; set; }
public string Debuggable { get; set; }
public override bool Execute()
{
var xml = new XmlDocument();
xml.Load(ManifestFilename);
XmlNamespaceManager nsmgr = new XmlNamespaceManager(xml.NameTable);
nsmgr.AddNamespace("android", AndroidNamespace);
if (xml.DocumentElement != null)
{
xml.DocumentElement.SetAttribute("package", PackageName);
var appNode = xml.DocumentElement.SelectSingleNode("/manifest/application", nsmgr);
if (appNode != null && appNode.Attributes != null)
{
var labelAttribute = appNode.Attributes["label", AndroidNamespace];
if (labelAttribute != null)
{
labelAttribute.Value = ApplicationLabel;
}
var debuggableAttribute = appNode.Attributes["debuggable", AndroidNamespace];
if (debuggableAttribute != null)
{
debuggableAttribute.Value = Debuggable;
}
xml.Save(ManifestFilename);
return true;
}
}
return false;
}
}
Thanks.
That because you are referencing full .NET Framework to Xamarin.Android project. This full .NET framework is incompatible with the Xamarin.Android. You should use one of the following:
Create an Android Library Project.
Create a Portable Class Library Project.
Create a Shared Project.

Invalid argument: NodeDef mentions attr 'Tshape' not in Op

I am getting the error Invalid argument: NodeDef mentions attr 'Tshape' not in Op<name=Reshape; signature=tensor:T, shape:int32 -> output:T; attr=T:type>; NodeDef: Y_GroundTruth = Reshape[T=DT_FLOAT, Tshape=DT_INT32](LOut_Add, Y_GroundTruth/shape) when attempting to load the file on Android using tensorflow::Status s = session->Create(graph_def);.
People with similar problems have mentioned that upgrading to Tensorflow 0.9.0rc0 fixed their problems. However, I am already using the most current Tensorflow build in my jni-build.
Could this be a problem with the variables declared when generating the protobuf file?
Snippet
def reg_perceptron(t, weights, biases):
t = tf.nn.relu(tf.add(tf.matmul(t, weights['h1']), biases['b1']), name = "layer_1")
t = tf.nn.sigmoid(tf.add(tf.matmul(t, weights['h2']), biases['b2']), name = "layer_2")
t = tf.add(tf.matmul(t, weights['hOut'], name="LOut_MatMul"), biases['bOut'], name="LOut_Add")
return tf.reshape(t, [-1], name="Y_GroundTruth")
g = tf.Graph()
with g.as_default():
...
rg_weights = {
'h1': vs.get_variable("weights0", [n_input, n_hidden_1], initializer=tf.contrib.layers.xavier_initializer()),
'h2': vs.get_variable("weights1", [n_hidden_1, n_hidden_2], initializer=tf.contrib.layers.xavier_initializer()),
'hOut': vs.get_variable("weightsOut", [n_hidden_2, 1], initializer=tf.contrib.layers.xavier_initializer())
}
rg_biases = {
'b1': vs.get_variable("bias0", [n_hidden_1], initializer=init_ops.constant_initializer(bias_start)),
'b2': vs.get_variable("bias1", [n_hidden_2], initializer=init_ops.constant_initializer(bias_start)),
'bOut': vs.get_variable("biasOut", [1], initializer=init_ops.constant_initializer(bias_start))
}
pred = reg_perceptron(_x, rg_weights, rg_biases)
...
...
g_2 = tf.Graph()
with g_2.as_default():
...
rg_weights_2 = {
'h1': vs.get_variable("weights0", [n_input, n_hidden_1], initializer=tf.contrib.layers.xavier_initializer()),
'h2': vs.get_variable("weights1", [n_hidden_1, n_hidden_2], initializer=tf.contrib.layers.xavier_initializer()),
'hOut': vs.get_variable("weightsOut", [n_hidden_2, 1], initializer=tf.contrib.layers.xavier_initializer())
}
rg_biases_2 = {
'b1': vs.get_variable("bias0", [n_hidden_1], initializer=init_ops.constant_initializer(bias_start)),
'b2': vs.get_variable("bias1", [n_hidden_2], initializer=init_ops.constant_initializer(bias_start)),
'bOut': vs.get_variable("biasOut", [1], initializer=init_ops.constant_initializer(bias_start))
}
pred_2 = reg_perceptron(_x_2, rg_weights_2, rg_biases_2)
...
To stop the post from being too cluttered, I have uploaded my code to generate the .PB-file and my model to create the model on Pastebin.
PBFileGeneration
Model

Getting ProtoBuf.ProtoException using OsmSharp in Xamarin Android

I am trying to test a sample project called Android.Routing.Offline from OsmSharp.Samples in Github.
After two taps on the screen (the first one gets just the GeoCoordinate) I get a ProtoBuf.ProtoException in the Router.cs
private static IBasicRouterDataSource<CHEdgeData> _graph;
public static void Initialize()
{
var routingSerializer = new CHEdgeDataDataSourceSerializer();
_graph = routingSerializer.Deserialize(
Assembly.GetExecutingAssembly().GetManifestResourceStream(#"Android.Routing.Offline.kempen-big.contracted.mobile.routing"));
}
public static Route Calculate(GeoCoordinate from, GeoCoordinate to)
{
try
{
lock(_graph)
{
var router = Router.CreateCHFrom(_graph, new CHRouter(), new OsmRoutingInterpreter());
// The exception happens here below
var fromResolved = router.Resolve(Vehicle.Car, from);
var toResolved = router.Resolve(Vehicle.Car, to);
if(fromResolved != null && toResolved !=null)
{
return router.Calculate(Vehicle.Car, fromResolved, toResolved);
}
}
}
catch(Exception ex)
{
OsmSharp.Logging.Log.TraceEvent("Router", OsmSharp.Logging.TraceEventType.Critical, "Unhandled exception occured: {0}", ex.ToString());
}
return null;
}
And the exception:
> {ProtoBuf.ProtoException: Invalid wire-type; this usually means you
> have over-written a file without truncating or setting the length; see
> http://stackoverflow.com/q/2152978/23354 at
> ProtoBuf.ProtoReader.ReadSingle () ...
I didnt overwrite the file (kempen-big.contracted.mobile.routing) just added it as a linked file in the project. Any ideas how I can solve this issue?
Well, the first thing to try is to check that the contents of the Stream you are reading (via GetManifestResourceStream) contains exactly the contents you are expecting, and not some wrapper or otherwise-corrupt mess. If you have some checksum algorithm you can run: great! Checking just the .Length would be a great start. Otherwise, you could cheat (just for the purposes of validating the contents) by getting the hex:
using (var ms = new MemoryStream())
{
stream.CopyTo(ms);
string hex = BitConverter.ToString(
ms.GetBuffer(), 0, (int)ms.Length);
// dump this string, and compare it to the same output run on the
// oringal file; they should be identical
}
Note that this duplicates the contents in-memory, purely so we can get a byte[] (oversized) to get the hex from - it isn't intended for "real" code, but until you are sure that the contents are correct, all other bets are off. I strongly suspect that you'll find that the contents are not identical to the contents in the original file. Note that I'm also implicitly assuming that the original file works fine in terms of deserialization. If the original file doesn't work: again, all bets are off.

Unity WebPlayer to Android Build Issues

I am new to Unity so a well stepped out answer would be nice. I am trying to make a dice roller on an Android platform. I was following this very well put together tutorial http://games.ucla.edu/resource/unity-1-beginner-tutorial-dice-making-pt-1/ (There is a second part too)
The problem is that it was made for a Web Player. If I try to build it for Android I get two particular errors.
I have two simple scripts with one error associated with each one.
SideTrigger.js - Error: BCE0019: 'currentValue' is not a member of 'UnityEngine.Component'.
public var faceValue = 0;
function OnTriggerEnter( other : Collider ) {
var dieGameObject = GameObject.Find("SixSidedDie");
var dieValueComponent = dieGameObject.GetComponent("DieValue");
dieValueComponent.currentValue = faceValue; //ERROR HERE
Debug.Log("Die1: " + faceValue);
}
DieValue.js - Error: BCE0019: 'text' is not a member of 'UnityEngine.Component'.
public var currentValue = 0;
function Update () {
var dieTextGameObject = GameObject.Find("DieText");
var textMeshComponent = dieTextGameObject.GetComponent("TextMesh");
textMeshComponent.text = currentValue.ToString(); //ERROR HERE
}
I'm assume it's purely a syntactical issue, but I can't seem to find a solution.
GetComponent using string is not recommended due to performance reasons, it is documented here.
It is better to use this:
var dieValueComponent : DieValue = dieGameObject.GetComponent(DieValue)
Or this:
var dieValueComponent : DieValue = dieGameObject.GetComponent.<DieValue>()
See if that works.

Categories

Resources