So I am trying to use the built in testTool to generate some test for my mainActivity, so far I have managed to generate a test class and I got empty methods in it to test the methods of mainActivity. If I run the testClass with coverage I get this error:
Exception in thread "main" java.lang.NoClassDefFoundError: org/testng/TestNG
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:760)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at org.testng.RemoteTestNGStarter.main(RemoteTestNGStarter.java:117)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)
Caused by: java.lang.ClassNotFoundException: org.testng.TestNG
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 18 more
I'm not sure what this really means, there is a class that is not defined?
I might also add that I added:
task testClasses {
doLast {
println 'This is a dummy testClasses task'
}
}
in the build.gradle file for my sqlite module, otherwise I couldn't run any test at all.
I might also add that under Dependencies tab under Module settings, I do have "org.testng:testnb:6.9.6" set to "Test compile".
This is how my dependencies look in my gradle file:
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
androidTestCompile 'org.testng:testng:6.9.6'
compile project(':sqlite-jdbc-3.8.11.2')
compile 'com.android.support:appcompat-v7:23.3.0'
compile 'com.getbase:floatingactionbutton:1.10.1'
compile 'com.android.support:design:23.3.0'
compile 'com.github.PhilJay:MPAndroidChart:v2.1.6'
compile 'com.android.support:support-v4:23.3.0'
compile 'com.numetriclabz.numandroidcharts:numandroidcharts:1.0.13'
}
EDIT: I saw that Android studio also created an ExampleUnitTest file and If I add my testcases to this file and run them, it works just fine. The problem only seems to happen when I try to run the whole MainActivityTest class, but individual methods seems to be ok to test.
Check your module structure. Probably one of your high level module folders doesn`t have dependencies. (You can link modules together and everything should work).
Go to -> File|Project structure|Modules|*your module*|Dependencies.
It's not a TestNG issue, it's a module structure issue.
More detailed description Click This -> Link
Try changing
testCompile 'junit:junit:4.12'
to
androidTestCompile 'junit:junit:4.12'
Also, make sure you are running it as an Android Test.
Related
I'm new to creating a web application using Spring Boot with Gradle and I've been getting along alright, then all of a sudden without knowledge of what's changed, I can't run it as a Spring Boot app and I get a popup error that says "Error: A JNI error has occurred. Please check your installation and try again." I hit okay and then another popup occurs that says "A Java exception has occurred". I hit okay again and then the console reads:
Exception in thread "main" java.lang.NoClassDefFoundError:
javax/servlet/http/HttpServletResponse
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
at java.lang.Class.privateGetMethodRecursive(Class.java:3048)
at java.lang.Class.getMethod0(Class.java:3018)
at java.lang.Class.getMethod(Class.java:1784)
at
sun.launcher.LauncherHelper.validateMainClass(LauncherHelper.java:544)
at
sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:526)
Caused by: java.lang.ClassNotFoundException:
javax.servlet.http.HttpServletResponse
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)
... 7 more
I have import javax.servlet.http.HttpServletResponse; and I'm not getting any errors in the code until I compile so I know something is getting lost when I compile it. I've read about possible errors in the class path file? I'm not sure where that is or how to edit that. It's all new to me and I've just hit a brick wall. I've even downloaded other JARs to import and then I get the same error but for a different class and it's just an infinite loop of errors.
My build.gradle file looks something like this:
plugins {
id 'org.springframework.boot' version '2.1.5.RELEASE'
id 'java'
}
apply plugin: 'io.spring.dependency-management'
group = 'com.example'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '1.8'
configurations {
developmentOnly
runtimeClasspath {
extendsFrom developmentOnly
}
}
repositories {
mavenCentral()
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
developmentOnly 'org.springframework.boot:spring-boot-devtools'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
}
What other information will you need to assist me with this? Any pointers in the right direction would be greatly appreciated.
I created a plugin for kafka connect that implements SinkConnector, I packaged it into a jar using gradle jar task:
jar {
archiveName='name.jar'
}
I copy it into the kafka cluster in a folder, and I set CLASSPATH=where my jar is.
Then I execute the kafka script to start the standalone connect and it gives me an error saying that my class can't be found:
[2017-07-25 05:15:52,084] WARN could not get type for name mypackage.SplunkSinkConnector from any class loader (org.reflections.Reflections:384)
org.reflections.ReflectionsException: could not get type for name mypackage.SplunkSinkConnector
at org.reflections.ReflectionUtils.forName(ReflectionUtils.java:378)
at org.reflections.ReflectionUtils.forNames(ReflectionUtils.java:397)
at org.reflections.Reflections.getSubTypesOf(Reflections.java:367)
at org.apache.kafka.connect.runtime.PluginDiscovery.connectorPlugins(PluginDiscovery.java:76)
at org.apache.kafka.connect.runtime.PluginDiscovery.scanClasspathForPlugins(PluginDiscovery.java:70)
at org.apache.kafka.connect.runtime.AbstractHerder$1.run(AbstractHerder.java:354)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.ClassNotFoundException: mypackage.SplunkSinkConnector
at java.net.URLClassLoader$1.run(URLClassLoader.java:372)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at org.reflections.ReflectionUtils.forName(ReflectionUtils.java:376)
... 6 more
[2017-07-25 05:15:52,419] INFO Reflections took 1586 ms to scan 62 urls, producing 3002 keys and 15379 values (org.reflections.Reflections:229)
[2017-07-25 05:15:52,420] WARN could not get type for name mypackage.SplunkSinkConnector from any class loader (org.reflections.Reflections:384)
org.reflections.ReflectionsException: could not get type for name mypackage.SplunkSinkConnector
at org.reflections.ReflectionUtils.forName(ReflectionUtils.java:378)
at org.reflections.ReflectionUtils.forNames(ReflectionUtils.java:397)
at org.reflections.Reflections.getSubTypesOf(Reflections.java:367)
at org.apache.kafka.connect.runtime.ConnectorFactory.getConnectorClass(ConnectorFactory.java:69)
at org.apache.kafka.connect.runtime.ConnectorFactory.newConnector(ConnectorFactory.java:38)
at org.apache.kafka.connect.runtime.AbstractHerder.getConnector(AbstractHerder.java:334)
at org.apache.kafka.connect.runtime.AbstractHerder.validateConnectorConfig(AbstractHerder.java:233)
at org.apache.kafka.connect.runtime.standalone.StandaloneHerder.putConnectorConfig(StandaloneHerder.java:159)
at org.apache.kafka.connect.cli.ConnectStandalone.main(ConnectStandalone.java:93)
Caused by: java.lang.ClassNotFoundException: mypackage.SplunkSinkConnector
at java.net.URLClassLoader$1.run(URLClassLoader.java:372)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at org.reflections.ReflectionUtils.forName(ReflectionUtils.java:376)
... 8 more
Any idea why is not picking up my jar?
Thank you
================================
EDIT: Kakfa Connect version 10.2.1, as per script, classpath is calculated with: CLASSPATH="$CLASSPATH":"$KAFKA_HOME/libs/*"
Can you check your .jar file to make sure that class is there. Using Scala as a JVM shell:
// Or Maybe try $CLASSPATH with the full classpath that you are using.
scala -classpath path-to-jar.jar
// If class is not loaded, this will trigger an error.
classOf[mypackage.SplunkSinkConnector]
FYI, I am doing exactly this, using a custom .jar plugin with Kafka Connect loaded via the CLASSPATH environment variable.
UPDATE: Here is my build.gradle file for my plugin. IMO, this is the simplest way to build a Java .jar with some simple dependencies. I build the jar with gradle jar and it will be created at ./build/libs/(project-name).jar:
apply plugin: 'java'
apply plugin: 'idea'
sourceCompatibility = 1.8
repositories {
mavenLocal()
mavenCentral()
maven { url "http://packages.confluent.io/maven/" }
}
configurations {
all*.exclude group: 'org.slf4j', module: 'slf4j-log4j12'
all*.exclude group: 'log4j'
}
dependencies {
compile 'io.confluent:kafka-connect-storage-partitioner:3.2.1'
compile 'org.apache.kafka:connect-api:0.10.2.1'
testCompile 'junit:junit:4.+'
}
idea {
project {
languageLevel = '1.8'
}
}
I updated playservice in my sdk and I got this error. And I am not able to access GCM Token. Before update sdk my project work perfectly.
I waste my whole day in it but not found any solution. I tried this but gettting error in this dependencies com.google.android.gms:play-services-plus:9.0.0
Here is my logcat
Caused by: java.lang.IllegalAccessError: Method 'void android.support.v4.content.ContextCompat.<init>()' is inaccessible to class 'com.google.android.gms.iid.zzd' (declaration of 'com.google.android.gms.iid.zzd' appears in /data/data/com.hwindiapp.passenger/files/instant-run/dex/slice-com.google.android.gms-play-services-iid-9.0.0_b51865a18dbfbfb3651aaa54856c955adf1e354f-classes.dex)
at com.google.android.gms.iid.zzd.zzeC(Unknown Source)
at com.google.android.gms.iid.zzd.<init>(Unknown Source)
at com.google.android.gms.iid.zzd.<init>(Unknown Source)
at com.google.android.gms.iid.InstanceID.zza(Unknown Source)
at com.google.android.gms.iid.InstanceID.getInstance(Unknown Source)
at com.mainProfile.classFiles.RegisterFbLoginResCallBack$registerFBUser.processGCMID_user(RegisterFbLoginResCallBack.java:166)
at com.mainProfile.classFiles.RegisterFbLoginResCallBack$registerFBUser.doInBackground(RegisterFbLoginResCallBack.java:219)
at com.mainProfile.classFiles.RegisterFbLoginResCallBack$registerFBUser.doInBackground(RegisterFbLoginResCallBack.java:153)
at android.os.AsyncTask$2.call(AsyncTask.java:292)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:818)
12-01 12:23:59.553 18157-18703/com.hwindiapp.passenger E/ACRA: Not adding buildConfig to log. Class Not found : com.VolleyLibFiles.BuildConfig. Please configure 'buildConfigClass' in your ACRA config
12-01 12:24:00.013 18157-19059/com.hwindiapp.passenger E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #4
Process: com.hwindiapp.passenger, PID: 18157
java.lang.RuntimeException: An error occured while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:304)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355)
at java.util.concurrent.FutureTask.setException(FutureTask.java:222)
at java.util.concurrent.FutureTask.run(FutureTask.java:242)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:818)
Caused by: java.lang.IllegalAccessError: Method 'void android.support.v4.content.ContextCompat.<init>()' is inaccessible to class 'com.google.android.gms.iid.zzd' (declaration of 'com.google.android.gms.iid.zzd' appears in /data/data/com.hwindiapp.passenger/files/instant-run/dex/slice-com.google.android.gms-play-services-iid-9.0.0_b51865a18dbfbfb3651aaa54856c955adf1e354f-classes.dex)
at com.google.android.gms.iid.zzd.zzeC(Unknown Source)
at com.google.android.gms.iid.zzd.<init>(Unknown Source)
at com.google.android.gms.iid.zzd.<init>(Unknown Source)
at com.google.android.gms.iid.InstanceID.zza(Unknown Source)
at com.google.android.gms.iid.InstanceID.getInstance(Unknown Source)
at com.mainProfile.classFiles.RegisterFbLoginResCallBack$registerFBUser.processGCMID_user(RegisterFbLoginResCallBack.java:166)
at com.mainProfile.classFiles.RegisterFbLoginResCallBack$registerFBUser.doInBackground(RegisterFbLoginResCallBack.java:219)
at com.mainProfile.classFiles.RegisterFbLoginResCallBack$registerFBUser.doInBackground(RegisterFbLoginResCallBack.java:153)
at android.os.AsyncTask$2.call(AsyncTask.java:292)
Showing error in this line of code
InstanceID instanceID = InstanceID.getInstance(mContext);
GCMregistrationId = instanceID.getToken(CommonUtilities.SENDER_ID, GoogleCloudMessaging.INSTANCE_ID_SCOPE,
null);
And here is my gradle
apply plugin: 'com.android.application'
android {
signingConfigs {
config {
keyAlias 'hwindi'
keyPassword '123456'
storeFile file('D:/Company Projects/Hwindi/Project 2/Play_KeyStore/HwindiKeyStore.jks')
storePassword '123456'
}
}
compileSdkVersion 24
buildToolsVersion "24.0.3"
defaultConfig {
applicationId "com.hwindiapp.passenger"
minSdkVersion 16
targetSdkVersion 24
versionCode 12
versionName "1.12"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'lib/arm64-v8a/libcardioDecider.so'
exclude 'lib/arm64-v8a/libcardioRecognizer.so'
exclude 'lib/arm64-v8a/libcardioRecognizer_tegra2.so'
exclude 'lib/arm64-v8a/libopencv_core.so'
exclude 'lib/arm64-v8a/libopencv_imgproc.so'
exclude 'lib/armeabi/libcardioDecider.so'
exclude 'lib/armeabi-v7a/libcardioDecider.so'
exclude 'lib/armeabi-v7a/libcardioRecognizer.so'
exclude 'lib/armeabi-v7a/libcardioRecognizer_tegra2.so'
exclude 'lib/armeabi-v7a/libopencv_core.so'
exclude 'lib/armeabi-v7a/libopencv_imgproc.so'
exclude 'lib/mips/libcardioDecider.so'
exclude 'lib/x86/libcardioDecider.so'
exclude 'lib/x86/libcardioRecognizer.so'
exclude 'lib/x86/libcardioRecognizer_tegra2.so'
exclude 'lib/x86/libopencv_core.so'
exclude 'lib/x86/libopencv_imgproc.so'
exclude 'lib/x86_64/libcardioDecider.so'
exclude 'lib/x86_64/libcardioRecognizer.so'
exclude 'lib/x86_64/libcardioRecognizer_tegra2.so'
exclude 'lib/x86_64/libopencv_core.so'
exclude 'lib/x86_64/libopencv_imgproc.so'
}
configurations.all {
/*resolutionStrategy {
force 'com.android.support:design:23.4.0'
force 'com.android.support:support-v4:23.4.0'
force 'com.android.support:appcompat-v7:23.4.0'
}*/
}
}
repositories {
mavenCentral()
maven { url "https://jitpack.io" }
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile ('com.squareup:fest-android:1.0.8') {
exclude module: 'support-v4'
}
compile 'com.android.support:appcompat-v7:24.2.0'
compile 'com.android.support:design:24.2.0'
compile 'com.android.support:cardview-v7:24.2.0'
compile 'com.android.support:recyclerview-v7:24.2.0'
compile 'com.google.android.gms:play-services-gcm:9.0.0'
compile 'com.google.android.gms:play-services-location:9.0.0'
compile 'com.google.android.gms:play-services-maps:9.0.0'
compile 'com.google.android.gms:play-services-plus:9.0.0'
compile 'com.facebook.android:facebook-android-sdk:[4,5)'
compile 'com.paypal.sdk:paypal-android-sdk:2.13.3'
compile 'com.wdullaer:materialdatetimepicker:2.2.0'
compile 'com.mukesh:permissions:1.0.3'
}
Please check your declared dependencies. As discussed in the given documentation there are three different types of direct dependencies in the app/ module's build.gradle file.
Sample dependencies are as follows:
android {...}
...
dependencies {
// The 'compile' configuration tells Gradle to add the dependency to the
// compilation classpath and include it in the final package.
// Dependency on the "mylibrary" module from this project
compile project(":mylibrary")
// Remote binary dependency
compile 'com.android.support:appcompat-v7:25.0.1'
// Local binary dependency
compile fileTree(dir: 'libs', include: ['*.jar'])
}
Furthermore, as answered by #Diego Giorgini in a related SO post,
The issue you are experiencing is due to an incompatibility between
play-services / firebase sdk v9.0.0 and com.android.support:appcompat-v7 >= 24 (the version released with android-N sdk)
With this, you may want to try the suggested fix:
You should be able to fix it by targeting an earlier version of the support library. Like:
compile 'com.android.support:appcompat-v7:23.4.0'
You may want to also check the other suggestions in the following SO posts:
IncompatibleClassChangeError after updating to Android Build Tools 25.1.6 GCM / FCM
Android Google Cloud Messaging (GCM) token generation crash after Firebase-related Google Play Services update.
I had the same problem after some digging I found out that facebook sdk was depending on the new version of google support libraries than I have compiled on.
You can check the dependencies with gradle command
./gradlew app:dependencies
Ensure that all the dependency libraries has same version.
If not then you can exclude that dependency using
compile ('com.facebook.android:facebook-android-sdk:[4,5)'){
exclude module: 'support-v4'
exclude group: 'com.android.support'
}
then later add the required the dependency you have compiled your project on, In my case
compile 'com.android.support:support-v4:23.1.0'
Set a API version check of > 22 cause I got the same issue
java.lang.IllegalAccessError: Method 'void android.widget.ProgressBar.setProgress(int, boolean)' is inaccessible to class
and I fixed it like:
if (Build.VERSION.SDK_INT > 22)
progressBar.setProgress(currentProgress, true);
else
progressBar.setProgress(currentProgress);
check here setProgress Issue
I have Android Studio 2.3 and my problem was solved by uninstalling the "Android Support Library (Obsolete)" from SDK Tools.
I have created a simple Java program in IntelliJ ide. I used few libraries and when I try to export the jar as an artifact and run it from command line I get the following error:
Exception in thread "main" java.lang.NoClassDefFoundError: com/google/common/util/concurrent/FutureCallback
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2615)
at java.lang.Class.getMethod0(Class.java:2856)
at java.lang.Class.getMethod(Class.java:1668)
at sun.launcher.LauncherHelper.getMainMethod(LauncherHelper.java:494)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:486)
Caused by: java.lang.ClassNotFoundException: com.google.common.util.concurrent.FutureCallback
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
... 6 more
Compiling & Running the program inside IntelliJ works great.
My project is configured as a gradle project with the following build.gradle:
group 'marianpavel.com'
version '1.0'
apply plugin: 'java'
sourceCompatibility = 1.5
repositories {
mavenCentral()
maven {
url "http://repo.bastian-oppermann.de"
}
}
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.11'
compile 'de.btobastian.javacord:javacord:2.0.11'
compile 'ch.qos.logback:logback-classic:1.0.13'
compile 'de.btobastian.sdcf4j:sdcf4j-core:1.0.2'
compile 'de.btobastian.sdcf4j:sdcf4j-javacord:1.0.2'
compile 'org.jsoup:jsoup:1.9.2'
}
I have exported the jar as followed: Project Structure -> Artifacts -> Jar -> From Module with dependencies -> Added the main source folder and all the libraries from library files, added a manifest and a main class and exported the jar.
I am trying to figure this out for days and I don't understand why it cant find the class.
I think there is a misconception on your end.
Your project consists of two important parts:
Your own code
External libraries that your code is using
When you run your project within an IDE, and your project setup is correct, then both things are in your classpath.
But when you create a JAR for your project, it very much depends on your setup. Meaning: the "default" would be that a JAR created for your project only contains the "1." parts. Because you do not want that all external classes are added to "your" JAR in the first place.
So, to resolve that: when you want to run your program from your JAR on the command line, then you will need all those external JARs to be in your classpath as well! Because, as said: to run, you need both "1" and "2" parts to be present in the classpath.
Conclusion: you should check what gradle puts in the JAR it creates for you. I am pretty sure: that JAR only contains "1".
(and for the record, it is fine like that. it is possible to bundle everything into a single jar, but that will require work on your end)
Am performing a junit test on one of my methods in a class in android. and according to the info at http://code.google.com/appengine/docs/java/tools/localunittesting.html i should add the libraries below to my classpath.
${SDK_ROOT}/lib/impl/appengine-api.jar
${SDK_ROOT}/lib/impl/appengine-api-labs.jar
${SDK_ROOT}/lib/impl/appengine-api-stubs.jar
My question is, where in u.s should i get this libraries and how should i add them? am using android studio running on ubuntu 15 64bit.
am fairly new in android and GAE things!
what i have tried
this is what i have added to my modlue's build.gradle
dependencies {
testCompile 'junit:junit:4.12'
testCompile "org.mockito:mockito-core:1.9.5"
testCompile 'com.google.appengine:appengine-testing:1.8.2'
testCompile 'com.google.appengine:appengine-api-labs:1.8.2'
testCompile 'com.google.appengine:appengine-api-stubs:1.8.2'
testCompile 'com.google.appengine:appengine-tools-sdk:1.8.2'
testCompile 'org.json:json:20141113'
}
When i try to run my junit test class. this is what am getting
com.googlecode.objectify.SaveException: Error saving
com.top.ash.backend.entities.Ameggedon#589b3632: No API environment is registered for this thread.
com.googlecode.objectify.impl.EntityMetadata.save(EntityMetadata.java:95)
at com.googlecode.objectify.impl.WriteEngine.save(WriteEngine.java:75)
at com.googlecode.objectify.impl.SaverImpl.entities(SaverImpl.java:60)
at com.googlecode.objectify.impl.SaverImpl.entity(SaverImpl.java:35)
org.mockito.internal.runners.JUnit45AndHigherRunnerImpl.run(JUnit45AndHigherRunnerImpl.java:37)
at org.mockito.runners.MockitoJUnitRunner.run(MockitoJUnitRunner.java:62)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:78)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:212)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:68)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:140)
Caused by: java.lang.NullPointerException: No API environment is registered for this thread.
Note: I know nothing about GAE, but here is how you can add jars from folder to test classpath.
Create a new folder in the same directory as libs folder (in this picture it is called testlibs). In this directory you should put those jars.
Now, add to the build.gradle of the module (not of the project), inside dependencies block:
dependencies {
...
testCompile fileTree(dir: 'testlibs', include: ['*.jar'])
}
Now in your tests (Junit, not instrumentation) you could use the methods from the jar.