JavaFXPorts Multi-Dex Android Build - android

I am porting a JavaFX application to Android using JavaFXPorts. However, assuming I understand this error correctly, I need to perform a multi-dex build. This is not surprising, since the project has many dependencies.
./gradlew :client:android
...
:client:dex[ant:java] Java Result: 2
FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':client:dex'.
> UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Too many classes in --main-dex-list, main dex capacity exceeded
at com.android.dx.command.dexer.Main.processAllFiles(Main.java:546)
at com.android.dx.command.dexer.Main.runMultiDex(Main.java:366)
at com.android.dx.command.dexer.Main.run(Main.java:275)
at com.android.dx.command.dexer.Main.main(Main.java:245)
at com.android.dx.command.Main.main(Main.java:106)
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
I followed the instructions for configuring the multi-dex build, but it does not appear to be compatible with JavaFXPorts. Specifically, when I add this to my build.gradle:
compileSdkVersion 21
buildToolsVersion "21.1.0"
defaultConfig {
...
minSdkVersion 14
targetSdkVersion 21
...
// Enabling multidex support.
multiDexEnabled true
}
I get the following error:
./gradlew :client:android
FAILURE: Build failed with an exception.
* Where:
Build file 'C:\Users\username\myproject\client\build.gradle' line: 67
* What went wrong:
A problem occurred evaluating root project 'client'.
> Could not find method compileSdkVersion() for arguments [21] on object of type org.javafxports.jfxmobile.plugin.android.AndroidExtension.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
For reference, my build.gradle is as follows:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'org.javafxports:jfxmobile-plugin:1.0.8'
}
}
apply plugin: 'base'
subprojects {
apply plugin: 'scala'
apply plugin: 'org.javafxports.jfxmobile'
repositories {
jcenter()
mavenCentral()
}
dependencies {
...
}
mainClassName = "com.myproject.client.Main"
jfxmobile {
ios {
forceLinkClasses = [ 'com.myproject.client.**.*' ]
}
android {
// This does not work with JavaFXPorts
/*compileSdkVersion 21
buildToolsVersion "21.1.0"
defaultConfig {
minSdkVersion 14
targetSdkVersion 21
// Enabling multidex support.
multiDexEnabled true
}*/
packagingOptions {
pickFirst 'META-INF/LICENSE.txt'
pickFirst 'META-INF/NOTICE.txt'
pickFirst 'reference.conf'
pickFirst 'rootdoc.txt'
}
}
}
}
How can I configure a multi-dex build for a JavaFXPorts project?

Related

Flutter: A problem occurred evaluating root project 'android'. > Cannot run Project.afterEvaluate(Closure) when the project is already evaluated

