我无法启动我的应用,因为它为我提供了Default Activity not Found错误。我已阅读其他主题并尝试添加/更改以下代码的位置:
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name = "android.intent.category.LAUNCHER" />
</intent-filter>
但它仍然无效。我也试过
File -> Invalidate Caches / Restart...
仍然无效。下面是我的Android Manifest.xml文件。我想用名为“.Main2Activity”的活动启动我的应用程序。另请注意,出于某种原因,我在设计模式下的.xml文件显示为黑色背景,并且奇怪地不同。
<?xml version="1.0" encoding="utf-8"?>
<!--
The ACCESS_COARSE/FINE_LOCATION permissions are not required to use
Google Maps Android API v2, but you must specify either coarse or fine
location permissions for the 'MyLocation' functionality.
-->
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-feature
android:name="android.hardware.camera"
android:required="true" />
<activity android:name=".MainActivity" />
</activity>
<activity android:name=".Dining" />
<activity android:name=".SignUp" />
<provider
android:name="android.s
upport.v4.content.FileProvider"
android:authorities="com.example.android.fileprovider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@layout/file_paths" />
</provider>
<!--
The API key for Google Maps-based APIs is defined as a string resource.
(See the file "res/values/google_maps_api.xml").
Note that the API key is linked to the encryption key used to sign the APK.
You need a different API key for each encryption key, including the release key that is used to
sign the APK for publishing.
You can define the keys for the debug and release targets in src/debug/ and src/release/.
-->
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="AIzaSyD37TQWZ02Re5_3lTH-kL17cOOVQw1B8dY" />
<activity>
android:name=".MapsActivity"
android:label="@string/title_activity_maps" />
<activity android:name=".Main2Activity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name = "android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".MapsMain"></activity>
</application>
答案 0 :(得分:2)
<activity>
android:name=".MapsActivity"
android:label="@string/title_activity_maps" />
检查, 你必须在xml中有错误。 它将是:
<activity
android:name=".MapsActivity"
android:label="@string/title_activity_maps" />
不是吗?
答案 1 :(得分:0)
你试过这个:https://stackoverflow.com/a/22028681/1101730.
将这些行添加到android {...}块内的build.gradle文件中:
android { ... sourceSets { main.java.srcDirs + ='src / main /' } }
编辑文件后,点击工具&gt; Android&gt;使用Gradle文件同步项目。
我能想到的最后一件事就是点击Run&gt;编辑配置并确保选择您的活动作为启动活动。