Java.Lang.NoClassDefFoundError:超时超过了获取异常详细信息Xamarin Android

时间:2019-02-12 05:25:42

标签: c# android xamarin

在按照教程尝试运行代码后,我在应用程序启动时得到了Java.Lang.NoClassDefFoundError: Timeout exceeded getting exception details。我尝试了cleanRebuild,但是并不能解决问题。当我尝试调试时,我注意到它在onCreate方法上,但是由于代码在构建时没有错误,我不明白其引发异常的原因。 以下是base.onCreate方法中的代码

protected override void OnCreate(Bundle savedInstanceState)
    {
        base.OnCreate(savedInstanceState);

        // Set our view from the "main" layout resource
        SetContentView(Resource.Layout.activity_main);
        locationManager = (LocationManager)GetSystemService(Android.Content.Context.LocationService);
        provider = locationManager.GetBestProvider(new Criteria(), false);
        Location location = locationManager.GetLastKnownLocation(provider);

        if (location == null)
        {
            System.Diagnostics.Debug.WriteLine("No Location");
        }
    }

清单文件

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
  android:versionCode="1" android:versionName="1.0" 
  package="XamarinWeatherApp.XamarinWeatherApp" 
  android:installLocation="auto">
  <uses-sdk android:minSdkVersion="21" android:targetSdkVersion="27" />
  <uses-permission android:name="android.permission.INTERNET" />
  <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" 
   />
  <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
  <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
  <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
  <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
  <uses-permission 
  android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" 
  />
  <application android:allowBackup="true" android:icon="@mipmap/ic_launcher" 
  android:label="@string/app_name" 
  android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" 
  android:theme="@style/AppTheme"></application>
</manifest>

1 个答案:

答案 0 :(得分:0)

检查manifest.xml,确保正确添加“活动”并检查位置权限。