简体   繁体   中英

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.

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).

the AndroidManifest.xml file is:

<?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. 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?

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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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