[英]Why am I getting a default Activity not found error?
I have used intent-filter
here:我在这里使用了
intent-filter
:
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<action android:name="com.example.test.testActivity"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
I invalidated and restarted several times, but it failed.我多次失效并重新启动,但它失败了。
I used Micer´s method to do things like this我用 Micer 的方法做这样的事情
android {
....
....
sourceSets {
main.java.srcDirs += 'src/main/<YOUR DIRECTORY>'
}
}
But it still has the error Default Activity not found但它仍然有错误未找到默认活动
android {
compileSdkVersion 24
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.example.test"
minSdkVersion 15
targetSdkVersion 24
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
}
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.test">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".testActivity"></activity>/>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<action android:name="com.example.test.testActivity"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</application>
</manifest>
and I think this maybe the source:我认为这可能是来源:
<activity android:name=".testActivity"></activity>/>
error:Reports empty tag body.错误:报告空标签正文。 The validation works in XML / JSP / JSPX / HTML/ XHTML file types.
验证适用于 XML/JSP/JSPX/HTML/XHTML 文件类型。
How can I solve this issue?我该如何解决这个问题?
The intent-filter
goes INSIDE your activity
TAG to make it the default like so: intent-filter
进入您的activity
标签内部,使其成为默认值,如下所示:
<activity android:name=".testActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Replace this,换这个,
<activity android:name=".testActivity"></activity>/>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<action android:name="com.example.test.testActivity"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
with this,有了这个,
<activity android:name=".testActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<action android:name="com.example.test.testActivity"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.