尝试在Android Studio中运行调试器时出现错误

时间:2019-03-22 17:32:41

标签: android debugging

当前发生的情况:当我在某个方法上创建一个断点并右键单击以选择Debug VendorMapsActivity时,出现一个错误,提示我说"Error running VendorMapsActivity: this activity must be exported or contain an intent-filter."

需要发生的事情:我需要能够调试一种方法,该方法应在用户滑动关闭应用程序并从Firebase Auth和Firebase Database Uid删除其数据时调用。我需要查看该方法是否以所需的方式运行。因为到目前为止,该方法本身尚未从Firebase数据库中删除任何数据。

我做了什么:我在构建中选择了调试版本。我在gradle中添加了debug的构建类型。我的清单文件中也有VendorMapsActivity。

清单代码:

   <?xml version="1.0" encoding="utf-8"?>
  <manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.example.zzyzj.man">

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />

<application
    android:allowBackup="true"
    android:icon="@drawable/logo"
    android:label="@string/app_name"
    android:roundIcon="@drawable/logo"
    android:supportsRtl="true"
    android:theme="@style/AppTheme"
    tools:ignore="GoogleAppIndexingWarning">

    <activity android:name=".login.EatLoginActivity"
        android:screenOrientation="portrait"
        android:label="@string/app_name"/>
    <activity android:name=".login.VendorLoginActivity"
        android:screenOrientation="portrait"
        android:label="@string/app_name" />
    <activity
        android:name=".WelcomeActivity"
        android:screenOrientation="portrait"
        android:label="@string/app_name">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

  <meta-data
        android:name="com.google.android.geo.API_KEY"
        android:value="@string/google_maps_key" />

    <meta-data
        android:name="com.google.android.gms.ads.APPLICATION_ID"
        android:value="@string/testAppId"/>

    <activity
        android:name=".MapsActivity"
        android:label="@string/title_activity_eater_maps"
        android:screenOrientation="portrait">

    </activity>


    <activity
        android:name=".VendorMapsActivity"
        android:label="@string/title_activity_vendor_maps"
        android:screenOrientation="portrait"/>
</application>

 </manifest>

分级代码:

android {

compileSdkVersion 27
defaultConfig {
    applicationId "com.example.zzyzj.man"
    minSdkVersion 21
    targetSdkVersion 27
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        signingConfig signingConfigs.config
    }
    debug {
        debuggable true
    }
}

}

我实际上要调试的内容:

 @Override
protected void onDestroy() {
    super.onDestroy();
    //TODO: Remove me.  Debug only!
    while (!Debug.isDebuggerConnected()) {
        try {
            Log.d(TAG, "Waiting for debugger");
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
    //TODO: Figure out how to delete UID and user when they sign out
    removeAnonymousVendorUser();
    FirebaseAuth.getInstance().signOut();
    finish();
}

1 个答案:

答案 0 :(得分:1)

不要太深入,请尝试在Android Studio中检查更新。如果有,请执行这些操作,然后重新启动“ Android Studio”

对我有用:)