My Android Application is not running - android

Whenever I try to run my android app it shows the following error .
PowerSMS does not specify a android.test.InstrumentationTestRunner instrumentation or does not declare uses-library android.test.runner in its AndroidManifest.xml
What is the problem ? How can I solve this ?

Eclipse: Right click->Run As->Android Application instead of Android JUnitTest
Android Studio: Run->Edit Configuration to Run as Android Application either to device or emulator.

I think you probably missing the following in your AndroidManifest.xml:
<instrumentation android:name="android.test.InstrumentationTestRunner"
android:targetPackage="your.package"
android:label="your tests label" />
and
<uses-library android:name="android.test.runner" />

Related

Error on using the maps library

I am trying to run android maps example on my emulator, I have added the library
<uses-library android:name="com.google.android.maps" />
inside the application tag.
When I try to run the application in emulator I get the following error
Installation error: INSTALL_FAILED_MISSING_SHARED_LIBRARY
I have set the build path for android to "Google API's"
How to resolve this error?
Actually, you can't run google maps v2 on emulator.
You can check this post for a dirty solution
Right click on your project --> Properties --> Android --> On the library block clik on add and add google-play-services_lib as your project's library. Then to your manifest file add:
<permission
android:name="your_package.permission.MAPS_RECEIVE"
android:protectionLevel="signature"/>
<uses-permission android:name="your_package.permission.MAPS_RECEIVE"/>
Then in your application tag add:
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="YOUR_API_KEY"/>
If you are testing the app in emulator make sure that You have created AVD for emulator with Google Maps-APIs.
In general, this error arises from the fact that Google Maps not installed on your device/emulator.

Could not find test class exception when running Android Junit

i am trying to run my test class as Android Junit Test through Eclipse and then its giving could not find test class excpetion.
I have properly mentioned the intrumentation target package to my productive code package.
Below is the android manifest
<?xml version="1.0" encoding="utf-8"?>
<uses-sdk android:minSdkVersion="15" />
<instrumentation
android:name="android.test.InstrumentationTestRunner"
android:targetPackage="com.abc.android" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name" >
<uses-library android:name="android.test.runner" />
</application>
I have also checked by build path, its properly including the target classes such that the class file could be found.
Not able to find what is the problem.
Thanks and Regards,
Saurav
I removed my project and got the latest version from my source code repo.
Then i ran my tests it did work.
But would like to know why the problem was there.
Where does Android junit test picks it classes when running from Eclipse ?...i presume its bin/classes which is in the build path...can not figure out on what is the problem
Did you check if you are setting up properly? See this link
http://developer.android.com/tools/testing/activity_test.html
Also you can think of using Robotium for testing.
https://code.google.com/p/robotium/

Android Application is not installed

I tried signing the application and tried just debugging it. I have the Galaxy nexus. i have been able to run on the device before but now when I compile and build it shows up on the device but when i try and run it it tells me the application is not installed. I have tried to reinstall it too!
thanks
You need to add Internet permission for the app you're installing, in its manifest file, by adding the following line to the manifest file:
<uses-permission android:name="android.permission.INTERNET" />
Do this before the <application ...> tag

New package not yet registered with the system. Error on a real phone

