I am currently trying to integrate the Sign In functionality from aws into my android app. I followed all the instructions provided to me by AWS, downloaded and inserted there auto generated code, but still get an error.
Here is the Location:
...\app\src\main\java\com\amazonaws\mobile\user\signin\SignInManager.java
My Error:
(49, 15) error: cannot find symbol class CognitoUserPoolsSignInProvider
Auto generated code snippet that throws the error:
// Initialize Cognito User Pools SDK.
final CognitoUserPoolsSignInProvider cognitoUserPoolsSignInProvider =
new CognitoUserPoolsSignInProvider(context);
addSignInProvider(cognitoUserPoolsSignInProvider);
Where do I find this class and how do I integrate it in my app?
I tried googling for it, but I can't find anything relevant.
Thanks!
The getting started guide is not complete. I had the same problem.
You can find this class in the sample application of the User Sign-In step.
just add these dependencies and sync your project!
compile('com.amazonaws:aws-android-sdk-core:2.4.2')
compile 'com.amazonaws:aws-android-sdk-cognitoidentityprovider:2.4.2'
compile 'com.amazonaws:aws-android-sdk-cognito:2.4.2'
CognitoUserPoolsSignInProvider is ditributed as part of aws-android-sdk-auth-userpools library. Please import the following library and you should be able to do it.
compile ('com.amazonaws:aws-android-sdk-auth-userpools:2.6.+') { transitive = true; }
Now you can register this provider with the IdentityManager as follows:
IdentityManager.getDefaultIdentityManager().addSignInProvider(CognitoUserPoolsSignInProvider.class);
I've created an AIDL service called IHelloService and I am trying to call it from IOBridge under the libcore module.
Currently my code looks like this
// import
import android.os.IHelloService;
import android.os.ServiceManager;
....
IHelloService helloService = IHelloService.Stub.asInterface(ServiceManager.getService("hello"));
int val = helloService.getVal();
I run into errors when doing a standard build.
The errors include package android.os does not exist and cannot find symbol ServiceManager and IHelloService
I've already declared package android.os in the HelloService aidl file, so I don't think that's the issue.
Any help would be appreciated.
Sang,
Your issue is actually one I have been working through. What you need to do is build a new SDK for use with that specific service so that Android Studio (I am assuming that is what you are using) can recognize it as being available in your version of the ROM.
Here is what you should do: (found at https://android.googlesource.com/platform/sdk/+/master/docs/howto_build_SDK.txt)
Go to your Android build area and run . build/envsetup.sh
Run the command "make update-api" in your build area. This will update the files with the changes or additions you have made to the api.
Run "lunch sdk-eng" to set up the build for the sdk.
To make the SDK, run "make sdk". This could take some time (20m - 2hr), but will end with the line "Package SDK: out/host/darwin-x86/sdk/android-sdk_eng..zip"
Now that the SDK is made, you will need to point Android Studio to the new SDK. TO do this:
RIght click on your app, and select "Open Module Settings".
Choose "SDK" from the menu on the Left.
Select your new SDK path.
There might be other ways to do this, but that is the process I am working with currently.
I was trying to use opencv library, so I imported one of its projects in Android Studio and when I tried to run it I got this error:
Error:Execution failed for task ':openCVSamplefacedetection:compileDebugNdk'.
NDK not configured.
Download the NDK from http://developer.android.com/tools/sdk/ndk/.Then add ndk.dir=path/to/ndk in local.properties.
(On Windows, make sure you escape backslashes, e.g. C:\ndk rather than C:\ndk)
So I downloaded the ndk and I addes this line to the local.properties file where it became:
sdk.dir=C\:\\Users\\skoon\\AppData\\Local\\Android\\sdk
ndk.dir=C\:\\Users\\skoon\\AppData\\Roaming\\IDM\\android-ndk-r10d
but I still got this error which I didn't understand:
Error:Execution failed for task ':openCVSamplefacedetection:compileDebugNdk'.
com.android.ide.common.internal.LoggedErrorException: Failed to run command:
C:\Users\skoon\AppData\Roaming\IDM\android-ndk-r10d\ndk-build.cmd NDK_PROJECT_PATH=null APP_BUILD_SCRIPT=C:\Users\skoon\Downloads\Compressed\OpenCV-2.4.10-android-sdk\OpenCV-2.4.10-android-sdk\samples\face-detection\openCVSamplefacedetection\build\intermediates\ndk\debug\Android.mk APP_PLATFORM=android-14 NDK_OUT=C:\Users\skoon\Downloads\Compressed\OpenCV-2.4.10-android-sdk\OpenCV-2.4.10-android-sdk\samples\face-detection\openCVSamplefacedetection\build\intermediates\ndk\debug\obj NDK_LIBS_OUT=C:\Users\skoon\Downloads\Compressed\OpenCV-2.4.10-android-sdk\OpenCV-2.4.10-android-sdk\samples\face-detection\openCVSamplefacedetection\build\intermediates\ndk\debug\lib APP_ABI=all
Error Code:
2
Output:
make.exe: *** No rule to make target 'C:\Users\skoon\Downloads\Compressed\OpenCV-2.4.10-android-sdk\OpenCV-2.4.10-android-sdk\samples\face-detection\openCVSamplefacedetection\build\intermediates\ndk\debug\obj/local/arm64-v8a/objs/detection_based_tracker/C_\Users\skoon\Downloads\Compressed\OpenCV-2.4.10-android-sdk\OpenCV-2.4.10-android-sdk\samples\face-detection\openCVSamplefacedetection\src\main\jni', needed by `C:\Users\skoon\Downloads\Compressed\OpenCV-2.4.10-android-sdk\OpenCV-2.4.10-android-sdk\samples\face-detection\openCVSamplefacedetection\build\intermediates\ndk\debug\obj/local/arm64-v8a/objs/detection_based_tracker/C_\Users\skoon\Downloads\Compressed\OpenCV-2.4.10-android-sdk\OpenCV-2.4.10-android-sdk\samples\face-detection\openCVSamplefacedetection\src\main\jni\DetectionBasedTracker_jni.o'. Stop.
I didn't change anything in the code, so what should I do? do I need to change or add any variables to point to the ndk?
P.S. This is my first time trying to build Android application so I don't have any experience.
Thank you in advance.
UPDATE:
To import the project I just used import project from file, then I synced the gardle, and run the project.
the package that I downloaded from opencv was the Android one, and I tried to use the face detection sample.
when I run it I got the error above.
You need to setup OpenCV librairies for your project. You can follow the instruction here.
OpenCV sample projects haven't support gradle officially. I think it will be easier if you start a new project and configure it to work as in examples.
I have implemented a tutorial project using Android Studio + NDK + OpenCV. You may have a look. https://github.com/quanhua92/NDK_OpenCV_AndroidStudio
Install NDK in your SDK manager, if you already installed open app's "build.gradle" replace these lines
sourceSets { main { jni.srcDirs = ['src/main/jni', 'src/main/jniLibs/', 'src/main/jni/'] } }
to
sourceSets.main {
jniLibs.srcDir 'src/main/jniLibs' // mention your JNI lib path(where ".so" files contains)
jni.srcDirs = [] //disable automatic ndk-build call
}
I'm tried to configure OpenCV and its fixed
I've setup my Play Framework 1.2.1 project to run from within IntelliJ using the instructions from the following post on Google groups:
http://groups.google.com/group/play-framework/msg/54cfe212cbae218e
However, following the tutorial at http://www.playframework.org/documentation/1.2.2/guide8, I'm getting the following error from the IDE:
/Library/WebServer/Documents/devschool.play/app/controllers/Security.java
package Secure does not exist
/Library/WebServer/Documents/devschool.play/app/controllers/Application.java
cannot find symbol class Secure
When I run the application with > play run, everything works fine, but I prefer running it from the IDE. Please note that the project was running perfectly from the IDE before I added the secure module.
Is there a way to fix this? I have a hunch it's to do with an external source, but not being a Java expert, I'm not entirely sure how to do this.
Can anyone please assist?
You should run the following commands:
play dependencies
play idealize
The first one will resolve the dependencies from the Secure module.
The second will update the IntelliJ "classpath" and the red lines/errors regarding the Secure module will disappear.
Okay, so the project is compiling and running okay after unchecking the "Make" checkbox from the Edit Configurations dialog box.
To get the IDE to find the code, you simply need to Attach Sources. On the Mac, press Command + ; and add the sources under the Libraries section.
From the second link you posted, there is a class called Security, it looks like this:
public class Security extends Secure.Security {
static boolean authenticate(String username, String password) {
return true;
}
}
Security extends Secure.Security, which is another class named Security in the Secure package. This error is saying that it cannot find the package Secure. Make sure you are including everything in your classpath properly.
Make sure you run play idealize after adding modules to dependencies.yml or adding dependencies to the application.conf(which is deprecated by the way)
Adding modules in application.conf is deprecated and shouldn't be used anymore. Instead use dependencies.yml and add
- play -> secure
So now my dependencies.yml looks like:
# Application dependencies
require:
- play
- play -> secure
I then ran:
play dependencies
play idealize
and there was a delay but eventually Intellij recognized the module. Not sure exactly if the last commands were necessary.
(Reposting an answer by Sascha Kleiber from the relevant page of the Play tutorial: http://www.playframework.org/documentation/1.2.4/guide8)
In my Android app, I always get VerifyErrors! And I cannot figure out why. Whenever I include a external JAR, I always get VerifyErrors when I try to launch my app (except for once, when I included Apache Log4j.)
I usually get around this by taking the source of the library and adding it to my project, but I am trying to put the GData client library.
I can get this in source, but it's dependencies (mail.jar, activation.jar, servlet-api.jar) I cannot, so I get verify errors. I would like to get to the root of this problem once and for all. I looked on the internet, but they all seem to talk about incomplete class files? which I do not know of.
Look at LogCat and see what's causing the verifyerror. It's probably some method in a java.lang class that is not supported on the android SDK level you are using (for instance, String.isEmpty()).
From android-developers:
The output from "adb logcat" indicates the class that could not be
found as well as the class that has the bad reference. The location
is identified down to the specific Dalvik instruction. The trick is
to look in the logs above the exception.
Android uses a different class file format. Are you running the 3rd party JAR files through the "dx" tool that ships with the Android SDK?
To make it work you need to add jar of the library to one of the source folders (even if you have already added it as eclipse library, you still need to add it as source).
Create a directory in your project
(e.x. "libs") and put library jar
there.
Add the directory to the build class
path by (click right button on the
folder and select "Build path"->"Use
as source folder").
Rebuild your project.
It happened to me right now.
The error was caused because I was using methods from a newer SDK that my device had.
Android 1.5 device installed an apk using this:
<uses-sdk android:minSdkVersion="3" android:targetSdkVersion="4"/>
I found an interesting case. I use:
<uses-sdk
android:minSdkVersion="9"
android:targetSdkVersion="18" />
So some of new Android 4 capabilities are not implenented in Android 2.3 like ImageView.setLayerType. To avoid runtime error simply:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
setLayerType(View.LAYER_TYPE_SOFTWARE, null);
}
This approach should be used also with exceptions handling:
} catch (NetworkOnMainThreadException nomte) {
// log this exception
} catch (SocketTimeoutException socketTimeoutException) {
// log this exception
}
NetworkOnMainThreadException is not implemented in Android 2.3 so when the class is loaded (and not before!) the exception java.lang.VerifyError occurs.
If you're using Retrolambda you might have added a static method to an interface (which is only allowed in Java 8).
This can also occur because of referencing limit error on Lollypop below versions, where it is limited upto max 65K size
Possible solution for above issue
Step1: Add android-support-multidex.jar to your project. The jar can be found in your Android SDK folder /sdk/extras/android/support/multidex/library/libs
Step2: Extend your application with MultiDexApplication, for e.g.
public class MyApplication extends MultiDexApplication
Step3: Override attachBaseContext
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
Step4:
The next step is to add the following to the android part of your apps build.gradle
dexOptions {
preDexLibraries = false
}
Step5:
Lastly, following to the general part of your apps build.gradle
afterEvaluate {
tasks.matching {
it.name.startsWith('dex')
}.each { dx ->
if (dx.additionalParameters == null) {
dx.additionalParameters = ['--multi-dex']
} else {
dx.additionalParameters += '--multi-dex'
}
}
}
For details, please checkout
https://developer.android.com/tools/building/multidex.html
In my case, it happened when I updated from Eclipse Indigo to Eclipse Juno: I'm not sure what is the true reason, but, my Android project that I'm working on for a long time stopped work because of that exception.
After many hours of trying to fix that, I found the solution for me.
In my Android project, I use other project (say, "MyUtils") that is in the same workspace. So, I needed to do the following:
Right click on Android project -> Build path -> Configure build path
Now, go to tab "Order and Export" and make "MyUtils" checked. That's it: I got rid of this annoying exception.
I downgrade gradle version from 2.0.0-alpha2 to 1.5.0 that solved this problem.
The problem could also be caused by a mismatch between two androids projects. For example if you have developed an android library using the package "com.yourcompany", Then you have the main application's project using the same package as base package. Then let say you want to change the version of your main app, so you change the manifest file's values: Version Code and Version name. If you run your app without changing those values for the library, you would get a verify error on any call of a method on a object from the library.
I had the same issue. I was building with 2.1 r1 and updated to 2.1 r3 with the new adt 17. I had verify errors on javamail's mail.jar and it was driving me crazy. Here is how i solved the issue:
created a libs/ folder and added the jars.
right click > add as source folder
i tried a rebuild and it failed. I removed the libs/ directory as a source folder and removed refs to the 3 jar files in the build path. Then i added the libs/ folder again, and added each jar in the libs/ folder to the build path. Now it works as expected. This is a weird workaround but it worked for me.
In Eclipse 4.x, if you encounter this problem, try below:
migrate all included 3th-party jars into the User-Libaray
move up the user lib before the android lib and check it in the Order and Export tab
clean and rebuild to run
I have this issue after a SDK update. The compiler had problems with my external librarys. I did this: right click on project, then "android Tools > add suport library..." this install on my project library "android-support-v4.jar".
java.lang.VerifyError means your compiled bytecode is referring to something that Android cannot find at runtime. This verifyError Issues me only with kitkat4.4 and lesser version not in above version of that even I ran the same build in both Devices. when I used jackson json parser of older version it shows java.lang.VerifyError
compile 'com.fasterxml.jackson.core:jackson-databind:2.2.+'
compile 'com.fasterxml.jackson.core:jackson-core:2.2.+'
compile 'com.fasterxml.jackson.core:jackson-annotations:2.2.+'
Then I have changed the Dependancy to the latest version 2.2 to 2.7 without the core library(when I include core2.7 it gives the verifyError), then it works. which means the Methods and other contents of core is migrated to the latest version of Databind2.7. This fix my Issues.
compile 'com.fasterxml.jackson.core:jackson-annotations:2.7.0-rc3'
compile 'com.fasterxml.jackson.core:jackson-databind:2.7.0-rc3'
I get the VerfiyError as well... can't find a real reason. It helps to wrap the new lines of code into a method (Eclipse, 'Extract Method...'). So in my case the reason is not an unsupported method.
I had very similar problem. I had added Apache POI jars and problem appeared when I updated to android SDK 22.3.
I had Android Private Libraries checked so this was not the common problem with android SDK. I unchecked all Apache POI jars and added one by one. I found that poi-3.9-20121203.jar should be before poi-ooxml-3.9-20121203.jar. Otherwise it will not work.
If you have tests, try commenting out this line from your build.grade file:
testCoverageEnabled = true
For me this caused VerifyError exceptions on classes which use Java 1.7 features, particularly string switch statements.
I had the same problem after making a git pull.
Solution: Build -> Clean Project.
Hope this helps.
I have found another case.
Conditions:
Use Retrolambda (not sure if it's necessary);
Make a static method in an interface.
And the result is boom! java.lang.VerifyError when trying to access the class that uses that interface. Looks like Android (4.4.* in my case) doesn't like static methods in interfaces. Removing the static method from interface makes VerifyError go away.
I also had this problem, as had my jars in a user library...
The way I solved this was to add them to the lib folder and then add them in the build properties in eclipse...
The first time i did this it did not work, but then i removed them and readded them again and it started working...
bit of a strange one! but now working all the time.
Good Luck
I have coded Android API methods/class that are in SDK 2.1, and was trying to run it on Android 1.6 emulator. So i got that error.
SOLUTION:
Changed it to correct emulator version.
THIS WORKED FOR ME.. Thanks.
For posterity, I just got this error because I was using Arrays.copyOf() which is not a method supported by Java 1.5 which corresponds to Android Level 4. Because I was running including libraries developed under 1.6 they compiled fine. I only saw the problems when I moved the class in question over to my Android project -- then the error was highlighted.
Uncaught handler: thread main exiting due to uncaught exception
java.lang.VerifyError: com.j256.ormlite.dao.BaseDaoImpl$DaoConfigArray
at com.j256.ormlite.dao.BaseDaoImpl$1.initialValue(BaseDaoImpl.java:71)
at com.j256.ormlite.dao.BaseDaoImpl$1.initialValue(BaseDaoImpl.java:1)
at java.lang.ThreadLocal$Values.getAfterMiss(ThreadLocal.java:429)
at java.lang.ThreadLocal.get(ThreadLocal.java:66)
On that line I was trying to do a new DaoConfigArray and that class had the following line:
// copyOf is only supported in Java >= 1.6
doArray = Arrays.copyOf(daoArray, newLength);
What made it even more complicated is that line 71 was pointing to a ThreadLocal initialization which I thought was the reason for the problem initially.
private static final ThreadLocal<DaoConfigArray> daoConfigLevelLocal
= new ThreadLocal<DaoConfigArray>() {
#Override
protected DaoConfigArray initialValue() {
return new DaoConfigArray();
}
};
I had to remove dependent projects and instead compile dependent projects are jar's and include them in the libs folder.
I'm sure that my cause was different than yours, but since this is one of the top hits when searching for "Android java.lang.VerifyError", I thought I'd record it here for posterity.
I had some classes along the lines of:
public class A { ... }
public class B extends A { ... }
public class C extends A { ... }
And a method that did:
A[] result = null;
if (something)
result = new B[cursor.getCount()];
else
result = new C[cursor.getCount()];
// Fill result
...
As long as this code was present in the file, I would get a VerifyError the first time the class containing this method was loaded. Splitting it out into two separate methods (one that dealt only with B's, and one that dealt only with C's) fixed the problem.
In my case, this error occur because my google-play-service is not the newest.
If your project does not support some class in the .jar, this error occurs(ex. ImageView.setLayerType, AdvertisingIdClient, etc.).
I just identified another situation that it occurs, not only due to libs not dx'ed.
I have a AsyncTask with a very long doInBackground mehtod. For some reason this method with more than 145 lines started to break.
It happened on a 2.3 app.
When I just encapsulated some parts into methods, it worked fine.
So for those that could not find the class that was not correctly dx'ed, try reducing the length of your method.
For me, the issue ended up actually being that I was using multi-catch clause somewhere in the class which is a Java 7 feature (and API 19+). So it would crash with VerifyError on all pre-19 devices.
For me it was in correlation between compileSdkVersion and buildToolsVersion. I had:
compileSdkVersion 21
buildToolsVersion '19.1.0'
I changed it to:
compileSdkVersion 21
buildToolsVersion '21.1.2'
For me, it is the problem of compileSdkVersion. When I used the API level 21 in a specific android application (https://github.com/android10/Android-AOPExample):
compileSdkVersion 21
the java.lang.verifyerror happened. So I changed the compileSdkVersion to 19
compileSdkVersion 19
It worked well. I think that it might be the problem of SDK buildTools, and it seems OK when API level < 21.