問題是我能夠啓動我的應用程序「tk.buntowaf.docs
」,但是當我嘗試使用應用程序時,它崩潰了。我該如何解決'android.content.ActivityNotFoundException'?
錯誤
我調試與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?
下面是該應用程序的完整的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
...
我的環境
我使用:
- 的Android工作室1.0
- 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)
- 搖籃版本:
com.android.tools.build:gradle:2.0.0
- 我已經啓用Multidex!
我./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'
}
我./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}"
}
我./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>
完整代碼:代碼
編輯:
我./settings.gradle
文件:
include ':library', ':app'
我想你已經忘記在清單文件中添加應用程序...而不是tk.buntowaf.docs.DocsWebViewActivity請嘗試tk.buntowaf.docs.app .DocsWebViewActivity ... –
應用程序中沒有DocsWebViewActivity –
您不必在清單中添加庫活動 –