After I have set up all the unit test cases for my android application I now also want to do functional testing. But I encouter one problem. As I am developping for the HTC Legend I can, by now, only use android platforms up to 2.1. But in some way it seems that the ActivityInstrumentationTestCase2 won't work.
public SupplierSelectoinTest() {
super("com.sap.catalogue.activities", SupplierSelection.class);
}
This simple piece of code gives me the following error, when I try to run the test:
java.lang.RuntimeException: Unable to resolve activity for: Intent { act=android.intent.action.MAIN flg=0x10000000 cmp=com.sap.catalogue.activities/com.sap.catalogue.activities.SupplierSelection }
at android.app.Instrumentation.startActivitySync(Instrumentation.java:371)
at android.test.InstrumentationTestCase.launchActivityWithIntent(InstrumentationTestCase.java:120)
at android.test.InstrumentationTestCase.launchActivity(InstrumentationTestCase.java:98)
at android.test.ActivityInstrumentationTestCase2.getActivity(ActivityInstrumentationTestCase2.java:87)
at com.sap.catalogue.test.acceptance.SupplierSelectoinTest.setUp(SupplierSelectoinTest.java:27)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:169)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:154)
at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:430)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1447)
I read through all tutorials and all I get out of it is, that it should work but it doesn't. Anyway, when I switch to android 2.2 (which is no solution for now) and I use the new constructor, where I only need to hand in the activity class and not the pkg string the emulator will run the tests without complaining.
But there has to be a way to get this running in android 2.1!
In addition
These are my two Manifest.xml files. The first one, is the one of the application itself. The other one is the one of the test project.
Application Manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.sap.catalogue"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="#drawable/icon" android:label="#string/app_name">
<activity android:name=".Catalogue"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".activities.CategoryBrowser"></activity>
<activity android:name=".activities.ProductDetails"></activity>
<activity android:name=".activities.ProductSearch"></activity>
<activity android:name=".activities.ProductView"></activity>
<activity android:name=".activities.SupplierSelection"></activity>
</application>
<uses-sdk android:minSdkVersion="7" />
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
</manifest>
Test Manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.sap.catalogue.test"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="#drawable/icon" android:label="#string/app_name">
<uses-library android:name="android.test.runner" />
</application>
<uses-sdk android:minSdkVersion="7" />
<instrumentation android:targetPackage="com.sap.catalogue" android:name="android.test.InstrumentationTestRunner" />
</manifest>
Use the top level package name.
public SupplierSelectoinTest() {
super("com.sap.catalogue", SupplierSelection.class);
}
Most probably, you didn't write the activity in the Manifest.xml. Would you share it also?
Edit:
Add this to the test Manifest.xml. I think, this will solve your problem.
<activity android:name="com.sap.catalogue.activities.SupplierSelection"></activity>
Related
It was all good yesterday, but right now it won't show up when I run the AVD.
Don't know if it is my AndroidManifest.xml file which is pretty standard.
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.app" >
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme">
<activity
android:name="com.example.app.Hoved"
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>
This is now fixed all, thank you!
The problem was that I write Android app on Xamarin, so you use flags there instead of declaring the activity in the manifest.
You missing this 2 'lines', it's really important but just past it above (over) < application and it's will work.
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="21" />
This is the most basic question, you should know that before u start programming in visual studio or eclipse. Just watch some tutorials on youtube it will help you. Good Luck.
I have tried everything to get this to work and now I have this error:
Exception in thread "main" java.lang.NoClassDefFoundError: android/app/Activity
There is another post on here that says to try this in the manifesto:
uses-library android:name="com.google.android.maps"
uses-permission android:name="android.permission.INTERNET"
This solution does not work for me.
As background, I am running one windowsXP, I had to change the Bootstrap Entries to JRE System Library and JUnit3 to fix another error. I also had to change the path for the emulator to run as well.
This is my first time trying to run the droid app stuff on here. I am using the hello world example. I assume I must run the emulator for the phone first then run my code?
Thanks
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="edu.rit.cs.ats"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="8" />
<application android:icon="#drawable/icon" android:label="#string/app_name">
<activity android:name=".AndroidTestActivity"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<uses-library android:name="com.google.android.maps" />
<uses-permission android:name="android.permission.INTERNET" />
</application>
</manifest>
I need to set the permission in the manifest to read, I manually edited the manifest after having problems trying to use the android manifest editor. My code is below and is currently proving to be erroneous. Any help appreciated. :)
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="ac.uk.d"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="#drawable/icon" android:label="#string/app_name">
<activity android:name=".Quiz"
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-sdk android:minSdkVersion="7" />
<uses-permission android:name="android.permission.READ_CONTACTS"/>
</manifest>
The issue is that you have not cleaned the project. To clean the project, select 'Project' on the top menu bar then you'll find clean upon which you clean the selected project or clean all projects as per your needs..
I have been working on an Android 2.2 app for the past three months, but decided this past week to try to build the app using Android 2.1 SDK. The app ran fine under 2.2 in the emulator, and I was able to build the source as a 2.1 project successfully, but when I try to run the app in the 2.1 emulator, I get the following runtime error:
java.lang.SecurityException: Permission Denial: starting Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.tampamobileapps.testapp/.LoginScreen } from null (pid=-1, uid=-1) requires null
The app is not that complicated and only makes HTTP POST and GET requests. It also supports PayPal payments, but this API worked fine under 2.2. I have googled this error message and have not found any solutions to get rid of the error.
Any ideas?
Edit:
Here's the relevant parts of the Android manifest; the LoginScreen currently does nothing of consequence.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.app"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="#drawable/icon"
android:debuggable="true"
android:label="#string/app_name"
android:name=".SharedApplicationContext">
<activity android:name=".LoginScreen"
android:label="#string/login_screen_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".LoginScreen"
android:label="#string/app_name">
</activity>
<activity android:name=".MainMenu"
android:label="#string/app_name">
</activity>
</application>
<uses-sdk android:minSdkVersion="7" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
</manifest>
You have duplicate activities defined in your manifest for .LoginScreen. Try removing:
<activity android:name=".LoginScreen"
android:label="#string/app_name">
</activity>
You may need to use the android:exported="true" option.
For instance, preference activities in live wallpapers need this set. Hope this helps someone else as I know you have probably already sorted the issue.
The subject says it all. My application gets internet access thanks to the android.permission.INTERNET permission, but my test cases don't while using the instrumentation test runner.
This means I can't test my server IO routines in my test cases. What's up?
Here's my manifest in case it helps you. Thanks!
Sorry about the lack of indents - could not get it working on short notice with this site. Thanks!
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.helloandroid" android:versionCode="1" android:versionName="1.0">
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
<application android:icon="#drawable/icon" android:label="#string/app_name">
<uses-library android:name="android.test.runner" />
<activity android:name=".HelloAndroid" 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-sdk android:minSdkVersion="2" />
<instrumentation android:name="android.test.InstrumentationTestRunner" android:targetPackage="qnext.mobile.redirect" android:label="Qnext Redirect Tests" />
</manifest>
I've compared your manifest file with mine, and it looks about the same. Only difference is that I require minSdkVersion 3, and that I have the uses-permission after the application tag. I don't think that should make a difference.
Are you trying to run on the emulator or on a phone?
I had the same issue. In my case the application under test (not the test application) did not have the INTERNETpermission.