My application is not yet migrated to gradle, we still use Ant build script.
Recently one of our dependent libraries started using Java 8 features.
In order to compile using Java-8 lib, configured ant script to use java 1.8.
with this change, the compilation is successful, but failing in dex phase.
With 20.x build tools I got
"Bad Class File Magic (cafebabe)" error.
With 24.x build tools I got
"[dex] PARSE ERROR: unsupported class file version 52.0"
Seems to get rid of the dex error, i need to use jack toolchain, however as mentioned earlier, I am not using Gradle builds.
Is there any way to use dex with java-8 code? or Jack tools is the only solution?
Related
I ran build -> Make Project, and then used the Build Analyzer.
Inside the reports, I select the Warning tab and no jetifier warnings are found. (The project is build with Android Gradle Plugin 4.1)
Does that mean that I can be confident that jetifier does not need to be used for any lib and I may disable the jetifier from the gradle.properties file?
In short, no.
Probabably it will only check direct dependencies or known dependencies. We use a vendor artifact that didn't throw any errors when compiling, running profiler, etc. But after running the app it threw exception because it was still requiring the android.support.v4.content.ContextCompat class
Just updated to Android gradle plugin version 3.3.0
We have the following setup (not sure which are important):
Application project (app) with 3 library modules (data, domain, utils)
Databinding enabled (databinding.enabled true)
Proguard enabled(proguardFiles 'proguard-rules.pro')
When I build the app using:
./gradlew assembleDevRelease
I get the following error:
can't find referenced class my.package.data.R$raw
When I build the app using:
./gradlew :app:assembleDevRelease
The app builds fine, generates an obfuscated *.apk which I can install
Question:
What's the difference between assembleRelease and :app:assembleRelease
- Why does switching to android gradle plugin 3.3.0 affect which task I have to call to build my apk? We use assembleRelease everywhere in our CI pipelines to build our apks.
What changed in android gradle plugin 3.3.0 that caused the task assembleRelease to break? We use assembleRelease everywhere in our CI pipelines to build our apks.
Any suggestions how we can make 'assembleRelease' working again? (update Proguard config?, enabling R8?)
What's the difference between assembleRelease and :app:assembleRelease
The former runs the assembleRelease task on all modules relative to current level. The latter runs it on the app module only (and its dependencies).
Why does switching to android gradle plugin 3.3.0 affect which task I have to call to build my apk? We use assembleRelease everywhere in our CI pipelines to build our apks.
The question does not have enough info to say for sure, but there are a number of changes listed in the release notes. For example, this issue might be related to:
Faster R class generation for library projects: Previously, the Android Gradle plugin would generate an R.java file for each of your project's dependencies and then compile those R classes alongside your app's other classes. The plugin now generates a JAR containing your app's compiled R class directly, without first building intermediate R.java classes. This optimization may significantly improve build performance for projects that include many library subprojects and dependencies, and improve the indexing speed in Android Studio.
I have tried the Crystax sample on IDEA, and I have compiled it successfully, got it to run on my phone.
However, when I try to modify the project, IDEA throws an error about Gradle version:
Error:The project is using an incompatible version of the Android Gradle "experimental" plugin.
Please update your project to use version 0.9.0.
Then I updated it and met new problems:
Gradle version 3.3 is required. Current version is 4.1.
Please fix the project's Gradle settings.
I choose to Fix Gradle wrapper and re-import project
Then the next error appears:
Cannot set readonly property: proguardFiles for class: com.android.build.gradle.managed.BuildType
Please, is there anyone who knows how to use Crystax on IDEA IDE?
I found an alternative way, which does not relies on AS to build.
Just set your system PATH to Crystax-ndk folder, set up your Application.mk and Android.mk, and run command:
ndk-build
then you will get the result lib or executable file, then, link it to your Android project.
I am trying to setup a JDBC jar for my android studio project. I am currently getting an error when trying to launch the application due to the Module/Dependency I added.
Stack Trace
Error:Gradle: Error converting bytecode to dex:
Cause: Dex cannot parse version 52 byte code.
This is caused by library dependencies that have been compiled using Java 8 or above.
If you are using the 'java' gradle plugin in a library submodule add
targetCompatibility = '1.7'
sourceCompatibility = '1.7'
to that submodule's build.gradle file.
I tried following the steps in the trace and modifying the build.gradle file but could not resolve the issue. I am not sure if I need to uninstall and reinstall the module and set the compiler to 1.7 in the process or if I can even do that.
To get it to work you'll need a Java 7 compiled jar. See: Is it possible to use Java 8 for Android development?.
Additionally not sure why you are trying to include a JDBC driver into Android app, but recommend reading this: JDBC vs Web Service for Android
I'm working on an Android project with two projects inside it. When trying to run a build with gradlew (./gradlew build), I see the following error:
Execution failed for task ':example:lint'.
Could not initialize class
com.android.build.gradle.tasks.Lint$LintGradleIssueRegistry
With stacktrace enabled, this is listed as a java.lang.NoClassDefFoundError.
Oddly, the first time I ran this (which downloaded dependencies), the build failed with a different error:
Execution failed for task ':example:lint'.
lombok/ast/Node
The gradle wrapper that Android SDK created for the project is using Gradle 2.8.
Could this be a configuration issue with the project or my dev machine? I'm trying to avoid using the Android SDK lint tool as this complains about the projects using Gradle (and I hear it may miss some parts of these projects).
Turned out this was a configuration issue in our build.gradle. The following line had been added for testing and never removed:
configurations.classpath.exclude group: 'com.android.tools.external.lombok'
As such, the classes needed for linting were missing.
The following discussion pointed us in the right direction, in case it's useful to anyone else:
https://github.com/evant/gradle-retrolambda/issues/96