Lottie error:"Java.Lang.IllegalStateException: 'Unable to parse composition'" - xamarin

When i tried to load gif to my project suddenly return me error:
Java.Lang.IllegalStateException: 'Unable to parse composition'
Image for more information link
I want to insert gif to my project I tried to use Lottie and Json File
My code so far
<forms:AnimationView
x:Name="animationView"
Grid.Row="1"
Animation="first.json"
Loop="false"
AutoPlay="false"/>

Please add xmlns:lottie="clr-namespace:Lottie.Forms;assembly=Lottie.Forms" to your XAML head and use this component
<lottie:AnimationView
x:Name="AnimationView"
Animation="first.json"
AutoPlay="True" Loop="true"
VerticalOptions="FillAndExpand"
HorizontalOptions="FillAndExpand" />
and dont forget to init AnimationViewRenderer.Init(); on MainActivity and AppDelegate

In my case i replaced app:lottie_url with app:lottie_rawRes , and it worked just fine

need determine json like
Android: DroidProject/Assets/filename.json like AndroidAsset
iOS: iOSProject/filename.json like BundleResource

This error occurred when lottie.setAnimation(""); is not set or blank

Related

Is NativeScript Angular xml space sensitive

I have been trying out NativeScript Angular and started with the default Angular app on Windows using VSCode (that shouldn't matter). The default app has the following xml for the items component:
<GridLayout>
<ListView [items]="items">
<ng-template let-item="item">
<StackLayout>
<Label [nsRouterLink]="['/item', item.id]" [text]="item.name"></Label>
</StackLayout>
</ng-template>
</ListView>
</GridLayout>
Now if I add an additional space before the terminating GridLayout tag, i.e. on last line above, the app breaks up with following message:
An uncaught Exception occurred on "main" thread.
Calling js method run failed
Error: View not added to this instance. View: ProxyViewContainer(8) CurrentParent: Page(4) ExpectedParent: AppHostView(1)
I could not find any documentation where it is specified that the xml must be formatted. Is this expected behavior or is there something wrong with my setup?
As far as I know
</ListView>
</GridLayout>
this should work..!!
see if you can re-produce this error on playground and share here..

App displays URL images from other URLs than my own

I am unable to make the URL public, but I've pasted the full URL into my browser and can confirm the page is right - the image shows in the browser.
But... when I copy that exact URL into a Xamarin.Forms image, set as:
<Image
HorizontalOptions="FillAndExpand"
VerticalOptions="FillAndExpand"
Aspect="AspectFit">
<Image.Source>
<UriImageSource Uri="https://example.com/images/doesntshow.jpg"
CacheValidity="3"
CachingEnabled="false"/>
</Image.Source>
</Image>
The image simply will not show.
If I substitute the URL: "https://upload.wikimedia.org/wikipedia/en/a/a9/Example.jpg" the image shows fine.
NOTE: There is 0 possibility the URL is incorrect or has an error because... I'm not typing it; I'm copying/pasting it and it's showing just fine in the browser, just not the Xamarin.Forms app.
I've not a clue as to what to look for. Does anyone else?
ISSUE RESOLVED - thanks for the good mental vibes :)
I found the resolution here:
https://forums.xamarin.com/discussion/105036/images-from-url-not-showing-on-android
April 5
"Just change the following options and it should work with https too.
Android Options => Advanced
HttpClient implementation = Set to "Managed" option value
SSL/TLS implementation = set to "Native TLS 1.2+" option value"
I still don't understand why prior to this setting change, I could load https images from other servers just fine (e.g. "https://upload.wikimedia.org/wikipedia/en/a/a9/Example.jpg"). So... I will lose a bit of sleep wondering what is different on my server from wiki's. If you have a clue, please share.

How to clear UWP WebView cache?

I am using WebView in my UWP application and I want to clear the cache while closing the app, is there a way? I know I can disable cache by adding headers into my HttpRequestMessage as mentioned in this link. However, I want to be able to clear the cache upon app exit.
I did try WebView.ClearTemporaryWebDataAsync() without any success.
Once something is cached it normally remains throughout the app.
Any help is appreciated, thanks.
Edit : Adding code snippet
var webView = new WebView();
webView.Navigate(new Uri("http://refreshyourcache.com/en/cache-test/"));
await WebView.ClearTemporaryWebDataAsync(); //static method
webView.Navigate(new Uri("http://refreshyourcache.com/en/cache-test/"));
I expect the static method to clear cache and when I navigate to same page again its cache should be cleared. Am I doing something wrong here?
In UWP (XAML) there is the ClearTemporaryWebDataAsync method, that allows to webview's cache and IndexedDB data. And there is similar method for JavaScript in MSApp - clearTemporaryWebDataAsync.
Here is code sample (based on your one) that works for me:
XAML:
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<StackPanel>
<WebView x:Name="webView" Width="800" Height="600"></WebView>
<Button x:Name="refreshBtn" Content="Refresh" ></Button>
</StackPanel>
</Grid>
C#:
public MainPage()
{
this.InitializeComponent();
refreshBtn.Tapped += RefreshBtn_Tapped;
webView.Navigate(new Uri("http://refreshyourcache.com/en/cache-test/"));
}
private async void RefreshBtn_Tapped(object sender, TappedRoutedEventArgs e)
{
await Windows.UI.Xaml.Controls.WebView.ClearTemporaryWebDataAsync();
webView.Navigate(new Uri("http://refreshyourcache.com/en/cache-test/"));
}
When I click refresh button, cache is cleared -- I see green image.
There was no possibility to do it in 8.1 according
Ten Things You Need to Know About WebView – An Update for Windows 8.1
the closest method you can use now is WebView.Refresh that "reloads the file without forced cache validation by sending a "Pragma:no-cache" header to the server."
... or just clear cache in explorer

Data binding the Image control in Windows 8 to a URL?

In Windows 8/Store programming, how would you go about databinding an image to a URL. In other platforms I've worked with, I would set the source property (or equivalent) to the URL and the platform would handle it for me, but that doesn't seem to be the case here.
I'm currently binding it to a property for my business object that is of type "string", and returns the URL of the image that I want populated in the image control. How would I go about doing this?
Turns out this is really easy.
Code:
<Image Stretch="UniformToFill">
<Image.Source>
<BitmapImage UriSource="{Binding Path=ImageUrl}" />
</Image.Source>
</Image>
ImageUrl is a Uri containing the path to the remote image.

How can I get MP3 flux with Windows Phone 7?

I tried this code, but it didn't work:
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<MediaElement Height="120"
HorizontalAlignment="Left"
Margin="-12,148,0,0"
Name="mediaPlayer"
VerticalAlignment="Top"
Width="474"
AutoPlay="True"
/>
</Grid>
C#:
Uri Path = new Uri("http://streaming.acc.net:8000/kalilo");
mediaPlayer.Source = Path;
Looks like you're using a unsupported type of stream. And since your link isn't valid, that's all the info we can provide.
Remember that you can't play music in the emulator, and on the device you need to use WPConnect.exe to connect instead of Zune, to make it actually play.
If that is a streaming service, MediaElement is a basic, but often unreliable source because of possible interruptions (e.g. switching from WiFi to a cell data connection). It works in most situations, but it has restrictions on media content that is passed through it.
Assuming that the URI you are showing belongs to a Shoutcast stream, it is not supported by default and you need to implement a connector through MediaStreamSource, even if you receive MP3 bytes.
Here is a great MediaStreamSource example from Tim Heuer.
Also worth checking out - ManagedMediaHelpers.

Resources