简体   繁体   English

Android应用程序无法在设备上启动

[英]Android application won't launch on device

I have developed an Android application using Eclipse which works perfectly on the Android Virtual Device or when running it on my smartphone using Eclipse + USB Debugging mode enabled. 我使用Eclipse开发了一个Android应用程序,它可以在Android虚拟设备上完美运行,或者在启用Eclipse + USB调试模式的智能手机上运行它。

However, when I install the application on my phone using a signed apk file which resided on the sd card and try to launch it I get a "Activity not found - lsp.workshop" error, and the app won't start (lsp.workshop is the application package name). 但是,当我使用签名的apk文件在我的手机上安装应用程序,该文件位于SD卡并尝试启动它时,我得到“未找到活动 - lsp.workshop”错误,应用程序将无法启动(lsp。 workshop是应用程序包的名称)。

the AndroidManifest.xml file is: AndroidManifest.xml文件是:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="lsp.workshop"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk android:minSdkVersion="7" />
    <uses-permission android:name="android.permission.INTERNET" /> 

    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name" > 
        <activity
            android:name=".TwitterLogin"
            android:label="@string/app_name" android:launchMode="singleTask">
            <intent-filter>
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />
                <action android:name="android.intent.action.MAIN" />

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

                <data android:host="log" />
            </intent-filter>
        </activity>

    </application>
</manifest>

What am I doing wrong? 我究竟做错了什么? Thanks 谢谢

The emulator and android with a debugger attached can behave differently then when you start an app normally. 附加调试器的模拟器和android的行为可能与正常启动应用程序时的行为不同。 The timing is different (influences multithreading and race conditions) and other things may be affected as well. 时机不同(影响多线程和竞争条件),其他事情也可能受到影响。

But just to be sure: 但只是为了确定:

Did you list the activity within your AndroidManifest.xml file? 您是否在AndroidManifest.xml文件中列出了活动?

Is the spelling really correct? 拼写是否真的正确?

If those things are not the problem, then could you show some code (how do you start the activity? with an intent?) and maybe the manifest file ? 如果那些问题不是问题,那么你能展示一些代码(你如何开始活动?有意图?)以及清单文件?

Using two intent filters instead of one solved the problem: 使用两个意图过滤器而不是一个解决了问题:

<intent-filter>
     <action android:name="android.intent.action.MAIN" />
     <category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
     <action android:name="android.intent.action.VIEW" />
     <category android:name="android.intent.category.DEFAULT" />
     <category android:name="android.intent.category.BROWSABLE" />
     <data android:scheme="twitter" android:host="log" />
</intent-filter>

导出apk时,请务必将其命名为-something.apk,即在导出应用程序时将“.apk”放在末尾(y)

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

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