Closed andaqui closed 6 years ago
@kumpanen How are you trying to build apk ? I am able to create apk successfully.
Can you please share me your Script '/prod/platforms/android/bms-push/android-build-extras.gradle'
?
The file looks like this:
if (!project.hasProperty('cdvMinSdkVersion') || cdvMinSdkVersion < 15) {
ext.cdvMinSdkVersion = 15;
}
// For Push SDK, SDK version must be at least 23
if (!project.hasProperty('cdvCompileSdkVersion') || cdvCompileSdkVersion < 26) {
ext.cdvCompileSdkVersion = 26;
}
android {
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE'
}
}
// Include Android Bluemix SDK dependency
dependencies {
compile 'com.ibm.mobilefirstplatform.clientsdk.android:push:3.+'
}
I belive that cordova crosswalk plugin makes some changes in the cdvMinSdkVersion. If i remove crosswalk plugin i get this error:
BUILD FAILED
Total time: 6.041 secs
Command finished with error code 1: /Users/andresaquino/code/moove/dist/movingblinds/prod/platforms/android/gradlew cdvBuildDebug,-b,/Users/andresaquino/code/moove/dist/movingblinds/prod/platforms/android/build.gradle,-Dorg.gradle.daemon=true,-Dorg.gradle.jvmargs=-Xmx2048m,-Pandroid.useDeprecatedNdk=true
(node:66621) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: /Users/andresaquino/code/moove/dist/movingblinds/prod/platforms/android/gradlew: Command failed with exit code 1 Error output:
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Module 'com.ibm.mobilefirstplatform.clientsdk.android:analytics:1.2.6' depends on one or more Android Libraries but is a jar
Module 'com.ibm.mobilefirstplatform.clientsdk.android:analytics:1.2.6' depends on one or more Android Libraries but is a jar
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':prepareDebugDependencies'.
> Dependency Error. See console for details.
This is with cordova platform android@6.3.0. Instead if i use cordova platform android@7.0.0 i get this error when building:
BUILD FAILED in 3s
38 actionable tasks: 4 executed, 34 up-to-date
(node:68033) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: /Users/andresaquino/code/moove/dist/movingblinds/prod/platforms/android/gradlew: Command failed with exit code 1 Error output:
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Dex: Error converting bytecode to dex:
Cause: com.android.dex.DexException: Multiple dex files define Landroid/support/design/R$anim;
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Landroid/support/design/R$anim;
com.android.dex.DexException: Multiple dex files define Landroid/support/design/R$anim;
at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:661)
at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:616)
at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:598)
at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)
at com.android.dx.merge.DexMerger.merge(DexMerger.java:198)
at com.android.builder.dexing.DexArchiveMergerCallable.call(DexArchiveMergerCallable.java:61)
at com.android.builder.dexing.DexArchiveMergerCallable.call(DexArchiveMergerCallable.java:36)
at java.util.concurrent.ForkJoinTask$AdaptedCallable.exec(ForkJoinTask.java:1424)
at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)
at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:transformDexArchiveWithDexMergerForDebug'.
> com.android.build.api.transform.TransformException: com.android.dex.DexException: Multiple dex files define Landroid/support/design/R$anim;
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
* Get more help at https://help.gradle.org
If i remove bms-push cordova plugin the project builds works fine in both 7.0.0 and 6.3.0.
Any idea how to solve this issues?
Also if i create a completely new clean hello world cordova project and only install bms-push plugin i get "Execution failed for task ':app:transformDexArchiveWithDexMergerForDebug'" for cordova android platform 7.0.0 when i run cordova build android.
@kumpanen Hi, this is related to the Core plugin dependency issue. Fix will be available soon.
@kumpanen Please try a cordova plugin update
. this will fix the issue
Thanks. I tried this now but i still get errors. If i used cordova-plugin-crosswalk-webview i get the "java.lang.Integer cannot be cast to java.lang.String". But okay, i remove that plugin and i get the error below. It builds fine until i add the lines to dependencies classpath 'com.google.gms:google-services:3.2.0' and the apply plugin: 'com.google.gms.google-services'. Same result in a clean hello world project.
BUILD FAILED in 11s
41 actionable tasks: 41 executed
(node:91531) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: /Users/andresaquino/code/moove/dist/movingblinds/prod/platforms/android/gradlew: Command failed with exit code 1 Error output:
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Exception in thread "main" java.lang.IllegalArgumentException
at com.google.common.base.Preconditions.checkArgument(Preconditions.java:108)
at com.google.devtools.build.android.desugar.DefaultMethodClassFixer$DefaultMethodFinder.visit(DefaultMethodClassFixer.java:471)
at org.objectweb.asm.ClassReader.accept(Unknown Source)
at org.objectweb.asm.ClassReader.accept(Unknown Source)
at com.google.devtools.build.android.desugar.DefaultMethodClassFixer.defaultMethodsDefined(DefaultMethodClassFixer.java:319)
at com.google.devtools.build.android.desugar.DefaultMethodClassFixer.visitEnd(DefaultMethodClassFixer.java:88)
at org.objectweb.asm.ClassVisitor.visitEnd(Unknown Source)
at com.google.devtools.build.android.desugar.InterfaceDesugaring.visitEnd(InterfaceDesugaring.java:85)
at org.objectweb.asm.ClassVisitor.visitEnd(Unknown Source)
at com.google.devtools.build.android.desugar.LambdaDesugaring.visitEnd(LambdaDesugaring.java:150)
at org.objectweb.asm.ClassReader.accept(Unknown Source)
at org.objectweb.asm.ClassReader.accept(Unknown Source)
at com.google.devtools.build.android.desugar.Desugar.desugarClassesInInput(Desugar.java:401)
at com.google.devtools.build.android.desugar.Desugar.desugarOneInput(Desugar.java:326)
at com.google.devtools.build.android.desugar.Desugar.desugar(Desugar.java:280)
at com.google.devtools.build.android.desugar.Desugar.main(Desugar.java:584)
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:transformClassesWithDesugarForDebug'.
> com.android.build.api.transform.TransformException: java.lang.RuntimeException: java.lang.RuntimeException: com.android.ide.common.process.ProcessException: Error while executing java process with main class com.google.devtools.build.android.desugar.Desugar with arguments {--input /Users/andresaquino/code/moove/dist/movingblinds/prod/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/20.jar --output /Users/andresaquino/code/moove/dist/movingblinds/prod/platforms/android/app/build/intermediates/transforms/desugar/debug/22.jar --input /Users/andresaquino/code/moove/dist/movingblinds/prod/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/33.jar --output /Users/andresaquino/code/moove/dist/movingblinds/prod/platforms/android/app/build/intermediates/transforms/desugar/debug/35.jar --input /Users/andresaquino/code/moove/dist/movingblinds/prod/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/6.jar --output /Users/andresaquino/code/moove/dist/movingblinds/prod/platforms/android/app/build/intermediates/transforms/desugar/debug/8.jar --input /Users/andresaquino/code/moove/dist/movingblinds/prod/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/31.jar --output /Users/andresaquino/code/moove/dist/movingblinds/prod/platforms/android/app/build/intermediates/transforms/desugar/debug/33.jar --input /Users/andresaquino/code/moove/dist/movingblinds/prod/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/23.jar --output /Users/andresaquino/code/moove/dist/movingblinds/prod/platforms/android/app/build/intermediates/transforms/desugar/debug/25.jar --input /Users/andresaquino/code/moove/dist/movingblinds/prod/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/27.jar --output /Users/andresaquino/code/moove/dist/movingblinds/prod/platforms/android/app/build/intermediates/transforms/desugar/debug/29.jar --input /Users/andresaquino/code/moove/dist/movingblinds/prod/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/36.jar --output /Users/andresaquino/code/moove/dist/movingblinds/prod/platforms/android/app/build/intermediates/transforms/desugar/debug/38.jar --input /Users/andresaquino/code/moove/dist/movingblinds/prod/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/26.jar --output /Users/andresaquino/code/moove/dist/movingblinds/prod/platforms/android/app/build/intermediates/transforms/desugar/debug/28.jar --input /Users/andresaquino/code/moove/dist/movingblinds/prod/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/0.jar --output /Users/andresaquino/code/moove/dist/movingblinds/prod/platforms/android/app/build/intermediates/transforms/desugar/debug/2.jar --input /Users/andresaquino/code/moove/dist/movingblinds/prod/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/15.jar --output /Users/andresaquino/code/moove/dist/movingblinds/prod/platforms/android/app/build/intermediates/transforms/desugar/debug/17.jar --input /Users/andresaquino/code/moove/dist/movingblinds/prod/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/11.jar --output /Users/andresaquino/code/moove/dist/movingblinds/prod/platforms/android/app/build/intermediates/transforms/desugar/debug/13.jar --input /Users/andresaquino/code/moove/dist/movingblinds/prod/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/35.jar --output /Users/andresaquino/code/moove/dist/movingblinds/prod/platforms/android/app/build/intermediates/transforms/desugar/debug/37.jar --input /Users/andresaquino/code/moove/dist/movingblinds/prod/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/22.jar --output /Users/andresaquino/code/moove/dist/movingblinds/prod/platforms/android/app/build/intermediates/transforms/desugar/debug/24.jar --classpath_entry /Users/andresaquino/code/moove/dist/movingblinds/prod/platforms/android/CordovaLib/build/intermediates/intermediate-jars/debug/classes.jar --classpath_entry /Users/andresaquino/code/moove/dist/movingblinds/prod/platforms/android/app/build/intermediates/classes/debug --classpath_entry /Users/andresaquino/code/moove/dist/movingblinds/prod/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/0.jar --classpath_entry /Users/andresaquino/code/moove/dist/movingblinds/prod/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/1.jar --classpath_entry /Users/andresaquino/code/moove/dist/movingblinds/prod/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/2.jar --classpath_entry /Users/andresaquino/code/moove/dist/movingblinds/prod/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/3.jar --classpath_entry /Users/andresaquino/code/moove/dist/movingblinds/prod/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/4.jar --classpath_entry /Users/andresaquino/code/moove/dist/movingblinds/prod/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/5.jar --classpath_entry /Users/andresaquino/code/moove/dist/movingblinds/prod/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/6.jar --classpath_entry /Users/andresaquino/code/moove/dist/movingblinds/prod/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/7.jar --classpath_entry /Users/andresaquino/code/moove/dist/movingblinds/prod/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/8.jar --classpath_entry /Users/andresaquino/code/moove/dist/movingblinds/prod/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/9.jar --classpath_entry /Users/andresaquino/code/moove/dist/movingblinds/prod/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/10.jar --classpath_entry /Users/andresaquino/code/moove/dist/movingblinds/prod/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/11.jar --classpath_entry /Users/andresaquino/code/moove/dist/movingblinds/prod/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/12.jar --classpath_entry /Users/andresaquino/code/moove/dist/movingblinds/prod/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/13.jar --classpath_entry /Users/andresaquino/code/moove/dist/movingblinds/prod/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/14.jar --classpath_entry /Users/andresaquino/code/moove/dist/movingblinds/prod/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/15.jar --classpath_entry /Users/andresaquino/code/moove/dist/movingblinds/prod/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/16.jar --classpath_entry /Users/andresaquino/code/moove/dist/movingblinds/prod/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/17.jar --classpath_entry /Users/andresaquino/code/moove/dist/movingblinds/prod/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/18.jar --classpath_entry /Users/andresaquino/code/moove/dist/movingblinds/prod/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/19.jar --classpath_entry /Users/andresaquino/code/moove/dist/movingblinds/prod/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/20.jar --classpath_entry /Users/andresaquino/code/moove/dist/movingblinds/prod/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/21.jar --classpath_entry /Users/andresaquino/code/moove/dist/movingblinds/prod/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/22.jar --classpath_entry /Users/andresaquino/code/moove/dist/movingblinds/prod/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/23.jar --classpath_entry /Users/andresaquino/code/moove/dist/movingblinds/prod/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/24.jar --classpath_entry /Users/andresaquino/code/moove/dist/movingblinds/prod/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/25.jar --classpath_entry /Users/andresaquino/code/moove/dist/movingblinds/prod/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/26.jar --classpath_entry /Users/andresaquino/code/moove/dist/movingblinds/prod/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/27.jar --classpath_entry /Users/andresaquino/code/moove/dist/movingblinds/prod/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/28.jar --classpath_entry /Users/andresaquino/code/moove/dist/movingblinds/prod/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/29.jar --classpath_entry /Users/andresaquino/code/moove/dist/movingblinds/prod/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/30.jar --classpath_entry /Users/andresaquino/code/moove/dist/movingblinds/prod/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/31.jar --classpath_entry /Users/andresaquino/code/moove/dist/movingblinds/prod/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/32.jar --classpath_entry /Users/andresaquino/code/moove/dist/movingblinds/prod/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/33.jar --classpath_entry /Users/andresaquino/code/moove/dist/movingblinds/prod/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/34.jar --classpath_entry /Users/andresaquino/code/moove/dist/movingblinds/prod/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/35.jar --classpath_entry /Users/andresaquino/code/moove/dist/movingblinds/prod/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/36.jar --bootclasspath_entry /Users/andresaquino/Library/Android/sdk/platforms/android-26/android.jar --bootclasspath_entry /Users/andresaquino/Library/Android/sdk/platforms/android-26/optional/org.apache.http.legacy.jar --bootclasspath_entry /Library/Java/JavaVirtualMachines/jdk1.8.0_162.jdk/Contents/Home/jre/lib/resources.jar --bootclasspath_entry /Library/Java/JavaVirtualMachines/jdk1.8.0_162.jdk/Contents/Home/jre/lib/rt.jar --bootclasspath_entry /Library/Java/JavaVirtualMachines/jdk1.8.0_162.jdk/Contents/Home/jre/lib/jsse.jar --bootclasspath_entry /Library/Java/JavaVirtualMachines/jdk1.8.0_162.jdk/Contents/Home/jre/lib/jce.jar --bootclasspath_entry /Library/Java/JavaVirtualMachines/jdk1.8.0_162.jdk/Contents/Home/jre/lib/charsets.jar --bootclasspath_entry /Library/Java/JavaVirtualMachines/jdk1.8.0_162.jdk/Contents/Home/jre/lib/jfr.jar --min_sdk_version 19 --nodesugar_try_with_resources_if_needed --desugar_try_with_resources_omit_runtime_classes}
@kumpanen Share me your build.gradle file please. The one inside platforms/android.
/* Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
*/
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
dependencies {
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.android.tools.build:gradle:3.0.0'
classpath 'com.google.gms:google-services:3.0.0'
}
}
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
//This replaces project.properties w.r.t. build settings
project.ext {
defaultBuildToolsVersion="26.0.0" //String
defaultMinSdkVersion=19 //Integer - Minimum requirement is Android 4.4
defaultTargetSdkVersion=26 //Integer - We ALWAYS target the latest by default
defaultCompileSdkVersion=26 //Integer - We ALWAYS compile with the latest by default
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
@kumpanen can you send me the entire gradle file please ?
Thats the entire build.gradle inside platforms/android. Do you want the one inside platforms/android/app/ aswell?
build.gradle in platforms/android: build.gradle.zip
build.gradle in platforms/android/app: build.gradle_app.zip
@kumpanen Are you using Cordova ? I don't know how you have one app
folder inside the platforms/android
..
The changes you have to make in platforms/android/gradle.build
are,
Find buildscript
and add
buildscript {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
// Switch the Android Gradle plugin version requirement depending on the
// installed version of Gradle. This dependency is documented at
// http://tools.android.com/tech-docs/new-build-system/version-compatibility
// and https://issues.apache.org/jira/browse/CB-8143
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'
classpath 'com.google.gms:google-services:3.0.0'
}
}
then allprojects
,
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
}
then go to dependencies
dependencies {
........
compile 'com.android.support:appcompat-v7:26.1.0'
compile 'com.google.firebase:firebase-messaging:10.2.6'
}
apply plugin: 'com.google.gms.google-services'
Add google-services.json
in the platforms/android/
After adding all these build should work for you .
Ok i will try it out. Im using cordova v8.0.0. But the folder structure with app folder, isn't that normal behaviour? I mean, always when i do completely new project (cordova create newProjectName and then cordova platform add android), i get an app folder and the same build.gradles files and structures. What version of cordova are you using?
Also using android gradle version 4.1. I believe thats the new folder and file structure? https://developer.android.com/studio/build/index.html#build-files
@kumpanen I am using cordova 7.1
Ok i tried it out and for cordova build to work with new gradle you need to update your bms-push/plugin.xml with the new android.support and firebase-messaging versions. Then it will automatically use those in the project with new folder structure as well.
plugin.xml file before:
<platform name="android">
<framework src="src/android/build-extras.gradle" custom="true" type="gradleReference" />
<framework src="com.android.support:appcompat-v7:23.2.1" />
<framework src="com.google.firebase:firebase-messaging:9.0.2" />
plugin.xml file working:
<platform name="android">
<framework src="src/android/build-extras.gradle" custom="true" type="gradleReference" />
<framework src="com.android.support:appcompat-v7:26.1.0" />
<framework src="com.google.firebase:firebase-messaging:10.2.6" />
@kumpanen you can add the same in build.gradle dependencies also.
The dependencies are in the build.gradle inside app in the new structure, if i manually change them they get overwritten by project.properties file that gets his version from bms-push/plugin.xml. But you are right, in cordova 7.1 i dont get app folder neither. Thanks for your help.
@kumpanen Thanks for pointing out that.. I will change this in the next release .
Seems like android has updated some libraries so now this plugins is getting some errors. I could build apk fine some days ago, but today when trying to build android apk i get:
`FAILURE: Build failed with an exception.
Where: Script '/prod/platforms/android/bms-push/android-build-extras.gradle' line: 2
What went wrong: A problem occurred evaluating script.
Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
Get more help at https://help.gradle.org
BUILD FAILED in 37s`