Android Studio refuses to run main() - java

Repro steps:
Start a new project in Android Studio (with the latest update);
Make a new class and add main() as usual;
Right-click class to run main() as a test.
package test;
public class Test {
public static void main(String[] args) {
}
}
Usually I expect I can just System.out.printLn("Hello World") but this time, no matter if it's a new project, I get the following error:
2:34:23 PM: Executing task 'Test.main()'...
Executing tasks: [Test.main()] in project C:\Users\regan\Desktop\events\MyApplication
FAILURE: Build failed with an exception.
* Where:
Initialization script 'C:\Users\regan\AppData\Local\Temp\Test_main__2.gradle' line: 20
* What went wrong:
A problem occurred configuring project ':app'.
> Could not create task ':app:Test.main()'.
> SourceSet with name 'test' not found.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/5.4.1/userguide/command_line_interface.html#sec:command_line_warnings
BUILD FAILED in 0s
2:34:24 PM: Task execution finished 'Test.main()'.
I am fairly new to Java after years of C# in Unity and have no idea what all this stuff is trying to tell me. I have googled but the closest I found was a way to HIDE this error (assuming code was still compiling). I need this code to at least compile.

Quick Fix : You can run using Run with Coverage.. See Image Below.
Permanent Solution: Add <option name="delegatedBuild" value="false" /> and sync project.
inside File gradle.xml under path E:\Project\.idea\gradle.xml. See Image below.

Open "gradle.xml" File in this path :
.idea/gradle.xml
Add the following line before </GradleProjectSettings/>
<option name="delegatedBuild" value="false" />
That is it , it worked for me.

The app module is an android library and expects android lifecycle methods such as onCreate() etc for successful execution. If you want to execute plain java code one option is to add a java library to the project using File -> New Module -> Java Library and add the main method there:
package com.example.lib;
public class MyClass {
public static void main(String[] args) {
System.out.println("Hello");
}
}
This would work as you expect it to.

Try to run it with "coverage". I don't have any explanation, but it works!

I'm currently using Android Studio Version 4.0.1
after creating the project, you should go to tab
File ==> New ==> New Module...
on "Create New Module/ Selecte Module Type":
Select Java or Kotlin Library
After it finish, go to javalib folder/ module that you have created.
Create Java file on there.
try to run it

I had this problem momentarily as well
I found when I changed Gradle to offline and then back online again then updated Gradle and made sure the connection and proxy settings were correct, things started working normally

Avoid naming the class name as Test, Android studio somehow will get screwed when you name class as Test.

If the module is from an android application or library it is not allowed to run the main; because what is expected is navigate transitions between stages of the activity lifecycle.
In the following cases of modules with these plugins applied, the main can NOT be run.
build.gradle.kts (:appAndroid)
plugins {
id("com.android.application")
id("kotlin-android")
}
build.gradle.kts (:libraryAndroid)
plugins {
id("com.android.library")
id("kotlin-android")
}
build.gradle.kts (:kmmShared)
plugins {
kotlin("multiplatform")
id("com.android.library")
}
If the purpose of running the main was to test things, what you really have to do is use the sourceSets of test.
If the module is from a Java or Kotlin library, running the main is allowed so the error would not exist.
The following applied plugins describe a JVM library:
build.gradle.kts (:jvmLibrary)
plugins {
id("java-library")
id("kotlin")
}
Finally, if using the test sourceSets or creating a JVM module was not enough for you, there is a 'hack' which is weak because it depends on the IDE (It does not work in KMM modules).
.idea/gradle.xml
<project version="4">
<component name="GradleSettings">
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>
<option name="delegatedBuild" value="false" />
</GradleProjectSettings>
</option>
</component>
</project>
GL

I have not much idea about it as I am very new in Android development and Android Studio. But after reading some solution over the internet and watchin some Youtube Videos, I have fixed it.
In app/build.gradle under dependencies for me
implementation 'androidx.appcompat:appcompat:1.4.1' - this was there
I changed it to
implementation 'androidx.appcompat:appcompat:1.2.0'
rebuilt the project and run, it worked for me..
I guess there must be some android studio update (in the latest version) was causing the problem.

I also got stuck in this problem. I am using Android Studio Arctic Fox in Macbook Pro M1. I have also tried to add New Module and Select Java and Kotlin Library and edited the configuration but it did not work for me. But it did work on my Windows System.
In macbook, I simply downgraded the dependancy in my App level build.gradle file
from
implementation 'androidx.appcompat:appcompat:1.5.0'
to
implementation 'androidx.appcompat:appcompat:1.2.0'
and run my Java Class as Run as Coverage and it worked.