I am trying to build a flutter app that uses many packages, these packages can sometime be a problem with the compileSdkversion so whenever I try and change it new errors come up.
Whenever I do
flutter build apk --release
Wanting to build my app, I keep getting this error
FAILURE: Build failed with an exception.
* Where:
Build file '/Users/user/dev/project/android/build.gradle' line: 26
* What went wrong:
A problem occurred evaluating root project 'android'.
> Cannot run Project.afterEvaluate(Closure) when the project is already evaluated.
* 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
BUILD FAILED in 1s
Running Gradle task 'assembleRelease'... 4.4s
Gradle task assembleRelease failed with exit code 1
Here is my build.gradle
buildscript {
ext.kotlin_version = '1.7.0'
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.1.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.3.14'
}
}
allprojects {
repositories {
google()
mavenCentral()
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
project.evaluationDependsOn(':app')
afterEvaluate { project ->
android {
compileSdkVersion 31
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
And here is my app/build.gradle
android {
compileSdkVersion 31
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
defaultConfig {
applicationId "com.user.project"
minSdkVersion 21
targetSdkVersion 31
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
buildTypes {
release {
signingConfig signingConfigs.debug
}
}
}
Here is my gradle-wrapper.properties
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-all.zip
I am using MacOS Catalina version 10.15.7 and Android studio Dolphin 2021.3.1 Patch 1
I have tried changing the compileSdkversion to 33 but it gives me another error with my video_player_android package.
I have also tried changing the distributionUrl to 6.9.2 and the com.android.tools.build:gradle to 4.2.2 but then I get this error with video_player_android:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:lintVitalRelease'.
> Could not resolve all artifacts for configuration ':video_player_android:debugUnitTestRuntimeClasspath'.
> Failed to transform bcprov-jdk15on-1.68.jar (org.bouncycastle:bcprov-jdk15on:1.68) to match attributes {artifactType=processed-jar, org.gradle.category=library, org.gradle.libraryelements=jar, org.gradle.status=release, org.gradle.usage=java-runtime}.
> Execution failed for JetifyTransform: /Users/user/.gradle/caches/modules-2/files-2.1/org.bouncycastle/bcprov-jdk15on/1.68/46a080368d38b428d237a59458f9bc915222894d/bcprov-jdk15on-1.68.jar.
> Failed to transform '/Users/user/.gradle/caches/modules-2/files-2.1/org.bouncycastle/bcprov-jdk15on/1.68/46a080368d38b428d237a59458f9bc915222894d/bcprov-jdk15on-1.68.jar' using Jetifier. Reason: IllegalArgumentException, message: Unsupported class file major version 59. (Run with --stacktrace for more details.)
Suggestions:
- Check out existing issues at https://issuetracker.google.com/issues?q=componentid:460323&s=modified_time:desc, it's possible that this issue has already been filed there.
- If this issue has not been filed, please report it at https://issuetracker.google.com/issues/new?component=460323 (run with --stacktrace and provide a stack trace if possible).
* 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
BUILD FAILED in 2m 3s
I have tried every possible combination but keep getting either the first error or the second error with video_player_android (degrading the package it won't work)
Please feel free to ask more details or try and change things. Thanks

Execution failed for task ':app:checkDebugAarMetadata' on npx react-native run-android

I have tried to change compileSdkVersion = 30 and targetSdkVersion = 30 but still no use it is giving the same error again and again also I clean the Gradle but still no use, so if you can help, please help me. This error is been coming for almost 3 to 4 days from today, before that my project was running obviously fine. I also tried cleaning gradel but still no use.
This is the error body I am getting Error body:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:checkDebugAarMetadata'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction
> One or more issues found when checking AAR metadata values:
The minCompileSdk (33) specified in a
dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)
is greater than this module's compileSdkVersion (android-31).
Dependency: androidx.browser:browser:1.5.0-alpha01.
AAR metadata file: C:\Users\hp\.gradle\caches\transforms-3\a7a45c1d439f263d5595caa518b0e64b\transformed\browser-1.5.0-alpha01\META-INF\com\android\build\gradle\aar-metadata.properties.
* 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
BUILD FAILED in 50s
my android/build.gradle:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext {
buildToolsVersion = "31.0.0"
minSdkVersion = 21
compileSdkVersion = 31
targetSdkVersion = 31
if (System.properties['os.arch'] == "aarch64") {
// For M1 Users we need to use the NDK 24 which added support for aarch64
ndkVersion = "24.0.8215888"
} else {
// Otherwise we default to the side-by-side NDK version from AGP.
ndkVersion = "22.0.7026061"
}
}
repositories {
google()
mavenCentral()
}
dependencies {
classpath("com.android.tools.build:gradle:7.0.4")
classpath("com.facebook.react:react-native-gradle-plugin")
classpath("de.undercouch:gradle-download-task:4.1.2")
classpath 'com.google.gms:google-services:4.3.13'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url("$rootDir/../node_modules/react-native/android")
}
maven {
// Android JSC is installed from npm
url("$rootDir/../node_modules/jsc-android/dist")
}
mavenCentral {
// We don't want to fetch react-native from Maven Central as there are
// older versions over there.
content {
excludeGroup "com.facebook.react"
}
}
google()
maven { url 'https://www.jitpack.io' }
}
}```
please do help if you can thank you.
Here is what i did to solve it. The project was on RN-0.66.4 (I upgraded it to the recent version RN-0.70.4)
Then in android/build.gradle I updated compileSdkVersion from 31 to 33.
This is my configurations for build.gradle
I hope it helps.

I get error when I use the apply plugin: 'com.android.library'

I created a normal project in android studio and considering to the tutorials I wanted to create an aar file from that project but I get the following error:
Gradle:
FAILURE: Build failed with an exception.
* Where:
Build file 'C:\Users\tec\AndroidStudioProjects\B\B\build.gradle' line: 1
* What went wrong:
A problem occurred evaluating project ':B'.
> Plugin with id 'com.android.library' not found.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
Could not execute build using Gradle distribution 'http://services.gradle.org/distributions/gradle-1.6-bin.zip'.
My gradle file is as follows:
apply plugin: 'com.android.library'
buildscript {
repositories {
maven { url 'http://repo1.maven.org/maven2' }
}
dependencies {
classpath 'com.android.tools.build:gradle:0.4'
}
}
apply plugin: 'android'
dependencies {
compile files('libs/android-support-v4.jar')
}
android {
compileSdkVersion 17
buildToolsVersion "17.0.0"
defaultConfig {
minSdkVersion 7
targetSdkVersion 16
}
}
You have to update your script:
First of all use the latest gradle plugin.
classpath 'com.android.tools.build:gradle:1.3.0'
Then update your gradle wrapper.
Open up this file in your project:
<Project>/gradle/wrapper/gradle-wrapper.properties
distributionUrl=http\://services.gradle.org/distributions/gradle-2.4-all.zip
Finally remove the line apply plugin: 'android'

different flavor dependencies

I found the same question Duplicate. But I have no maven dependency. I have subproject dependency.
I want to use one project dependency only for one flavor. This is my build.gradle
dependencies {
secureCompile project(':relatedProjects:gd')
}
android {
compileSdkVersion "Google Inc.:Google APIs:19"
buildToolsVersion "18.1.1"
productFlavors {
google {}
secure {
packageName "com.some_secure.package"
}
}
}
This is console out on build command
./gradlew clean assembleDebug
FAILURE: Build failed with an exception.
* Where:
Build file '/home/kulik/project/Notate/notateolearis/notateandroid/build.gradle' line: 27
* What went wrong:
A problem occurred evaluating project ':someproject'.
> Could not find method secureCompile() for arguments [project ':relatedProjects:gd'] on project ':someproject'.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 15.957 secs
Solution are founded. Flavors should be declared before using it, so right build gradle is:
android {
productFlavors {
google {}
secure {
packageName "com.some_secure.package"
}
}
dependencies {
secureCompile project(':relatedProjects:gd')
}
compileSdkVersion "Google Inc.:Google APIs:19"
buildToolsVersion "18.1.1"
}

Allow unstable Android Gradle builds on Jenkins

Hi I have set up my Android project on Jenkins to provide CI. Its working well, running tests on a connected Android handset. The tests run on the Android Test Framework which extends jUnit3.
Unfortunately, the build is marked as a failure if there are any test failures. I'd like to be able to improve this in two ways:
Allowing unstable builds
Being able to mark known test failures
For item 1 I tried adding this to the project build.gradle:
connectedCheck {
ignoreFailures = true
}
But it has no effect. Looking at the build log, I realised the actual test task is called connectedInstrumentTest, but this task is not found:
connectedInstrumentTest {
ignoreFailures = true
}
causes:
Could not find method connectedInstrumentTest() for arguments [build_4ldpah0qgf0ukktofecsq41r98$_run_closure3#9cd826] on project ':Playtime'.
That am I missing?
Thanks
EDIT: Heres my project build.gradle, nothing special:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.+'
}
}
apply plugin: 'android'
dependencies {
compile files('libs/android-support-v4.jar')
}
android {
compileSdkVersion 17
buildToolsVersion "18.0.1"
defaultConfig {
minSdkVersion 8
targetSdkVersion 16
testPackageName "com.bb.pt.test"
testInstrumentationRunner "android.test.InstrumentationTestRunner"
}
}
connectedCheck {
ignoreFailures = true
}
My gradle settings in jenkins:
switches: --stacktrace --info
tasks: :pt:assembleDebug :pt:assembleTest :pt:connectedCheck
EDIT:
I built gradlew and tried that. Same output. I don't want the build to FAIL if there are test failures:
:pt:connectedInstrumentTest FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':pt:connectedInstrumentTest'.
> There were failing tests. See the report at: file:///home/simon/WorkingCopies/bb/code/trunk/pt/pt/build/reports/instrumentTests/connected/index.html
* Try:
Run with --stacktrace option to get the stack trace. Run with --debug option to get more log output.
BUILD FAILED
I tried to qualify the task name in build.gradle:
task connectedCheck {
ignoreFailures = true
}
But it thinks I am trying to add a new task rather than modify the existing one.
FAILURE: Build failed with an exception.
* Where:
Build file '/home/simon/WorkingCopies/bb/code/trunk/pt/pt/build.gradle' line: 31
* What went wrong:
A problem occurred evaluating project ':pt'.
> Cannot add task ':pt:connectedCheck' as a task with that name already exists.
After our conversation I believe that:
the problem is gradle configuration only and not jenkins related. Get it to work in gradle.
in gradle I believe (though I am not an expert) you should get the connectedInstrumentTest to ignore failures, but your attempt to use the following failed
connectedInstrumentTest {
ignoreFailures = true
}
maybe the solution is to wrap this config node like this:
project.gradle.taskGraph.whenReady {
connectedInstrumentTest {
ignoreFailures = true
}
}
https://github.com/stanfy/hotandroid/blob/master/part0/build.gradle

Categories

Resources