Android Studio: 1.3.1 - Gradle Build Plugin: 1.1.2 - Gradle: 1.3.0
On Android Studio, I have an app that runs perfectly fine on Android API22 (Lollipop, on both simulator API22 and Android phone API22, and also works on API 21 - but nothing below API 21).
In my Gradle build file, I have the following:
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
minSdkVersion 17
targetSdkVersion 22
...
compile "commons-io:commons-io:2.4" //IO
So, as I understand it: my app is compiled with the latest API (22) to run on devices from API 17 to API 22 (and 22+ in compatibility mode).
However, when I run the Android app on a API 17 simulator, it crashes during some file copy operations. Before the crash, dalivkvm complains it cannot find methods.
I/dalvikvm﹕ Could not find method org.apache.commons.io.FileUtils.copyInputStreamToFile,
referenced from method FileCopy.batchCreate
W/dalvikvm﹕ VFY: unable to resolve static method 58205: Lorg/apache/commons/io/FileUtils;
.copyInputStreamToFile (Ljava/io/InputStream;Ljava/io/File;)V
D/dalvikvm﹕ VFY: replacing opcode 0x71 at 0x0058
Then the fatal exception:
E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.lang.NoClassDefFoundError: org.apache.commons.io.FileUtils
Now obviously the apache commons libraries can be present and imported, at least on API 22 (which, I remind you, runs successfully on both the device and the simulator).
This also happens for other libraries aside from the Apache commons one (if I skip using the Apache Commons, then another third party library will cause a similar issue and so on).
I'm at loss as to why it won't run on API 17. Also have the same issues on API 18 and 19, API 20 doesn't exist.
It appears to work correctly on both API 21 and API 22.
I've looked for similar errors on here, but usually it is because people simply forgot to include their jar libs so it didn't help.
UPDATES
MultiDex is enabled. On API 21 (Lollipop) the way multidex is supported has changed (see https://developer.android.com/tools/building/multidex.html). So it might have something to do with this.
Gradle builds Modules in "release mode" when app is in "Debug mode" (Why does Gradle build my module in Release mode when the app is in Debug)
I tried rebuilding, creating a new project with the files to no avail.
The "commons-io:commons-io:xxx" folder is present in the Gradle cache folder.