Related

Flurry CN1Lib error after submitting Android build

I am getting error 'Caused by: org.gradle.process.internal.ExecException: Process 'command '/home/ec2-user/jdk1.8.0_45/bin/java'' finished with non-zero exit value 2' when submitting an Android build request.
I suspect it has got to do with Flurry CN1Lib
* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':transformClassesWithDexForRelease'.
Caused by: java.lang.RuntimeException: com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: Error while executing java process with main class com.android.dx.command.Main with arguments {--dex --verbose --force-jumbo --num-threads=4 --output
The flurry cn1lib needs to be updated to use the newer Android API level 28 for location which is our current default. That's the right thing to do for the long term.
As a short term patch you might be able to define: android.playServicesVersion=8.3.0 in the build hints to work around this. Notice that this might impact the functionality of your app such as location services support etc.
Well, I finally managed to fix this issue. I was only interested on getting the analytics bit working but I believe Ads should work too. Here is how I did it:
Cloned/downloaded the current CN1Flurry project from GitHub here https://github.com/chen-fishbein/flurry-codenameone. This allowed me to access the source files and use them for reference.
Importing the project as is into my Netbeans was bringing some 'resolve project' issues so I just went ahead and created a new project with similar name and package/class structure as CN1Flurry then copied classes from old project into the new one.
Open the FlurryNative class and delete the onPageView(), setLogEvents() and setCrashReportingEnabled() as these aren't supported by current Flurry Android SDK. Once done, right-click on the FlurryNative class and choose 'Generate Native Access'. This will allow you to create native implementations for Android, iOS, Windows etc in the 'native' folder of the project.
Chen's project uses version 5.3.0 of Flurry SDKs but the recommended SDK version is version 12.1.0. Download the latest aar files from your Flurry portal under the 'Admin' section and copy them to the 'android' folder. For me these were flurryAds_12.1.0.aar and flurryAnalytics_12.1.0.aar
Switch to the Files view of your Netbeans project and open the FlurryNativeImpl class. You can copy most of the implementations from Chen's project the only thing you need to change is the initFlurry() method to - new FlurryAgent.Builder().build(AndroidNativeUtil.getActivity(), apiKey); Flurry is initialized differently in the new SDK - https://developer.yahoo.com/flurry/docs/integrateflurry/android/
That's it. Switch back to the 'Projects' view then clean and build your CN1Flurry project to generate the .cn1lib file which you can then add to your UI project in the 'libs' folder. Remember to refresh cn1Libs files.
Finally, add the following build hints to your UI project:
android.min_sdk_version=16
android.multidex=true
android.xapplication=\<activity android:name="com.flurry.android.FlurryFullscreenTakeoverActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"> \</activity>
Chen suggests a whole lot of other build hints to add but I didn't find them useful for my case.
Still learning the ropes on how GitHub works; will make a pull request once I get comfortable. Meanwhile, you can get the entire project here - https://drive.google.com/open?id=1GGygaVelmMhMUX9Deik9W72hXkw_detG

java.lang.noClassDefFoundError: Failed resolution of: Lcom/facebook/R$style;

I try to add the facebook sdk to my delphi android project. I add to the libraries the file facebook-android-sdk.jar, however when i run the app and try to launch for exemple :
package com.wrapper.facebook;
import com.facebook.share.widget.AppInviteDialog;
public class FaceBookAppInvite {
public static boolean canShow() {
return AppInviteDialog.canShow();
}
}
when i call from delphi canShow i receive the error: java.lang.noClassDefFoundError: Failed resolution of: Lcom/facebook/R$style;
what did i miss ? where to find and how to add R$style ?
Android development tools will generate [your package].R.java from your android project resources when you compile your project.
And then some resources would be parts of inner class of R class.
I think you know this well.
After looking your question, the Lcom/facebook/R$style may be the R class generate from facebook sdk resource.
but i have no any experience of using facebook sdk, however i have some sugestion for you:
1.Decompile the facebook-android-sdk.jar. Make sure that there is no any R class in it.
2.Read the facebook sdk tutorial again.Try to find out which stup you have miss.
3.What kind of ide do you use? may be your project output apk does not include any facebook sdk, because your ide compile script does not output sdk with your codes.so check it out.
4.Do you have more runtime log?

AIDL Service and Android Open Source

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.

ndk.dir error in Android Studio

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

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