I am working on an Android project in Eclipse and debugging / testing using my HTC Desire Z. I was coding away building a menu for my app when I started getting this error which is preventing me from continuing. Lots of people have had this error but none of the solutions that I found have worked for me. I tried cleaning and rebuilding the project, manually uninstalling the app from my phone, and renaming the domain in the manifest file. For people using an emulator they talked about deleting the data file but I'm not sure what this translates to when using a real phone.
Here is the console when I try to build:
[2011-08-09 06:57:13 - GreenThumbs] Android Launch!
[2011-08-09 06:57:13 - GreenThumbs] adb is running normally.
[2011-08-09 06:57:13 - GreenThumbs] Performing com.hernblog.GreenThumbs.GreenThumbs activity launch
[2011-08-09 06:57:13 - GreenThumbs] Automatic Target Mode: using device 'HT0ANRV03417'
[2011-08-09 06:57:13 - GreenThumbs] Uploading GreenThumbs.apk onto device 'HT0ANRV03417'
[2011-08-09 06:57:13 - GreenThumbs] Installing GreenThumbs.apk...
[2011-08-09 06:57:16 - GreenThumbs] Success!
[2011-08-09 06:57:17 - GreenThumbs] Starting activity com.hernblog.GreenThumbs.GreenThumbs on device HT0ANRV03417
[2011-08-09 06:57:19 - GreenThumbs] New package not yet registered with the system. Waiting 3 seconds before next attempt.
[2011-08-09 06:57:22 - GreenThumbs] Starting activity com.hernblog.GreenThumbs.GreenThumbs on device HT0ANRV03417
[2011-08-09 06:57:23 - GreenThumbs] New package not yet registered with the system. Waiting 3 seconds before next attempt.
[2011-08-09 06:57:23 - GreenThumbs] ActivityManager: Error: Activity class {com.hernblog.GreenThumbs/com.hernblog.GreenThumbs.GreenThumbs} does not exist.
[2011-08-09 06:57:26 - GreenThumbs] Starting activity com.hernblog.GreenThumbs.GreenThumbs on device HT0ANRV03417
[2011-08-09 06:57:27 - GreenThumbs] New package not yet registered with the system. Waiting 3 seconds before next attempt.
[2011-08-09 06:57:30 - GreenThumbs] Starting activity com.hernblog.GreenThumbs.GreenThumbs on device HT0ANRV03417
[2011-08-09 06:57:30 - GreenThumbs] New package not yet registered with the system. Waiting 3 seconds before next attempt.
[2011-08-09 06:57:33 - GreenThumbs] Starting activity com.hernblog.GreenThumbs.GreenThumbs on device HT0ANRV03417
[2011-08-09 06:57:34 - GreenThumbs] ActivityManager: Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.hernblog.GreenThumbs/.GreenThumbs }
[2011-08-09 06:57:34 - GreenThumbs] ActivityManager: Error type 3
[2011-08-09 06:57:34 - GreenThumbs] ActivityManager: Error: Activity class {com.hernblog.GreenThumbs/com.hernblog.GreenThumbs.GreenThumbs} does not exist.
And here is my manifest file:
?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.hernblog.GreenThumbs"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="8" />
<application>
<uses-library android:name="android.test.runner" />
</application>
<instrumentation android:name="android.test.InstrumentationTestRunner"
android:targetPackage="com.hernblog.Green.Thumbs" android:label="GreenThumbs Tests" />
<application android:icon="#drawable/icon" android:label="#string/app_name">
<activity android:name="GreenThumbs"
android:label="#string/app_name"
android:screenOrientation="landscape">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Any ideas on how to fix this?
I too had this problem immediately after changing the package name of my app (prepping it for Android Market). In Eclipse do a Project > Clean... , then turn off Build-Automatically so you can Build-All.
I got this error after renaming my project package. I fixed it by doing a clean in Eclipse. Then a full rebuild. After that pressing F11 launched the application on the device. (I also uninstalled the application from the device before that but I don't think that was the problem).
I solved this by unchecking the "Is Library" in Project->Properties->Android
Really a confusing Error...and what worked for me is :
Rename the app package name in Manifest xml file to some other name, any!
Save project, try to run it, mine gave lots of errors and didn't run!
Again roll back to old name...save and run!
Cleaning the project didn't work for me. I was able to fix this issue by doing the following:
Add #!/system/bin/sh as the first line /system/bin/am
Add #!/system/bin/sh as the first line /system/bin/pm
I was getting this issue when using some custom ROMs on my phone.
Hope this fixes your problem,
Joey
This is eclipse problem and one of the workaround of this is to rename your package in the manifest for example rename
package="com.hernblog.GreenThumbs"
to
package="com.hernblog.GreenThumbs1"
compile and build this, then put it back to the name you wanted
package="com.hernblog.GreenThumbs"
works as a charm :)
I too got the same error.
And able to resolve with following steps.
In phone that you are testing,
1.go to settings>Apps>Downloaded
2.Go to bottom, I found my app has been disabled.
3.Now uninstall it.
4.In the next run able to install it properly.
Thanks.
Check your package names. At one point you're using com.hernblog.GreenThumbs (unusual to have upper-case package names) then com.hernblog.Green.Thumbs and you even have an activity named com.hernblog.GreenThumbs.GreenThumbs!
I managed to fix this through some voo-doo magic combination of steps. I did many of the things mentioned as answers above, but I think the big fix happened when I updated to a new version of Android.
Thanks for the help guys. I appologize for not having a clear answer on how to fix this problem.
Ok, here's my answer. I was pulling my hair out trying to find the answer to this. I found at his link that the person basically had to create a new project and copy all of the old files into that. So, that's what I did, and it worked! I couldn't believe it. It took me a long time to find it.
However, while working on my new project, I made a change and the same error occurred again. Luckily, I know what change I made, and I undid it and the error cleared.
I added another application tag to the android manifest and it then generated the error. I simply undid it and the error went away.
I opened my app in Google Play, and press "enable"...
Wow! I founded in manifest: android:enabled="false" ... and deleted it!)
I had to reset my device/phone.
Background on how I confused my device:
I pushed the APP.apk to /system/app (this was the wrong place I guess)
I also used eclipse to deploy directly via adb
I then deinstalled manually these apps via settings
then I ran into the cited error "New package not yet registered with the system."
My answer: try test on your friend's device.
I also have the same problem. My Phone is LG lu-3000.
This symptom occurred after I moved my project from Mac to Windows.
After stuck on 10 days I found it runs on Android Virtual Device(but too slow to test anything) and now spent some days more and found out it DOES RUN on the other device!!
Before I tested on AVB and Motorola Bionic, I factory-reset my phone and did everything above. But it didn't change any result. It runs on neither Mac nor Windows.
More disastrous thing is now none of my android project is run on my device..
It is almost 2 years gone from I purchased this device.
If you have deleted the application by hand from the connected device and you still get the same error, please restart the connected device, and it will work correctly!
Check "android:installLocation" in your AndroidManifest.xml.
"preferExternal" will cause the problem.
I too had this problem immediately after changing the package name of my app. In Eclipse go to Project--> Clean, then turn off Build-Automatically so you can Build-All and don't forget to restart the eclipse. Then its working fine for me..
I solved this problem by setting the minimum SDK level of the project lower than the phone's SDK level.
Also try to free memory from the device, uninstall some apps to do this. solved the issue for me.
Make sure you have
<uses-sdk
android:minSdkVersion="yourMinSDKver"
android:targetSdkVersion="youtTargetSDKver" />
on top, in your manifest.xml file. I did swap it by mistake and got this very same error.
I made a really silly mistake. I laughed at when i caught it. There were two application tags in one application!!! have a look
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.riddhi.android"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="15" />
<uses-permission android:name="android.permission.INTERNET" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="#string/title_activity_main" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".WCFActivity"
android:label="#string/title_activity_main" >
</activity>
</application>
which should be
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.riddhi.android"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="15" />
<uses-permission android:name="android.permission.INTERNET" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="#string/title_activity_main" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".WCFActivity"
android:label="#string/title_activity_main" >
</activity>
</application>
so i fixed my project. I hope this will be useful to you.
Check your Manifest file. If it has multiple Tags it will face this as it will look for Class in the first Application tag it finds.

Android Unit Testing in Eclipse: "Failed to launch test"

I've just started trying to set up some unit testing in what is essentially my first android app. I've had a hell of a time finding resource for this, but ultimately was able to scrape together what I hoped was the right path forward.
First, this is what I've done.
In Eclipse, I right-clicked my project that I'd like to create a test project for.
I selected AndroidTools -> New Test Project
I filled out the necessary information selecting a location of ../MyApp/tests for the new project and selected MyApp as the project to test. Everything else was left as default.
While this was executing I received the below as an error:
[2011-04-01 08:13:02 - WPMSTest] R.java was modified manually! Reverting to generated version!
But everything seemed okay. I had a new source tree in my tests folder.
So I tried to execute it (first on hardware, then on the emulator) by RunAs -> Android jUnit test.
In both runs I received the below in my eclipse console:
[2011-04-01 08:23:04 - WPMSTest] Launching instrumentation android.test.InstrumentationTestRunner on device emulator-5554[2011-04-01 08:23:04 - WPMSTest] Failed to launch test
My two manifest files:
WPMSTest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.WPMS.test"
android:versionCode="1"
android:versionName="1.0">
<instrumentation android:targetPackage="com.WPMS" android:name="android.test.InstrumentationTestRunner" />
<application android:icon="#drawable/icon" android:label="#string/app_name">
<uses-library android:name="android.test.runner" />
</application>
WPMS:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.WPMS"
android:versionCode="1"
android:versionName="1.0">
<application android:label="#string/app_name" android:icon="#drawable/ic_launcher_wpms">
<activity android:name=".WPMS"
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>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
I'm hoping someone has seen something like this before and can shed some light on what I'm doing wrong. Please let me know if you need any more files and I'll be sure to post them.
Thanks!
I was missing a TestSuite in my Test Project. Once I had my AllTests class extend TestSuite I got past the error.
For me the problem was that I was using JUnit 4. When I changed to JUnit 3 it started working. I hope this helps.
[2011-04-01 08:13:02 - WPMSTest] R.java was modified manually! Reverting to generated version!
You get this error when you manually make changes in the R.java file. At times, when you clean the project, R.java file goes missing. At such occasion you must either copy the same program's R.java(if stored somewhere as a copy) or create an entire new project.
For your second issue, I too have got similar error when I was testing my app on the device. I had to make changes in the shell using $adb. then the device got recognised.
I had the same problem: JUnit 3 TestCase works, but when running JUnit 4 TestCase, I got "Failed to launch test" error.
But after following Ken's suggestion, i.e. make the JUnit 4 test class extends TestCase, and rename the test method with the "test" prefix, the test launches and runs the test!

Categories

Resources