简体   繁体   English

我该如何修复'android.content.ActivityNotFoundException'?

[英]How can I fix 'android.content.ActivityNotFoundException'?

The problem is that I'm able to start my app " tk.buntowaf.docs " but when I try to use the app it crashs. 问题是我能够启动我的应用程序“ tk.buntowaf.docs ”但是当我尝试使用该应用程序时它会崩溃。

Error 错误

I debugged the app with the adb logcat *:E command and I got this error output: 我用adb logcat *:E命令调试了应用程序,我得到了这个错误输出:

AndroidRuntime: Caused by: android.content.ActivityNotFoundException: Unable to find explicit activity class {tk.buntowaf.docs.app/tk.buntowaf.docs.DocsWebViewActivity}; have you declared this activity in your AndroidManifest.xml?

Here is the complete logcat for this app: 这是这个应用程序的完整logcat:

...
04-21 12:06:05.879   828   843 E SmartStandbyMode: user=UserHandle{0},owner=UserHandle{0}
04-21 12:06:05.945  9211  9211 E AndroidRuntime: FATAL EXCEPTION: main
04-21 12:06:05.945  9211  9211 E AndroidRuntime: Process: tk.buntowaf.docs.app, PID: 9211
04-21 12:06:05.945  9211  9211 E AndroidRuntime: java.lang.IllegalStateException: Could not execute method for android:onClick
04-21 12:06:05.945  9211  9211 E AndroidRuntime:        at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:293)
04-21 12:06:05.945  9211  9211 E AndroidRuntime:        at android.view.View.performClick(View.java:5265)
04-21 12:06:05.945  9211  9211 E AndroidRuntime:        at android.view.View$PerformClick.run(View.java:21534)
04-21 12:06:05.945  9211  9211 E AndroidRuntime:        at android.os.Handler.handleCallback(Handler.java:815)
04-21 12:06:05.945  9211  9211 E AndroidRuntime:        at android.os.Handler.dispatchMessage(Handler.java:104)
04-21 12:06:05.945  9211  9211 E AndroidRuntime:        at android.os.Looper.loop(Looper.java:207)
04-21 12:06:05.945  9211  9211 E AndroidRuntime:        at android.app.ActivityThread.main(ActivityThread.java:5728)
04-21 12:06:05.945  9211  9211 E AndroidRuntime:        at java.lang.reflect.Method.invoke(Native Method)
04-21 12:06:05.945  9211  9211 E AndroidRuntime:        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
04-21 12:06:05.945  9211  9211 E AndroidRuntime:        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:679)
04-21 12:06:05.945  9211  9211 E AndroidRuntime: Caused by: java.lang.reflect.InvocationTargetException
04-21 12:06:05.945  9211  9211 E AndroidRuntime:        at java.lang.reflect.Method.invoke(Native Method)
04-21 12:06:05.945  9211  9211 E AndroidRuntime:        at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:288)
04-21 12:06:05.945  9211  9211 E AndroidRuntime:        ... 9 more
04-21 12:06:05.945  9211  9211 E AndroidRuntime: Caused by: android.content.ActivityNotFoundException: Unable to find explicit activity class {tk.buntowaf.docs.app/tk.buntowaf.docs.DocsWebViewActivity}; have you declared this activity in your AndroidManifest.xml?
04-21 12:06:05.945  9211  9211 E AndroidRuntime:        at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1805)
04-21 12:06:05.945  9211  9211 E AndroidRuntime:        at android.app.Instrumentation.execStartActivity(Instrumentation.java:1523)
04-21 12:06:05.945  9211  9211 E AndroidRuntime:        at android.app.ContextImpl.startActivity(ContextImpl.java:682)
04-21 12:06:05.945  9211  9211 E AndroidRuntime:        at android.app.ContextImpl.startActivity(ContextImpl.java:664)
04-21 12:06:05.945  9211  9211 E AndroidRuntime:        at android.content.ContextWrapper.startActivity(ContextWrapper.java:331)
04-21 12:06:05.945  9211  9211 E AndroidRuntime:        at com.thefinestartist.utils.content.ContextUtil.startActivity(ContextUtil.java:461)
04-21 12:06:05.945  9211  9211 E AndroidRuntime:        at tk.buntowaf.docs.DocsWebView$Builder.show(DocsWebView.java:924)
04-21 12:06:05.945  9211  9211 E AndroidRuntime:        at tk.buntowaf.docs.DocsWebView$Builder.show(DocsWebView.java:911)
04-21 12:06:05.945  9211  9211 E AndroidRuntime:        at tk.buntowaf.docs.app.MainActivity.onClick(MainActivity.java:46)
04-21 12:06:05.945  9211  9211 E AndroidRuntime:        ... 11 more
04-21 12:06:05.952   205   205 E SurfaceFlinger: smallscreen captureScreenImplLocked isSmall 0, isLeft 0
04-21 12:06:05.952   205   205 E SurfaceFlinger: add by mtk crop(0,36,480,516) reqWidth(288) reqHeight(288)
04-21 12:06:05.985   828   843 E SmartStandbyMode: SSM_ShouldHandle while UserHandle.OWNER
04-21 12:06:05.986   828   843 E SmartStandbyMode: user=UserHandle{0},owner=UserHandle{0}
04-21 12:06:05.993   828   843 E SmartStandbyMode: SSM_ShouldHandle while UserHandle.OWNER
04-21 12:06:05.993   828   843 E SmartStandbyMode: user=UserHandle{0},owner=UserHandle{0}
04-21 12:06:06.138   828   843 E SmartStandbyMode: SSM_ShouldHandle while UserHandle.OWNER
04-21 12:06:06.139   828   843 E SmartStandbyMode: user=UserHandle{0},owner=UserHandle{0}
04-21 12:06:06.141   828   843 E SmartStandbyMode: SSM_ShouldHandle while UserHandle.OWNER
04-21 12:06:06.141   828   843 E SmartStandbyMode: user=UserHandle{0},owner=UserHandle{0}
04-21 12:06:06.292   828   828 E WifiTrafficPoller:  packet count Tx=4934 Rx=5765
04-21 12:06:06.292   828   828 E WifiTrafficPoller: notifying of data activity 1
04-21 12:06:07.294   828   828 E WifiTrafficPoller: TRAFFIC_STATS_POLL true Token 14 num clients 9
04-21 12:06:07.295   828   828 E WifiTrafficPoller:  packet count Tx=4943 Rx=5773
04-21 12:06:07.295   828   828 E WifiTrafficPoller: notifying of data activity 3
04-21 12:06:07.524   828   878 E InputDispatcher: channel 'a901017 Toast (server)' ~ Channel is unrecoverably broken and will be disposed!
04-21 12:06:07.524   828   878 E InputDispatcher: channel '7609fb1 tk.buntowaf.docs.app/tk.buntowaf.docs.app.MainActivity (server)' ~ Channel is unrecoverably broken and will be disposed!
04-21 12:06:07.540   828  1661 E MultiWindowProxy: getServiceInstance failed!
04-21 12:06:08.296   828   828 E WifiTrafficPoller: TRAFFIC_STATS_POLL true Token 14 num clients 9
04-21 12:06:08.297   828   828 E WifiTrafficPoller:  packet count Tx=4943 Rx=5773
04-21 12:06:08.297   828   828 E WifiTrafficPoller: notifying of data activity 0
...

