<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.vaibhav.myapplication">
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity
android:name="MainActivity"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
...........................................................................
Above is my code , which looks fine but i don't know why I am getting the below Error ...
Unexpected error while executing: am start -n "com.example.vaibhav.myapplication/com.example.vaibhav.myapplication.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER Error while Launching activity
.................
Also their is one thing , my , am start command is taking package name twice though it is declared correctly in
am start -n "com.example.vaibhav.myapplication/com.example.vaibhav.myapplication.MainActivity" -a android.intent.action.MAIN -c android.intent.category
You should use fully classified class name for activity in AndroidManifest.xml.
android:name
The name of the class that implements the activity, a subclass of Activity. The attribute value should be a fully qualified class name (such as, "com.example.project.ExtracurricularActivity"). However, as a shorthand, if the first character of the name is a period (for example, ".ExtracurricularActivity"), it is appended to the package name specified in the element.
For more info refer Android developer site
It looks like for some reason a wrong adb command is generated and being stuck in the project.
For me cleaning the project, closing then importing the project solved the problem.
Maybe even invalidate cashes and restart is also enough
Related
Hi I have installed Android studio correctly. I made AVD for e.q Marshmallow and project on the same platform. after press RUN, AVD turns on. I can do everything on emulated android phone(other issue- after running this my computer dramticly slowing down) but I should see my "Hello world" app, there is not there. I'm getting following error
Unexpected error while executing: am start -n "com.example.zad2/com.example.zad2.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Error while Launching activity
where zad2 is my project name.
On Stacfoverflow i saw tips to add into manifest some filter code but I already have it:
<?xml version="1.0" encoding="utf-8"?>
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/Theme.Zad2">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
Yea don't trouble friends. I found this post: Session 'app': Error Launching activity
and I unistalled my app from AVD :)
Error while executing: am start -n
"com.example.myapplication/com.example.myapplication.Detail" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.example.myapplication/.Detail }
Error type 3
Error: Activity class {com.example.myapplication/com.example.myapplication.Detail} does not exist.
Error while Launching activity
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.myapplication">
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".Detail"
android:label="SQLite Example - Details"></activity>
</application>
</manifest>
It is a easy problem which is happened when you migrate to androidX (at least it happened for me by this reason).
An easy solution is:
making a new project (same package name as the current one)
go to app\src\main and delete all files in main directory (for this new project)
go to app\src\main and copy all files in main directory (for the old project)
past the files in app\src\main directory (the new project)
run the new project
I'm using Android Studio 2.1.3 (Mac OS X) and com.android.tools.build:gradle:2.1.3. I've already tried invalidating cache and restarting and clean builds.
I have a project with many ProductFlavors, all of which use the same starting activity save one (this one is a paid version that uses the licensing library, all the others are free so I don't bother, although a solution might just be to use the licensed version of the activity for all flavors but skip the licensing unless a resource is set... just seems too easy to hack). I thus have 2 AndroidManifest.xml files:
// app/src/main/AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.company.app">
...
<application android:allowBackup="true" android:icon="#mipmap/ic_launcher"
android:label="#string/appFriendlyName"
android:theme="#style/AppTheme">
<activity
android:name="com.company.app.TabsFragmentActivity"
android:screenOrientation="portrait"
android:label="#string/appFriendlyName">
<intent-filter android:label="#string/launcherLabel">
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
...
</application>
</manifest>
// app/src/PaidFlavor/AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.company.app">
<application android:allowBackup="true" android:icon="#mipmap/ic_launcher"
android:label="#string/appFriendlyName"
android:theme="#style/AppTheme">
<activity
tools:node="merge"
android:name="com.company.app.TabsFragmentActivityLicensed"
android:screenOrientation="portrait"
android:label="#string/appFriendlyName">
<intent-filter android:label="#string/launcherLabel">
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
tools:node="remove"
android:name="com.company.app.TabsFragmentActivity"/>
</application>
</manifest>
This works great, and I can inspect the generated intermediate (merged) AndroidManifest.xml, and indeed the TabsFragmentActivity activity is removed, and the TabsFragmentActivityLicensed is added, and all is right with the world.
But I don't want the debug version (build type) to be licensed. Again, I can work around it easy enough in code, but it's the principle of the matter! So I thought it would be easy to just move
app/src/PaidFlavor/AndroidManifest.xml
to
app/src/PaidFlavorRelease/AndroidManifest.xml
This is where things go wrong. Everything builds without error, and I look at the intermediate (merged) manifest and it still looks correct. However, Android Studio tries to launch the PaidFlavor with release build type as:
adb shell am start -n "com.company.project/com.company.app.TabsFragmentActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Wrong activity! Where's it getting it from? Am I using the wrong subdirectory (PaidFlavorRelease/)? This results in the obvious error:
Error while executing: am start -n "com.company.project/com.company.app.TabsFragmentActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.company.project/com.company.app.TabsFragmentActivity }
Error type 3
Error: Activity class {com.company.project/com.company.app.TabsFragmentActivity} does not exist.
Error while Launching activity
I do have a curious error in my application.
My app crashes (don't mind the crash, I roughly know why - classloader) when I start the application from the OS directly, then kill it from the background via any Task Killer (this is one of the few ways to reproduce the crash consistently -> simulating the OS freeing memory and closing the application) and try to restart it again.
The thing is, if I start the application via adb shell using the following command:
adb shell am start -a android.intent.action.MAIN -n com.my.packagename/myLaunchActivity
I cannot reproduce the crash.
So is there any difference in how Android OS calls the application as opposed to the above call?
EDIT: added the manifest (just changed names)
<?xml version="1.0" ?>
<manifest android:versionCode="5" android:versionName="1.05" package="com.my.sample" xmlns:android="http://schemas.android.com/apk/res/android">
<uses-sdk android:minSdkVersion="7"/>
<application android:icon="#drawable/square_my_logo" android:label="#string/app_name">
<activity android:label="#string/app_name" android:name="com.my.InfoActivity" android:screenOrientation="landscape"></activity>
<activity android:label="#string/app_name" android:name="com.my2.KickStart" android:screenOrientation="landscape"/>
<activity android:label="#string/app_name" android:name="com.my2.Launcher" android:screenOrientation="landscape">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/></manifest>
starting the com.my2.Launcher from the adb shell
First thing I can see is that if you launch the app from the launcher icon, the Intent includes the CATEGORY "android.intent.category.LAUNCHER" and using the adb shell am it does not.
Also, when you launch via the launcher icon, the Intent flag FLAG_ACTIVITY_RESET_TASK_IF_NEEDED (0x200000) is set, in the adb shell case it is not.
Not sure if any of that would make a difference in your crash behaviour, but it answers the question.
I'm trying to start an Android application using adb shell.
I'm not succeeding
The AndoridManifest.XML is pasted below:
<?xml version="1.0" encoding="UTF-8"?>
<manifest android:versionCode="4" android:versionName="0.0.5.0" android:installLocation="auto" package="com.supascale.supascale" xmlns:android="http://schemas.android.com/apk/res/android">
<application android:label="#string/app_name" android:icon="#drawable/i_c_o_n_e________1">
<activity android:theme="#android:style/Theme.Translucent" android:label="#string/app_name" android:name=".wdgen.GWDPSupaScale_Android$WDLanceur">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
...
I tried the following call:
adb shell am start -a android.intent.action.MAIN -n com.supascale.supascale/com.supascale.supascale.wdgen.GWDPSupaScale_Android
This does'nt work ... I've tried all sorts of itterations after the ... /
I get Error type 3, the intent class does not exist!
Any help will be greatly appreciated.
Regards
Adrian
Some of my error messages:
You should escape the $ - \$ - since otherwise it gets changed to nothing. $WDLanceor is interpreted as a shell variable by the android shell, and since the variable is not set it becomes an empty string.
Quoting the arguments (adb ... -n "... GWDPSupaScale_Android$WDLanceur") will only quote it on the Windows side, when it goes into the shell on the android side it'll be without quotes. The backslash will survive the Windows command prompt and be converted to an actual $ on the android shell.