I am attempting to implement message sending from my Android app using AWS SQS. I have included aws-android-sdk-core-2.6.15 and aws-android-sdk-sqs-2.6.15 jar files. With just these, I am unable to resolve AmazonSQSClientBuilder (import com.amazonaws.services.sqs.AmazonSQSClientBuilder) and AWSStaticCredentialsProvider (import com.amazonaws.auth.AWSStaticCredentialsProvider).
These work if I include the aws-java-sdk-1.11.278 jar file. However, this causes the 'DuplicateFileException' when I try to build. If I include only this jar, then I get the 'GC overhead limit exceeded' error.
Is there a smaller package that will allow the import of these necessary classes?
Thanks!
The AWS SDK for Android does not follow the same pattern as AWS SDK for Java.
The applicable constructors can be found in these files depending on whether you want an async client or not:
https://github.com/aws/aws-sdk-android/blob/master/aws-android-sdk-sqs/src/main/java/com/amazonaws/services/sqs/AmazonSQSAsyncClient.java
https://github.com/aws/aws-sdk-android/blob/master/aws-android-sdk-sqs/src/main/java/com/amazonaws/services/sqs/AmazonSQSClient.java
One example:
AWSCredentialsProvider awsCredentialsProvider = // Choose one of many classes that implement this for instance, CognitoCachingCredentialsProvider
AmazonSQSClient client = new AmazonSQSClient(awsCredentialsProvider);
I'm trying to build a testing framework for an android application using selenium webdriver on eclipse and Appium. I'm not using Maven. The initial script to launch the app is as follows:
package executionEngine;
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import io.appium.java_client.android.AndroidDriver;
public class DriverScript {
public static AndroidDriver driver = null;
public static void main(String[] args) throws MalformedURLException {
// TODO Auto-generated method stub
File app = new File(System.getProperty("user.dir")+"\\BP_QASTG.apk");
// Created object of DesiredCapabilities class.
DesiredCapabilities capabilities = new DesiredCapabilities();
//capabilities.setCapability(CapabilityType.BROWSER_NAME,"");
// Set android deviceName desired capability. Set your device name.
capabilities.setCapability("deviceName", "Galaxy Tab A");
// Set android VERSION desired capability. Set your mobile device's OS version.
capabilities.setCapability(CapabilityType.VERSION, "6.0.2");
// Set android platformName desired capability. It's Android in our case here.
capabilities.setCapability("platformName", "Android");
// Set android appPackage desired capability. It is
capabilities.setCapability("appPackage", "com.rivigo.zoombp.rivigozoombpapp");
// Set android appActivity desired capability. It is
capabilities.setCapability("appActivity", "com.rivigo.zoombp.rivigozoombpapp.activity.Activity.RivigoHomeActivity");
capabilities.setCapability("app", app.getAbsolutePath());
// Set appium server address and port number in URL string.
//AndroidDriver driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"),capabilities);
driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
//driver = (AndroidDriver)((new URL("http://127.0.0.1:4723/wd/hub"), capabilities));
driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);
}
}
In the above code, the line where I declare the URL is marked in RED and hovering over it shows me this message: "The type org.openqa.selenium.remote.http.HttpClient$Factory cannot be resolved. It is indirectly referenced from required .class files"
I have seen many answers asking to add required jar files; but I'm sure I have added all the jar files required. It would be great if anyone can point out the particular jar file I might have missed,if indeed that is the issue, so that I can download and add it separately.
I have seen other answers asking to remove and re-add the JRE system library or close and repair the project, etc. which did not work for me.
I have tried with eclipse-neon and eclipse-mars versions also.
Please ask for any details you need,
I'm blocked here for quite sometime,
help on this would be appreciated,
Thanks,
Rahul
I encountered similar exception while working on automation framework which was built to serve as a base framework for UI (Mobile and Web) and AIP automation. Technologies which I was using included selenium web driver and appium for UI and Mobile automation. This was maven project and I ended up having bunch of dependencies. When I spent a hell lot time investigating my exceptions, root cause I found was dependency conflict because there were lot of dependencies which included different version of same artifact. In this case dependency in conflict was "com.squareup.okhttp3" which i had defined explicitly in my POM and same dependency is part of selenium-java as well. Please try following solution and hopefully that should work:
Exception:
Exception in thread "main" java.lang.NoClassDefFoundError: okhttp3/ConnectionPool
at org.openqa.selenium.remote.internal.OkHttpClient$Factory.<init>(OkHttpClient.java:116)
at org.openqa.selenium.remote.http.HttpClient$Factory.createDefault(HttpClient.java:66)
at org.openqa.selenium.remote.HttpCommandExecutor.<clinit>(HttpCommandExecutor.java:47)
at io.appium.java_client.AppiumDriver.<init>(AppiumDriver.java:95)
at io.appium.java_client.android.AndroidDriver.<init>(AndroidDriver.java:94)
at nz.co.flexicards.automation.framework.common.Common.BaseMobile.main(BaseMobile.java:62)
Caused by: java.lang.ClassNotFoundException: okhttp3.ConnectionPool
at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 6 more
Process finished with exit code 1
Solution:
I removed the explicit dependency for okhttp3 from POM.xml
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>3.11.0</version>
<scope>test</scope>
</dependency>
Moved java-client (appium-io) dependency on top in dependency list in POM.xml
<dependency>
<groupId>io.appium</groupId>
<artifactId>java-client</artifactId>
<version>7.2.0</version>
</dependency>
try the below code before creating the driver object.
System.setProperty("webdriver.http.factory", "apache");
This requires
commons-validator.jar
which has set of methods to do common http and other user requests and validations.
And kindly update your selenium jar as 2.5x or more have come now
The problem got solved when I followed below steps,
Created a new project
Added Selenium (2.53.1), gson (2.2.4-sources) and javaclient(4.0.0) jars
Previously I added different version of java client jar; I did not add any gson jar before.
Maybe these changes solved my problem. (I'm not sure though)
Regards,
Rahul
This problem occured today.
I just switched the version of java-client from 5.0.0 to 1.2.1, and found the problem solved.
Hope this would be helpful.
Add the below maven dependency to your pom.xml to resolve the issue.
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-remote-driver</artifactId>
<version>3.4.0</version>
</dependency>
It might have problem with java-client jar.
After changing java-client-7.0.0 version to java-client-3.2.0 my problem is solved.
I removed all the externals libraries that I had, and then I add java-client/7.0.0.
It has anything that you need, then my project worked.
https://jar-download.com/artifacts/io.appium/java-client/7.0.0/source-code
Adding "selenium-remote-driver" solved the problem
appium , selenium, okhttp alltogether happily, please check my answer :
Appium throws an error because of the driver
First of all, thank you for your help.
Here is my problem.
I have made a custom system service (it does connect through the binder, and hooks into the system server, then into the HAL, etc). One of the main commands is isBacklightOn(). I also ran the make update-api to include it in my ROM build.
I am now ready to test the functionality using an app. I am using the following code:
import android.os.BacklightManager; //My service manager name
...
BacklightManager bm = (BacklightManager) getSystemService(BACKLIGHT_SERVICE);
...
if(!bm.isBacklightOn()) {
//Turn it on.
} else {
//Other Things...
}
My problem occurs because Android Studio will not build the application due to not knowing what the BacklightManager is. How can I build this application to test my code? (import something into Android Manager, force a build ignoring errors, etc.)
It looks like the solution is to build a custom SDK within the AOSP build environment. And then import that into Android Studio
Since Chrome has an awesome feature for remote debugging,
I am wondering how this could help in developing in Worklight.
In the following docs they say to debug the contents of your WebView, you need to enable it programmatically from within your application by calling setWebContentsDebuggingEnabled, a static method on the WebView class.
Where can I find this class and will this be beneficial to do it in Worklight?
https://developers.google.com/chrome-developer-tools/docs/remote-debugging?hl=nl#debugging-webviews
Please note that WebView debugging is only relevant for Android 4.4 "KitKat" and not to any prior version of the Android OS.
To debug your Chromium WebView in a Worklight application with the Android environment,
Open the Android SDK and update to API Level 19.
You will of course need either a device or emulator running this version.
Make sure that in yourAppName\android\native\AndroidManifest.xml you add support for targetSdkVersion=19.
<uses-sdk android:minSdkVersion="10" android:targetSdkVersion="19" />
Change the Build Target to Android 4.4:
Right-click on the generated Android project > Properties > Android > Build Target
Open yourAppName\android\native\src\com\yourAppName\yourAppName.java and
Import the following:
import android.os.Build;
import android.util.Log;
import android.content.pm.ApplicationInfo;
import android.webkit.WebView;
Add the following to the onCreate() function:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT){
if(0 != (getApplicationInfo().flags & ApplicationInfo.FLAG_DEBUGGABLE)){
WebView.setWebContentsDebuggingEnabled(true);
}
}
The rest of the steps are as described in the Google documentation page.
I don't have an Android device to verify this, so please try.
As for whether it is beneficial or not, another debugging alternative can't hurt. It is up to you to decide if it's good or not, for you.
I tried a example provided in the, Android app testing through Selenium, i have included the selenium-java library and android-webdriver apk also installed in emulator, but when try with the sample code provide in the forum i got error in AnroidWebDriver import, in selenium library only AndroidDriver class is available, so where could i get the AdroidWebDriver jar. Plz assit.
Note: Selenium library is very latest one.
import android.test.ActivityInstrumentationTestCase2;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.android.AndroidWebDriver;
import simple.app.SimpleAppActivity;
public class SimpleGoogleTest extends ActivityInstrumentationTestCase2<SimpleAppActivity> {
private WebDriver driver;
private WebDriver googledriver;
public SimpleGoogleTest() {
super("simple.app", SimpleAppActivity.class);
}
#Override
protected void setUp() throws Exception {
driver = new AndroidWebDriver(getActivity());
}
........................,,,,,
}
There are two variations of the Android Driver:
AndroidDriver() which you use on your Personal Computer e.g. your
laptop, workstation, etc. which provides the richest and most
complete set of capabilities for your tests.
AndroidWebDriver() which runs on your Android device, this wraps a WebView component to provide the basic core functionality.
The example code that comes with the Android SDK and the optional support for Selenium/WebDriver runs some basic tests on the device. The tests are compiled as an Android program which extend ActivityInstrumentationTestCase2. AndroidWebDriver() is contained in sdk/extras/google/webdriver/android_webdriver_library.jar (and the Javadocs are in sdk/extras/google/webdriver/android_webdriver_library-srcs.jar
So, if you want to run your tests on your Android device, then you need to include android-webdriver-library.jar in your project. Perhaps the simplest way is to copy this jar into your test project's libs folder.
However, if you would like to run your tests on your Personal Computer you can modify the example code to use AndroidDriver instead of AndroidWebDriver. You also need to change your base class e.g. to use Junit 3 or Junit 4. I have posted a sample test as an answer to another question on Stack Overflow here Having difficulty in finding Elements using Xpath and CSS in Selenium Android Webdriver Testing