我通过Android Studio在手机上启动应用,在应用中显示错误。如果我通过手机上的图标打开应用程序,那么它可以工作。我认为AndroidManifest.xml中存在问题 附:如果设备不在Lolipop中,那么它无论如何都无法工作。
UPD:我在Google Play中发布了自己的应用。在Developer Console中,我收到一条通知消息,指出主要活动中出现错误,onCreate。但我在这里找不到任何东西。
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.engineers.great.firstapp"
>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<application
android:allowBackup="true"
android:icon="@mipmap/icon"
android:label="@string/app_name"
android:theme="@style/AppTheme">
<!--Below MA which started at first. I can can return here, if I use a back button -->
<activity android:name="com.engineers.great.firstapp.MainActivity"
android:windowSoftInputMode="adjustResize"
android:configChanges="orientation"
android:screenOrientation="portrait">
<intent-filter>
<category android:name="android.intent.category.LAUNCHER"/>
<action android:name="android.intent.action.MAIN"/>
</intent-filter>
</activity>
<!-- It's not a main menu lol if you click from MA on "START" then you will be here -->
<activity android:name=".MainMenu"
android:windowSoftInputMode="adjustResize"
android:configChanges="orientation"
android:screenOrientation="portrait">
<intent-filter>
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<!-- Below from MA1_! to MA2 are questions and results of my test. I set intent extras in everyone. I don't know, maybe it's important -->
<activity android:name=".MainActivity1_1"
android:windowSoftInputMode="adjustResize"
android:configChanges="orientation"
android:screenOrientation="portrait">
</activity>
<activity android:name=".MainActivity1_2"
android:configChanges="orientation"
android:screenOrientation="portrait">
</activity>
<activity android:name=".MainActivity1_3"
android:configChanges="orientation"
android:screenOrientation="portrait">
</activity>
<activity android:name=".MainActivity2"
android:configChanges="orientation"
android:screenOrientation="portrait">
</activity>
<!-- It's many buttons with different results of test -->
<activity android:name=".Sociotypes"
android:configChanges="orientation"
android:screenOrientation="portrait">
</activity>
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
</application>
</manifest>
答案 0 :(得分:1)
您没有在第一个活动中使用任何Launcher intent过滤器。 在您要首先启动的活动中添加此项:
<intent-filter>
<category android:name="android.intent.category.LAUNCHER"/>
<action android:name="android.intent.action.MAIN"/>
</intent-filter>