简体   繁体   English

安装后,Android 应用程序无法打开。 但它可以在模拟器中运行

[英]Android app won't open after i install. But it can run in emulator

I have exported my app from eclipse and installed it on my phone.我已经从 Eclipse 导出了我的应用程序并将其安装在我的手机上。 After installation, I click open from package installer, but the installer force close.安装后,我从包安装程序中单击打开,但安装程序强制关闭。 Afterwards, when I tried to launch the app, nothing happen after I click it.之后,当我尝试启动该应用程序时,单击它后没有任何反应。 I click the app in app drawer but it return to home screen instead.我单击应用程序抽屉中的应用程序,但它返回到主屏幕。

I am able to run in emulator and in debug mode when I connect my device via usb, but not when I export the apk to install.当我通过 USB 连接我的设备时,我能够在模拟器和调试模式下运行,但当我导出 apk 进行安装时则不能。

Note that this is not the first app that I exported to install.请注意,这不是我导出安装的第一个应用程序。 Previous apps are working fine.以前的应用程序运行良好。

I found the problem!我发现了问题! I had declared the activity 2 times in the manifest with different properties, like:我在清单中用不同的属性声明了 2 次活动,例如:

<activity android:name=".myclass"></activity> 

and

<activity android:name=".myclass" android:label="@string/app_name">
  <intent-filter>   
     <action android:name="android.intent.action.MAIN" /> 
     <category android:name="android.intent.category.LAUNCHER" /> 
  </intent-filter>
</activity> 

Remove the unwanted one from the manifest and it will work.从清单中删除不需要的,它将起作用。

Check your android emulator version and the firmware version of the phone.检查您的 android 模拟器版本和手机的固件版本。 If firmware version is not supported for that app you will be install from adb, but you cant start the app.如果该应用程序不支持固件版本,您将从 adb 安装,但您无法启动该应用程序。

Check the settings to be able to install the unknown apps in检查设置以能够安装未知应用程序
Settings->Applications and check box "Unknown Sources"设置->应用程序和复选框“未知来源”

I spent few days to identify the problem why it occurred .But I solved my problem this way- Modification in Android Manifest我花了几天时间来确定它发生的原因。但是我通过这种方式解决了我的问题-Android Manifest 中的修改

<activity android:configChanges >
        <intent-filter android:label="@string/launcher_name">
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
            <I removed my code here that i added for reference to google play store for reference >

Remove the unwanted one from the manifest and it will work.从清单中删除不需要的,它将起作用。

Try to search errors in your Android manifest, i have the same problem and the problem was the 'R' in the category LAUNCHER are in lower case.尝试在您的 Android 清单中搜索错误,我遇到了同样的问题,问题是 LAUNCHER 类别中的“R”是小写的。

like this:像这样:

<category android:name="android.intent.category.LAUNCHEr" />

to solve it, simple:要解决它,很简单:

<category android:name="android.intent.category.LAUNCHER" />

android:theme="@style/AppTheme.NoActionBar"> android:theme="@style/AppTheme.NoActionBar">

        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>

Removing the configuration of all the modules that are not from the app worked for me.删除不是来自应用程序的所有模块的配置对我有用。 In other words, just leave the Project.app module and check its configuration.换句话说,只需离开Project.app模块并检查其配置。

Edit Run/Debug Configurations -> Android app -> app编辑运行/调试配置-> Android 应用->应用

GL GL

if you use splash in react native:如果您在本机反应中使用飞溅:

To avoid error: Binary XML file line #XXX: requires a valid src attribute为避免错误:二进制 XML 文件行 #XXX:需要有效的 src 属性

inside a layer-list, use:在图层列表中,使用:

<item android:drawable="@drawable/image" />

instead of:代替:

<item>
  <bitmap android:src="@drawable/image"/>
</item>

My solution is to add this flag in download manager when application is install我的解决方案是在安装应用程序时在下载管理器中添加此标志


    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)

In my case - i had this flag -> intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)就我而言 - 我有这个标志 -> intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)

I replaced it with Intent.FLAG_ACTIVITY_NEW_TASK and everything worked!我用Intent.FLAG_ACTIVITY_NEW_TASK替换了它,一切正常!

Try to check on permission in Android Manifest.尝试在 Android Manifest 中检查权限。 I was having the same problem earlier when i install a NFC app.我之前在安装 NFC 应用程序时遇到了同样的问题。 I forget to give permission for NFC.我忘记授予 NFC 许可。 After i gave the permission it works fine for me.在我给予许可后,它对我来说很好用。 Please check your AndroidManifest.请检查您的 AndroidManifest。

My Manifest looked like this.我的清单看起来像这样。 Those that need help and have a similar manifest look bellow.那些需要帮助并有类似清单的人请看下面。

<activity android:name=".login.activities.SplashScreenActivity">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
                <action android:name="android.intent.action.VIEW"/>
                <category android:name="android.intent.category.DEFAULT"/>
                <category android:name="android.intent.category.BROWSABLE"/>
                <data
                    android:host="example.com"
                    android:scheme="https"/>
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

You just need to remove the你只需要删除

< data> <数据>

element in the intent-filler and it should work.意图填充器中的元素,它应该可以工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM