所以我剛纔遇到這個錯誤,這導致我的android應用程序不能在設備上工作。每當我調試我的應用程序的Android它崩潰了一些reasont。 。作爲Xamarin的新用戶,我無能爲力。Xamarin.Forms「App has stopped working」on android
以下是錯誤我真的越來越:
[art] Late-enabling -Xcheck:jni
[ContextImpl] Unable to create files subdir /data/data/com.comhuis.saleskicker.sales_kicker/cache
[ContextImpl] Unable to create files subdir /data/data/com.comhuis.saleskicker.sales_kicker/files
[AndroidRuntime] Shutting down VM
[AndroidRuntime] FATAL EXCEPTION: main
[AndroidRuntime] Process: com.comhuis.saleskicker.sales_kicker, PID: 5035
[AndroidRuntime] java.lang.RuntimeException: Unable to get provider mono.MonoRuntimeProvider: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.io.File.getAbsolutePath()' on a null object reference
[AndroidRuntime] at android.app.ActivityThread.installProvider(ActivityThread.java:5015)
[AndroidRuntime] at android.app.ActivityThread.installContentProviders(ActivityThread.java:4607)
[AndroidRuntime] at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4547)
[AndroidRuntime] at android.app.ActivityThread.access$1500(ActivityThread.java:148)
[AndroidRuntime] at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
[AndroidRuntime] at android.os.Handler.dispatchMessage(Handler.java:102)
[AndroidRuntime] at android.os.Looper.loop(Looper.java:135)
[AndroidRuntime] at android.app.ActivityThread.main(ActivityThread.java:5272)
[AndroidRuntime] at java.lang.reflect.Method.invoke(Native Method)
[AndroidRuntime] at java.lang.reflect.Method.invoke(Method.java:372)
[AndroidRuntime] at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:909)
[AndroidRuntime] at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:704)
[AndroidRuntime] Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.io.File.getAbsolutePath()' on a null object reference
[AndroidRuntime] at mono.MonoPackageManager.LoadApplication(MonoPackageManager.java:27)
[AndroidRuntime] at mono.MonoRuntimeProvider.attachInfo(MonoRuntimeProvider.java:42)
[AndroidRuntime] at android.app.ActivityThread.installProvider(ActivityThread.java:5012)
[AndroidRuntime] ... 11 more
[Process] Sending signal. PID: 5035 SIG: 9
我還沒有真正得到了我的項目一些特別的東西。我無法上傳我的解決方案的截圖,只是還沒有,但我心底嘗試,並形容它:從存在的SalesKicker
我的解決方案和SalesKicker.Droid。 SalesKicker有3個文件MainPage.Xaml MainPage.Xaml.cs SalesKicker.cs。 和SalesKicker.Droid包含通常的東西加1個名爲delogo.png的圖像,我將其用作appicon。這是我的MainActivity.cs代碼:
namespace SalesKicker.Droid
{
[Activity (Label = @"Sales Kicker", Icon = "@drawable/delogo", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsApplicationActivity
{
protected override void OnCreate (Bundle bundle)
{
Xamarin.Insights.Initialize (global::SalesKicker.Droid.XamarinInsights.ApiKey, this);
base.OnCreate (bundle);
global::Xamarin.Forms.Forms.Init (this, bundle);
LoadApplication (new App());
}
}
我也一直試圖設置一些斷點。我在每一行都嘗試過,並且一遍又一遍地重複着同樣的錯誤。我也嘗試將我的「目標版本」設置爲Lollipop 5.0,它是我的LG G3上的當前軟件版本,並且它沒有任何效果。我還安裝了每個Android SDK。由於我對Xamarin相當陌生,所以我毫無頭緒。有人可以告訴我我在做什麼錯嗎?
那麼,例外是真正清楚,你想從一個文件對象,它是空的路徑(您或您使用一個組件),我的賭注是一個組件試圖寫入SD卡和G3有外部/內部存儲的另一個映射,因此它不能被創建或找到。在模擬器上試試。 – Gusman
嗯,我看到了,但是如何更改設備內部存儲的寫入路徑? –
您的代碼是拋出異常還是來自組件?如果它是一個組件,請向創建它的開發者詢問,如果它是你的代碼,那麼就有一些解決方案,比如測試不同的路徑來檢查它的映射位置,使用SDK監視器應用程序並檢查設備的文件系統。 – Gusman