My environment 我的环境

I am using: 我在用:

  • Android Studio 1.0 Android Studio 1.0
  • Java version: java version "1.8.0_73" / Java(TM) SE Runtime Environment (build 1.8.0_73-b02) / Java HotSpot(TM) 64-Bit Server VM (build 25.73-b02, mixed mode) Java版本: java version "1.8.0_73" / Java(TM) SE Runtime Environment (build 1.8.0_73-b02) / Java HotSpot(TM) 64-Bit Server VM (build 25.73-b02, mixed mode)
  • Gradle Version: com.android.tools.build:gradle:2.0.0 Gradle版本: com.android.tools.build:gradle:2.0.0com.android.tools.build:gradle:2.0.0com.android.tools.build:gradle:2.0.0
  • And I have Multidex enabled! 我启用了Multidex!

My ./build.gradle file: 我的./build.gradle文件:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
  repositories {
    jcenter()
  }
  dependencies {
    classpath 'com.android.tools.build:gradle:2.3.1'
    classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
    classpath 'com.novoda:bintray-release:0.3.4'
  }
}

allprojects {
  repositories {
    jcenter()
  }
}

task clean(type: Delete) {
  delete rootProject.buildDir
}

ext {
  minSdkVersion = 7
  targetSdkVersion = 23
  compileSdkVersion = 23
  buildToolsVersion = '23.0.3'

  sourceCompatibility = JavaVersion.VERSION_1_8
  targetCompatibility = JavaVersion.VERSION_1_8

  versionCode = 1
  versionName = '1.0.0'

  supportLibVersion = '24.1.1'
  playLibVersion = '8.4.0'
}

My ./app/build.gradle file: 我的./app/build.gradle文件:

apply plugin: 'com.android.application'

