[英]how to fix 'java.lang.noclassdeffounderror' error on xamarin.android preview when use scrollview
我嘗試下面的代碼,但是當使用滾動視圖和 ios 預覽工作正常時,android 預覽不起作用,只是不顯示圖像,但是當運行項目時,模擬器和模擬器中的結果為真,我的問題出在預覽上
這是我的 xaml 頁面:
<?xml version="1.0" encoding="utf-8"?>
<ContentPage Style="{StaticResource baseStyle}" xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:local="clr-namespace:Flightio" x:Class="Flightio.MainPage"
xmlns:ffimageloadingSVG="clr-namespace:FFImageLoading.Svg.Forms;assembly=FFImageLoading.Svg.Forms"
xmlns:fftransformations="clr-namespace:FFImageLoading.Transformations;assembly=FFImageLoading.Transformations">
<ContentPage.Content>
<ScrollView>
<Grid RowSpacing="8" x:Name="grid_Main">
<Grid.RowDefinitions>
<RowDefinition Height="45" />
<RowDefinition Height="75" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Image Source="Logo.jpg" x:Name="image_logo" HorizontalOptions="Center" Margin="0,10,0,0"/>
<RelativeLayout HorizontalOptions="FillAndExpand" x:Name="relLay_blueMenu" BackgroundColor="#1e559e" Grid.Row="1" Margin="10,0,10,0">
<ContentView BackgroundColor="White" x:Name="view_domesticMenu"
Margin="0,5,0,0"
RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=0.8}"
RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=0.2}"
RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=1}">
<RelativeLayout x:Name="relLay_flightMenu" HorizontalOptions="FillAndExpand">
<Label Text="aliali" TextColor="Red" XAlign="Center" Margin="10,0,10,0"/>
</RelativeLayout>
</ContentView>
<ContentView BackgroundColor="#1e559e" x:Name="view_internationalFlightMenu"
Margin="0,5,0,0"
RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=0.6}"
RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=0.2}"
RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=1}"></ContentView>
<ContentView BackgroundColor="#1e559e" x:Name="view_hotelMenu"
Margin="0,5,0,0"
RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=0.4}"
RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=0.2}"
RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=1}"></ContentView>
<ContentView BackgroundColor="#1e559e" x:Name="view_trianMenu"
Margin="0,5,0,0"
RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=0.2}"
RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=0.2}"
RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=1}"></ContentView>
<ContentView BackgroundColor="#1e559e" x:Name="view_busMenu"
Margin="0,5,0,0"
RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=0}"
RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=0.2}"
RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=1}">
<Label Text="aliali2" TextColor="Blue" XAlign="Center"/>
</ContentView>
</RelativeLayout>
<!-- <ffimageloadingSVG:SvgCachedImage Source="baseline-flight.svg" x:Name="image_logo2" HorizontalOptions="Center" Grid.Row="2"/> -->
</Grid>
</ScrollView>
</ContentPage.Content>
</ContentPage>
使用滾動視圖時,我在 android 預覽中遇到此錯誤:
所以我有兩個問題:
1- 如何修復我的 android 預覽?
2-如何在ios預覽中顯示圖像?
1- 如何修復我的 android 預覽?
我剛剛在我身邊測試了你的xaml
代碼,它在預覽中運行良好。
2-如何在ios預覽中顯示圖像?
嘗試刪除圖像名稱中的 .jpg。 例如:
<Image Source="Logo"/>
此外,請檢查此處列出的提示: xaml-previewer-isnt-showing-or-shows-an-error
但是當運行項目時,模擬器和模擬器中的結果為真
我認為模擬器和模擬器中的結果比預覽中的更可靠。
我遇到了同樣的問題,我通過更改 Android 項目的目標平台解決了它。
從應用程序屬性和 Android 清單中的 Android 9.0 (Pie) 到 Android 8.1 (Oreo)。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.