Monday, March 10, 2014

Not able to start Android application after adding activity through new Wizard in Eclipse

I normally add new Android activities, corresponding classes and config changes manually. Recently I came to visit a link from Kerala start-up village blog where they were explaining how to create new activity in Android. They mentioned in the same way I am doing. Or probably most of the developers are doing. Then I thought of other easy ways using Eclipse IDE or the Android plug-in to generate activity xml, its class and changes in the AndroidManifest and could see Android help page which explains the same. 

Just thought of trying it out by creating an activity into one of my Android project. After creating the activity, I was not able to run the application in simulator. The error got in the Console window is given below .

[time - app name] Installation error: INSTALL_PARSE_FAILED_MANIFEST_MALFORMED
[time - app name] Please check logcat output for more details.
[time - app name] Launch canceled!

It suggests to check the logcat as well. So opened the logcat window and log reads as follows.

<time>: W/ActivityManager(407): No content provider found for permission revoke: file:///data/local/tmp/<name>.apk
<time>: I/PackageManager(407): Copying native libraries to /data/app-lib/vmdl-1401938519
<time>: W/PackageParser(407): /data/app/vmdl-1401938519.tmp (at Binary XML file line #12): <activity> does not have valid android:name

Here the console logs says that the manifest is malformed. In logcat window we could see 2 issues. One error says permission issue. And second line says activity does not have valid android:name property value. It means the activity which I added via the android wizard might have added incorrect entry to the android manifest xml file.

I started by googling the error message. Most of the SO links says its permission issue and I have to give full permission to C:\Users\<user name>\.android folder. I checked and could see it has full permission. Then I compared my faulty project's androidmanifest.xml file with other project and could see that the Android wizard which used to add activity has added the package name to the android:name. Earlier the name was .activityname. The wizard updated the activity name as packagename.activityname which caused the problem. Since the package name is already mentioned in the manifest root node, activity name cannot have the package name.

A sample has been given below

Wrong xml
<activity
            android:name="JoymonOnline.Malayalam.SwipeHost"
            android:label="@string/title_activity_swipe_host" >
</activity>

Corrected the android:name

<activity
            android:name=".SwipeHost"
            android:label="@string/title_activity_swipe_host" >
</activity>

Happy coding. 

1 comment:

Blogger said...

DreamHost is ultimately one of the best hosting provider for any hosting plans you might require.