android {
  compileSdkVersion rootProject.ext.compileSdkVersion
  buildToolsVersion rootProject.ext.buildToolsVersion

  defaultConfig {
    applicationId "tk.buntowaf.docs.app"
    minSdkVersion rootProject.ext.minSdkVersion
    targetSdkVersion rootProject.ext.targetSdkVersion
    versionCode rootProject.ext.versionCode
    versionName rootProject.ext.versionName
    vectorDrawables.useSupportLibrary = true
    multiDexEnabled = true
  }
  buildTypes {
    release {
      minifyEnabled false
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
  }
    buildToolsVersion '25.0.0'
}

dependencies {
  compile fileTree(dir: 'libs', include: ['*.jar'])
  compile 'com.android.support:multidex:1.0.1'

  compile project(':library')
  //    compile "tk.buntowaf.docs:${rootProject.ext.versionName}"

  compile "com.android.support:support-annotations:${rootProject.ext.supportLibVersion}"
  compile "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
  //    compile "com.android.support:support-vector-drawable:${rootProject.ext.supportLibVersion}"
  //    compile "com.android.support:palette-v7:${rootProject.ext.supportLibVersion}"
  compile "com.android.support:design:${rootProject.ext.supportLibVersion}"
  //    compile "com.android.support:recyclerview-v7:${rootProject.ext.supportLibVersion}"

  //    compile "com.google.android.gms:play-services-base:${rootProject.ext.playLibVersion}"
  //    compile "com.google.android.gms:play-services-gcm:${rootProject.ext.playLibVersion}"
  //    compile "com.google.android.gms:play-services-plus:${rootProject.ext.playLibVersion}"
  //    compile "com.google.android.gms:play-services-analytics:${rootProject.ext.playLibVersion}"
  //    compile "com.google.android.gms:play-services-location:${rootProject.ext.playLibVersion}"
  //    compile "com.google.android.gms:play-services-maps:${rootProject.ext.playLibVersion}"
}

My ./app/src/main/AndroidManifest.xml file: 我的./app/src/main/AndroidManifest.xml文件:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="tk.buntowaf.docs.app">

  <uses-permission android:name="android.permission.INTERNET"/>
  <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>

  <application
      android:name="android.support.multidex.MultiDexApplication"
      android:allowBackup="true"
      android:hardwareAccelerated="true"
      android:icon="@mipmap/ic_launcher"
      android:label="@string/app_name"
      android:supportsRtl="true"
      android:theme="@style/AppTheme">
    <activity
        android:name="tk.buntowaf.docs.app.MainActivity"
        android:label="@string/app_name">
      <intent-filter>
        <action android:name="android.intent.action.MAIN"/>

        <category android:name="android.intent.category.LAUNCHER"/>
      </intent-filter>
    </activity>

    <activity
        android:name="tk.buntowaf.docs.DocsWebViewActivity"
        android:configChanges="keyboardHidden|orientation|screenSize"
        android:screenOrientation="sensor"
        android:theme="@style/FinestWebViewTheme.Light"/>

    <activity android:name="tk.buntowaf.docs.app.WebViewActivity"/>
  </application>

</manifest>

Complete code: 完整代码:


EDIT: 编辑:

My ./settings.gradle file: 我的./settings.gradle文件:

include ':library', ':app'

your last activity in manifest has problem 你在清单中的最后一个活动有问题

set that like this and i think it solve your problem 设置这样,我认为它解决了你的问题

instead of these 而不是这些

 <activity
    android:name="tk.buntowaf.docs.DocsWebViewActivity"
    android:configChanges="keyboardHidden|orientation|screenSize"
    android:screenOrientation="sensor"
    android:theme="@style/FinestWebViewTheme.Light"/>

<activity android:name="tk.buntowaf.docs.app.WebViewActivity"/>

just past these 刚刚过去

<activity
    android:name="tk.buntowaf.docs.DocsWebViewActivity"
    android:configChanges="keyboardHidden|orientation|screenSize"
    android:screenOrientation="sensor"
    android:theme="@style/FinestWebViewTheme.Light">

  <intent-filter>
    <action android:name="android.intent.action.MAIN"/>
  </intent-filter>

</activity>

you entered the android:name .... twice 你输入了android:name ....两次
and also i think its necessary to have intent-filter for activity 而且我认为有必要对活动进行意图过滤

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 android.content.ActivityNotFoundException,无法开始活动 - android.content.ActivityNotFoundException ,unable to start activity android.content.ActivityNotFoundException:将url传递给intent - android.content.ActivityNotFoundException: passing url to the intent 尝试从我的应用程序打开 web 浏览器时看到“android.content.ActivityNotFoundException” - I'm seeing an `android.content.ActivityNotFoundException` when trying to open a web browser from my app Android错误:“ android.content.ActivityNotFoundException:未找到用于处理Intent的活动” - Android error : “android.content.ActivityNotFoundException: No Activity found to handle Intent” 对于服务类,我看到 android.content.ActivityNotFoundException: Unable to find explicit activity class - For a Service class I see android.content.ActivityNotFoundException: Unable to find explicit activity class android.content.ActivityNotFoundException:无法在Android中找到明确的活动类 - android.content.ActivityNotFoundException: Unable to find explicit activity class in Android android.content.ActivityNotFoundException:无法找到明确的活动类 - android.content.ActivityNotFoundException: Unable to find explicit activity class 使用ContentProvider打开文件时出现android.content.ActivityNotFoundException - android.content.ActivityNotFoundException when opening file using ContentProvider android.content.ActivityNotFoundException:未找到用于处理Intent的活动 - android.content.ActivityNotFoundException: No Activity found to handle Intent 致命异常:android.content.ActivityNotFoundException:未找到处理 Intent 的活动 - Fatal Exception: android.content.ActivityNotFoundException: No Activity found to handle Intent
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM