当我尝试运行我的应用程序时,它会出现Error running 'app': Default Activity not found
,但是我认为我的 AndroidManifestx.ml 很好,因为它之前没有给我任何问题,而且我没有对此文件进行更改,我只是突然收到错误。
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="io.github.ziceck.appgaci001">
<!-- To auto-complete the email text field in the login form with the user's emails -->
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.READ_PROFILE" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<application
android:name=".Initializer"
android:allowBackup="true"
android:icon="@mipmap/logo"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme"
android:hardwareAccelerated="false"
android:largeHeap="true">
<activity android:name=".activities.HomeActivity">
</activity>
<activity android:name=".activities.LoginActivity"
android:noHistory="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".activities.ProyectoActivity" />
<activity android:name=".activities.ProjectsActivity" />
<activity android:name=".activities.ParticipantsActivity" />
<activity android:name=".activities.ActivitiesActivity" />
<activity android:name=".activities.RepliesActivity" />
</application>
</manifest>
我也已经尝试过该选项File -> Invalidate Cache / Restart
,但错误仍然存在。
我也尝试过这样做,Run/Debug Configurations con Specified Activity
但它说该活动未在清单中声明,实际上它不识别任何活动。
build.gradle(模块:app)
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "io.github.ziceck.appgaci001"
minSdkVersion 19
targetSdkVersion 27
versionCode 1
versionName "2018.12.05"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.android.volley:volley:1.1.0'
implementation 'com.android.support:cardview-v7:27.1.1'
implementation 'net.gotev:uploadservice:3.4.2'
implementation 'com.github.chrisbanes:PhotoView:2.1.3'
implementation 'de.hdodenhof:circleimageview:2.2.0'
}
build.gradle(Prohe)
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
mavenCentral()
maven { url "https://jitpack.io" }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
在配置中选择
Launch
:Default Activity
,这样它将采用 AndroidManifest.xml 中定义的配置,在这种情况下将打开确保重建项目
使缓存失效也可以,进入 Android Studio 菜单:
File
>Invalidate Caches / Restart...
同样的事情发生在我身上,唯一对我有用的是执行以下操作: