首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >找不到默认活动错误Android Studio

问找不到默认活动错误Android Studio
EN

Stack Overflow用户
提问于 2017-02-27 02:35:29
回答 2查看 467关注 0票数 2

我无法启动我的应用程序,因为它给我的默认活动找不到错误。我已经阅读了其他线程,并尝试添加/更改以下代码的位置:

代码语言:javascript
复制
<intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name = "android.intent.category.LAUNCHER" />
</intent-filter>

但它仍然不起作用。我也试过

代码语言:javascript
复制
File -> Invalidate Caches / Restart...

但还是不起作用。下面是我的Android Manifest.xml文件。我想用名为".Main2Activity“的活动启动我的应用程序。还要注意的是,由于某些原因,我在设计模式下的.xml文件显示为黑色背景,与其他文件有很大的不同。

代码语言:javascript
复制
<?xml version="1.0" encoding="utf-8"?>

​

代码语言:javascript
复制
<!--
     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>

​

EN

回答 2

Stack Overflow用户

发布于 2017-02-27 02:46:24

代码语言:javascript
复制
<activity>
        android:name=".MapsActivity"
        android:label="@string/title_activity_maps" />

检查一下,您一定是在xml中有错误。它将是:

代码语言:javascript
复制
<activity
        android:name=".MapsActivity"
        android:label="@string/title_activity_maps" />

难到不是么?

票数 2
EN

Stack Overflow用户

发布于 2017-02-27 02:50:00

你有没有试过这个:https://stackoverflow.com/a/22028681/1101730.

将以下行添加到android { ... }块内的build.gradle文件中:

android { ...sourceSets { main.java.srcDirs +=‘源/主/’}}

编辑文件后,单击Tools > Android > Sync Project with Gradle Files。

我能想到的最后一件事是单击Run > Edit configuration,并确保您的活动被选中作为启动活动。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/42472513

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档