Unable to load class com.android.build.gradle.managed.NdkConfig$Impl - java

I just upgraded to AS 2.0 Preview 8 and I'm trying to build my old project. I updated it to be
classpath 'com.android.tools.build:gradle-experimental:0.6.0-alpha8'
and updated the gradle-wrapper.properties to use gradle-2.10-all.zip, but when I try to build my project I get a Java stactrace saying:
Unable to load class com.android.build.gradle.managed.NdkConfig$Impl
I'm using Java 8 to start AS as well as having that set as the JDK for the project. I was also having the same problem with Java7. What am I missing?

The problem with my project was due to a change in the gradle-experimental plugin:
+= no longer works for collections. Adding items to the list can be done with the 'add' or 'addAll' method. e.g. CFlags +=
"-DCUSTOM_DEFINE" can be replaced with CFlags.add("-DCUSTOM_DEFINE")
Changed those occurrences and the build finished successfully.

Oddly enough, this was fixed by simply doing a Gradle clean. Hope this helps someone else as this was not intuitive

Related

Android Studio 3.1.3 - Unresolved reference: R - Kotlin

I am new to kotlin, i have converted some code from java but it seems like there's something wrong, The R in findViewById(R.id.my_id) is highlighted in red and it shows this message : "Unresolved reference: R".. I've been looking for a solution but i seem not to figure it out, So what should i do?
Here's a screenshot :
The issue can be caused by many factors,
as mentioned by martomstom in this Answer the issue is sometimes caused by com.android.tools.build:gradle version, changing it's version to a more stable one would solve the problem: for example: com.android.tools.build:gradle:3.4.0-alpha02 with com.android.tools.build:gradle:3.2.1
Also, having libraries from the same group, but with different versions may cause the problem or even more runtime errors. use the exclude group method like the following : implementation('com.squareup.picasso:picasso:2.71828') { exclude(group: 'com.android.support') } in this case, picasso library uses android.support components, the android library version used in picasso is different than the one you're currently using in your app, so in order to solve this issue, we have to exclude it completely from its sub library and class groups.
It can also happen by the mismatch of resources and code, including this importation line in your activity may solve the problem too : import com.package.name.R
Sometimes it can happen because of the IDE, performances or memory.. Cleaning the project from time to time may save you some time, on Android Studio it would be something like this : Build -> Clean Project / Rebuild Project - Cleaning IDE cash also helps with performance and memory, on Android Studio it would look like this : File-> Invalidate Chases/ Restart -> Invalidate Cashes and Restart
I noticed that this problem happens to me the most of the time when importing new resources, Using prohibited characters in their names would fire the error, such as . , , - , UpperCase or special Letters
And as a suggestion , if you're using Kotlin, i really recommend using Kotlin extensions in your activity such as : import kotlinx.android.synthetic.main.activity_page.* or if you're using a custom view : kotlinx.android.synthetic.main.view_layout.view.*
after that, in onCreat() method of an activity , you'll only have to call the id, for example : my_edit_text_ID.text = "Kotlin Dbest!", or from a custom view : mCostumView.my_edit_text_ID.text = "Kotlin Dbest!"
EDIT :
I have faced this issue againe and the problem was the '' R '' library was imported from 2 different sources :
com.android.R
com.example.package.R
You must only import the '' R '' library with your application package name,
in this case com.example.package.R
Sometimes the library is not imported at all, to import it, click on the
unresolved reference R and press Alt + Enter
EDIT:
As tobltobs mentioned in the comments section: " Most of the time the problem is caused by another error which prevents the build system from creating generated sources. To find the root cause look at the gradle log (the "toggle view" icon below of the green hammer in the Build output) and look for errors unrelated to R or BuildConfig (also generated). If there is no other error left and the problem with R persists then maybe something of this list might help. "
EDIT:
As Patrick Beagan mentioned, Kotlin extensions are now deprecated - I'd advise using ViewBinding instead
I used com.android.tools.build:gradle:3.3.0-alpha13 and had the same issue. Changing to stable Version 3.2.1 solved this problem for me.
So this is a misleading error.
The fastest way to get to the root cause is to run:
bash gradlew assembleDebug --debug
then scroll up and look for the real error happening.
However, if it still doesn't seem like you have the answer you are looking for, then read on.
I'm going to explain the 30,000 foot view of what is happening. This is not EXACT order or EXACT flow, it is just pretty damn close ;) so if you know more then I do of the exact order and care to make corrections with links, feel free I won't stop ya :).
The Process
The R file is generated code.
There is an order to the generation.
Gradle will do it's magic, pull it's dependencies and kick off it's
warning and error tree first,
then Android converts all Kotlin to Java behind the scenes. Yup that's
right, our beloved Kotlin still has to be Java to compile for our
beloved ART virtual machine.
Then it runs through and does the adapters that you have created for
JVM Statics and a few other tasks.
Next up it compiles all the xml databinding files first to create the
generated databinding files.
If everything succeeds it moves on to processing the assets and
resources. Which creates pointers or IDs for each resource that you
reference in code. Next it will run through and begin compiling the
code and packaging process after that.
Pretty straight forward process, but here in lies the problem.
The misleading Error
If any step fails before the R generation is complete, then the R does not get generated. Sometimes a simple rebuild is all you need to do, sometimes a simple File->Invalidate Cache and Restart is all you need. However, more often than not you have a code issue in your gradle, your xml, your databinding or your adapters that are preventing the compiler from even reaching the R generation stage.
So the next question is
"Well shoot, how do we troubleshoot it if the errors are worthless or
non-existent".
Well first let's talk about the many ways these errors present themselves.
Duplicate Databinding class found
xml Binding Error at line #
Couldn't find matching signature of bind:customAdapterMethod
Can't find R file of the correct project, only shows import options for sub modules or incorrect namespace R files.
Couldn't find DataBindingUtility or DataBinding for activity/fragment
And many other various ways as well, too many to list them all
Next, let's talk about potential candidates causing the problem. As there are sooo many lol.
Gradle Syncing issues
Bad versions of Gradle or Tools, you may have gone too far forward in your last gradle file modification. Try stepping back one version and "invalidate cache and restart" if that fixed it, great, if not, read on.
Caching Issues (File->Restart and Invalidate Cache)
xml elements with wrong namespace
xml elements with bad IDs or references IDs out of order (i.e. you say align to right of an element that is lower in the xml document then the sibling element that is trying to reference it)
xml data binding issues referencing namespace or member that doesn't exist or is not typed correctly
xml data binding issues in non-auto-filled spots like custom attributes using adapters as those are harder to spot. i.e. bind:myCustomMethod=#"myObject.mistypedProperty()"
JVM Static adapters with issues or duplicated signatures
Duplicated or bad character in the Strings or Dimens file or any other xml file for that matter
Private variable marked for #Binding without properties to access it
Member variable marked for #Binding that matches a parent class method causing duplications that manifests itself in almost impossible errors
Mismatch of types like using an adapter that takes (Int) but you are passing (Int?) via data binding and it isn't recognized with JVM Statics until compile time
You selected IMPORT on a popup to import R file of a sub module instead of the application file
Having bindable members in a child or parent class, but not giving fully qualified namespace to class cast in the XML usage of the parent or child class. As the databinding compiler is not smart enough to realize the variable provided for class Foo is also parentFoo baseclass, so you have to qualify it as android:text="#((com.path.parentFoo)foo).parentMethod"
Having a method name in a class, that matches a "generated property from #Binding member variable" i.e. firstName as a variable, but then having a method called getFirstName in a parent or child class, because you are now matching a method name that will get auto generated, thus causing dataBindingUtility duplication class errors.
There are more causes, but this should give you a series of places to look, but the list can go on and on seriously.
Unfortunately this happens a lot in bleeding edge technologies where the UI tools are not up to speed with the terminal based tools yet. So I suggest you run from the project root in a terminal with
bash gradlew assembleDebug --debug
When it fails, and it will. Start scrolling up through the logs until you find the red where you see what is actually failing and preventing the next stage from occurring.
You will find this especially useful when you start dealing with databinding.
TIP:
When you start dealing with databinding, make sure you compile and run often because the goal is to recognize right away before doing other files to make sure you didn't break generation and make your life MUCH easier to know code you just added caused the issue before getting too far.
Times to compile and run to confirm no issues before moving on.
If you add a few JVM statics compile and run
If you add variables to your XML to use
If you bind to properties of your model in 1 file
If you add a binding to a JVMStatic
If you add bindable members or properties to an model
If you refactor moving observable member variables or properties into children or base classes
Any other xml or binding related elements that can effect the generated code.
Like I mentioned above, the reason is to avoid getting so many changes, that it becomes a troubleshooting nightmare to find a generic vague, horrible error related to generated databinding code. I'm sure the tools will improve, but for now, do yourself a favor and compile and run often when changing Databinding related items.
Happy Coding
Use gradle commands.
In Android Studio, on the right menu:
Gradle -> :app -> Tasks -> build -> clean.
After that, Gradle -> :app -> Tasks -> build -> build
I had wrong import statement import android.R instead of import my.project.package.R. Fixing it solved the problem
I had the same problem, and I tried not to downgrade from gradle version 3.3 to gradle version 3.2.1. Instead I updated Android Studio to version 3.3, which made the trick for me ;-)
This worked for me. How much work it is depends on how big your project is. I started a new project, created the required modules (XML, Kotlin, colors, strings, etc.), then copied the code into the modules in the new project from the modules in the old project. Copying XML saves a lot of time compared to recreating the UI. All in all, it take a little while, but I have spent much more time tring to fix the unresolved reference error without it.
TRY THIS
Go to the content_main.xml file and there you need to change the
android:id="#+id/??????"> line of code to whatever id you have given to your file.
Replace question mark ?????? with the related file id name.(IF you dont know the id go to the design tab on the bottom and click on the related Asset.
On the right side below attributes, you can find the ID you have given to it.
If it is blank you can freshly name it and Android Studio will write the code.
Then restart Android Studio. Hope this will help. Happy coding.
I believe that I came across the real answer (though by accident).
I also, as the OP had my KT file fail to location R. as well as other classes that happen to be in java. What I noticed was that there was a case difference I the filenames. Once I corrected the import statements to match the case of the package (aka, folder) the errors resolved.
I had the same problem with R reference too.
Finally Android Studio 3.3 has been released and using 'com.android.tools.build:gradle:3.3.0' the problem has been fixed!
I update Android Studio to version 3.3.1 and solved this problem.
Downgrading gradle version worked for me.
I changed :
Gradle version from : 4.10.4 to 4.4.1
and Gradle Plugin version from : 3.3.1 to 3.1.3
If your are experiencing this issue in Kotlin because you cannot reference the elements of the xml layout by ids. (e.g. R.id.adView) then try removing the line import android.R from your kotlin file.
For me it was because I had created a new package and R wasn't available until I imported it from the package above
I faced the same issue. I restarted my Android Studio, invalidate caches, Sync Gradle but nothing was working. Then I looked into my file and there are 2 imports of my R. 1 import was related to my application package and the other was related to Android.
import com.example.myApp.R
import android.R // This import was added accidentally during the build.
Removing second import related to android solved this issue.
I had an issue because of this import:
import android.os.Build.VERSION_CODES.*
In the latest version it contains R
I had same problem while using auto-manifest plugin. Adding AndroidManifest.xml explicitly solved the problem to me.
I used to File --> Invalidate Caches... and issue resolved.
Just restarting Android Studio solved it for me.
I also had this problem, Gradle Sync, and Invalidate Cache, and Restarting Android Studio Didn't help. Upgrading and Downgrading Gradle were also not helpful.
What worked for me is: Make Project (Ctrl + F9) and then try to run the project.
I solved this error by following Android Studio's lint tools to upgrade the version of a dependency in the project-level gradle file. In this case, I upgraded androidx.navigation:navigation-safe-args-gradle-plugin from 2.3.2 to 2.5.2 (latest version), then synced the project.
Here is the solution,
File->Project Structure->Project, select Android Gradle Plugin Version as 3.2.1 from the drop-down. then click apply.

Run demo of JBullet in IntelliJ

Has anyone successfully run demo of JBullet in IntelliJ?
When I run the demo using the ant build script, i found a mistake like this :
C:\Users\halin_000\ProgrammingProjects\Java\CS351L\JBullet\build.xml:77:
java.lang.IllegalStateException: first parameter of Stack.alloc(Class)
must be constant (in class
com.bulletphysics.collision.dispatch.ConvexConcaveCollisionAlgorithm,
method processCollision)
How do you solve the problem?
I ran into the same issue today. I used to be able to build jbullet a few years ago and I had the source put under version control back then.
It turns out building with a Java 7 compiler (from jdk1.7.0_79) works fine while building with a Java 8 compiler (from jdk1.8.0_101) fails with the message the OP reported.
I suppose a more definitive solution would be to update the vecmath library to satisfy the higher standards of a Java 8 compiler, but in the meantime I have reverted my toolchain to a state where I can get going.
Update 2016-10-08 22h30 EDT
Not satisfied of reverting my toolchain to Java7, I have dwelved a bit deeper into this issue and traced it to JStackAlloc, not vecmath as I previously thought.
It would seem compiling with Java8 adds more instruction nodes to the bytecode where there was none before. Specifically, LineNumberNode and LabelNode are being added between LdcInsnNode and MethodInsnNode.
JStackAlloc is looking for the later two but is not expecting to find the extra two nodes. It is easy to fix the library to skip these extra nodes and carry its job despite their presence.
Starting from a maven'ized build of jbullet, here is the diff required to make it work again.
Note that the Javadoc build of this release seems to be broken. It can be disabled by commenting out the jar goal of the maven-javadoc-plugin in the pom.xml config file.

Cannot resolve com.parse.ParseQueryAdapter

My current setup :
OS : windows 7
IDE : Android Studio (with updated SDKs)
Parse jar (v 1.10)
I am trying out an example for ParseQueryAdapter, and I run into this error on my IDE : import com.parse.ParseQueryAdapter; -> cannot resolve symbol ParseQueryAdapter
I want to try something similar to this example, and the import does not seem to go through because of the error.
If you need anymore information, please leave comments & I will respond.
PS : I am able to add com.parse.ParseObject without errors.
In your libs folder you'll find Parse-1.4.1.jar file.
Right click or control+click on it then 'Add as Library...'
Edit: Parse-1.10 does not have ParseQueryAdapter. You have to use Parse-1.4.1, which is included in that example.
ParseQueryAdapter was removed from the official Parse SDK and moved onto the Parse-UI libraries..
You can install them on via this link: https://github.com/ParsePlatform/ParseUI-Android
If we include 1.4.1, and keep 1.10.1 as well, it gives error because we cannot keep the same jar with two versions in the libs folder. And I think its not advisable to use just 1.4.1. I feel that ParseQueryAdapter is deprecated and we would just have to use the normal adapters. Any comments?

com.android.ant.SetupTask cannot be found

I would need to build one android app from command line. I successfully compiled its jni part, but cannot build Java part. ant prints the following (paths have been removed):
/.../build.xml:69: taskdef class com.android.ant.SetupTask cannot be found
using the classloader AntClassLoader[/path/to/sdk/tools/lib/ant-tasks.jar:/path/to/sdk/tools/lib/manifest-merger.jar:/path/to/sdk/tools/lib/common.jar:/path/to/sdk/tools/lib/guava-13.0.1.ja r:/path/to/sdk/tools/lib/sdklib.jar:/path/to/sdk/tools/lib/layoutlib-api.jar:/path/to/sdk/tools/lib/kxml2-2.3.0.jar:/path/to/sdk/tools/lib/dvlib.jar:/path/to/sdk/tools/lib/bcpkix-jdk15on-1.4 8.jar:/path/to/sdk/tools/lib/commons-compress-1.0.jar:/path/to/sdk/tools/lib/httpclient-4.1.1.jar:/path/to/sdk/tools/lib/httpmime-4.1.jar:/path/to/sdk/tools/lib/bcprov-jdk15on-1.48.jar:/path /to/sdk/tools/lib/httpcore-4.1.jar:/path/to/sdk/tools/lib/commons-logging-1.1.1.jar:/path/to/sdk/tools/lib/commons-codec-1.4.jar]
It seems that SetupTask is inside anttasks.jar, but it is not in my sdk directory. I tried to install all available sdks, tried to add ant-tasks.jar to the class path (it has similar name), but with no success. Is there any way how to install anttasks.jar, or is it replaced by something else? Or is SetupTask obsolete in some way?
I have run:
android update project ...
I tried to find answer by google but with no success for this particular issue (AntClassLoader is not empty, anttasks.jar is missing).
Thanks,
Daniel
Afaik the SetupTask ist obsolete in Android 2.3 and higher. So it seems to me like you're working with an old version of the build.xml. Since Android 2.3 and higher, there is a new template for the build.xml in the directory
your-android-SDK/tools/ant/. You can modify this one according to your needs.
Maybe this link will help you, it pointed me in the right direction:
https://sites.google.com/site/sokolkosta/internal-blog/includingadditionaljavaxpackagesinandroid23
https://stackoverflow.com/a/15719072/1343309
It worked for me.
rm MyProjects/NowRedux/build.xml
android update project --target 8 --path MyProjects/NowRedux

Android java.lang.VerifyError?

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.

Categories