I originally added firebase crash reporting using Android firebase assistant in android studio. Which added firebase-crash:10.0.1. Now i am want access some methods added in later version so i upgraded it to to firebase-crash:11.2.0.
This is where the problem starts
I used this guide to make changes in my gradle.build (Module:app)
Changed compile 'com.google.firebase:firebase-crash:10.0.1' to compile 'com.google.firebase:firebase-crash:11.2.0'
At this point gradle sync failed. To resolve this i modified build.gradle (Project) with
allprojects {
repositories {
jcenter()
//Added this code
maven {
url "https://maven.google.com" // Google's Maven repository
}
}
}
Gradle build sync completed succesfully. Now i tried building debug apk and i received this error
Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexException: Multiple dex files define Lcom/google/android/gms/internal/zzbvb;
To fix this issue i modified buil.gradle(Modeule:app)
defaultConfig{
///...
multiDexEnabled true
///...
}
And now i am able to generate debug-build apk. But generating signed apk gives following error with 1588 warnings & 1 error.
Error:Execution failed for task ':app:transformClassesAndResourcesWithProguardForRelease'.
Job failed, see logs for details
This is where i am stuck. I am not able to resolve this issue. I tried several methods including clean/rebuild and invalidate cache & restart. Also tried adding -ignorewarning -dontwarn -keep class { public private} none of them seems to work.
Error in console on generating signed apk
build.gradle(Project)
build.gradle(Module:app)
Update
Adding this line compile 'com.google.android.gms:play-services:11.2.0 in build.gradle (Module:app) does build signed apk successfully. But shows following warnings.
I am confused
Using the Firebase version 11.2.0 (that has a dependency with Google play services v.11.2.0), you should use also the support libraries v26.
In your case:
compile 'com.android.support:appcompat-v7:26.0.1'
compile 'com.android.support:design:26.0.1'
compile 'com.android.support:support-v13:26.0.1'
Also you have to use:
compileSdkVersion 26
More info here.
Related
EDIT: This issue was solved by forcing the gradle not to jetify my native library. This is done by adding in gradle.properties
android.jetifier.blacklist = your-causing-issues-library
For more details you can read the official docs or this post
I need to use some native code in a react native project. The native code is provided in a .jar file by the hardware manufacturer. In a clean project (react-native init), with this .jar file inside /android/app/libs folder, this error shows as soon as I try to run "react native run-android".
==============
Error is as follow:
Task :app:javaPreCompileDebug FAILED
6 actionable tasks: 6 executed
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':app:javaPreCompileDebug'.
Could not resolve all files for configuration
':app:debugCompileClasspath'.
Failed to transform file 'iMagPayV5.1.4.jar' to match attributes {artifactType=android-classes, org.gradle.usage=java-runtime-jars}
Execution failed for JetifyTransform:
/home/buonapasta/Desktop/React-Native/samples/project/android/app/libs/iMagPayV5.1.4.jar.
Failed to transform '/home/buonapasta/Desktop/React-Native/samples/project/android/app/libs/iMagPayV5.1.4.jar' using Jetifier. Reason: 10. (Run with --stacktrace for more details.)
==============
Help is appreciated in advance!!
(Sorry if some information is incomplete).
React Native version 0.60.4 running on Ubuntu 18.04.
I've tried to include some other .jar files in a clean project without inconvenience, but as soon as I include this particular .jar everything blows.
Also, this library is working on an Android Studio project.
The .jar can be found on
https://github.com/GPaoloni/imagpay-framework
android/app/build.gradle looks like this:
...
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "com.facebook.react:react-native:+" // From node_modules
if (enableHermes) {
def hermesPath = "../../node_modules/hermesvm/android/";
debugImplementation files(hermesPath + "hermes-debug.aar")
releaseImplementation files(hermesPath + "hermes-release.aar")
} else {
implementation jscFlavor
}
}
// Run this once to be able to run the application with BUCK
// puts all compile dependencies into folder libs for BUCK to use
task copyDownloadableDepsToLibs(type: Copy) {
from configurations.compile
into 'libs'
}
android/build.gradle:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext {
buildToolsVersion = "28.0.3"
minSdkVersion = 16
compileSdkVersion = 28
targetSdkVersion = 28
supportLibVersion = "28.0.0"
}
repositories {
google()
jcenter()
}
dependencies {
classpath("com.android.tools.build:gradle:3.4.1")
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
mavenLocal()
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")
}
google()
jcenter()
}
}
I just want being able to include the .jar library (to be used by a native activity).
==============
Update:
I've tried doing like sugested:
npm install --save-dev jetifier
npx jetify
But the error still the same.
Reading the npm page of jetifier, in the "Usage for jar/zip/aar files" section:
npm install jetifier
npx jetifier-standalone <your arguments here>
Runing this gives me the following error:
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 10
at org.objectweb.asm.ClassReader.readFrameType(ClassReader.java:2313)
at org.objectweb.asm.ClassReader.readFrame(ClassReader.java:2269)
at org.objectweb.asm.ClassReader.readCode(ClassReader.java:1448)
at org.objectweb.asm.ClassReader.readMethod(ClassReader.java:1126)
at org.objectweb.asm.ClassReader.accept(ClassReader.java:698)
at org.objectweb.asm.ClassReader.accept(ClassReader.java:500)
at com.android.tools.build.jetifier.processor.transform.bytecode.ByteCodeTransformer.runTransform(ByteCodeTransformer.kt:39)
at com.android.tools.build.jetifier.processor.Processor.visit(Processor.kt:443)
at com.android.tools.build.jetifier.processor.archive.ArchiveFile.accept(ArchiveFile.kt:49)
at com.android.tools.build.jetifier.processor.Processor.visit(Processor.kt:425)
at com.android.tools.build.jetifier.processor.archive.Archive.accept(Archive.kt:76)
at com.android.tools.build.jetifier.processor.Processor.transformLibrary(Processor.kt:421)
at com.android.tools.build.jetifier.processor.Processor.transform(Processor.kt:247)
at com.android.tools.build.jetifier.processor.Processor.transform$default(Processor.kt:234)
at com.android.tools.build.jetifier.standalone.Main.run(Main.kt:157)
at com.android.tools.build.jetifier.standalone.Main$Companion.main(Main.kt:109)
at com.android.tools.build.jetifier.standalone.Main.main(Main.kt)
Try executing these line by line.
1. yarn
2. yarn start
On a new terminal tab
1. react-native run-android
Check whether 'jetifier' running output is displayed on the terminal.
Something similar to this.
"Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag."
If not run these before executing 'react-native run-android'
1. npm install --save-dev jetifier
2. npx jetify
I am using VS Code and installed prettier and format on-save. For some reason, when I saved page, he formatted wrong and I had this error, when discarded changes, it started working well, u can try this, as prevention.
I'm using gradle version 4.4 and android plugin version 3.1.4 while building i am getting error as follows:
AGPBI: {"kind":"error","text":"Program type already present: javax.inject.Named","sources":[{}],"tool":"D8"}
:tractorapp:transformDexArchiveWithExternalLibsDexMergerForDebug FAILED
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':tractorapp:transformDexArchiveWithExternalLibsDexMergerForDebug'.
> com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives:
First of all, delete .gradle and .idea folders after closing this project in Android Studio and then re open the project and then follow this:
Enable multiDex in your app build.gradle file. This should help you solve this. Also share the build.gradle file here so that we can figure out what is causing the issue properly.
defaultConfig {
multiDexEnabled true
}
Gradle project sync failed and did not get answers from other related questions. Here are the details of my situation.
Initial sync attempt yielded the following error message:
Unsupported method: BaseConfig.getApplicationIdSuffix().
The version of Gradle you connect to does not support that method.
To resolve the problem you can change/upgrade the target version of Gradle you connect to.
Alternatively, you can ignore this exception and read other information from the model.
I have Android Studio 3.0. The build.gradle file includes the following dependency:
classpath 'com.android.tools.build:gradle-experimental:0.2.1'
The gradle-wrapper.properties file includes the following distribution URL:
distributionUrl=https\://services.gradle.org/distributions/gradle-2.5-all.zip
According to https://developer.android.com/studio/build/gradle-plugin-3-0-0-migration.html#update_gradle I need to make some changes.
First, update the Gradle version for Android Studio 3.0 in gradle-wrapper.properties:
distributionUrl=\
https://services.gradle.org/distributions/gradle-4.1-all.zip
(I believe the backslash right after the equal sign is an error and did not make that change.)
Second, add the following buildscript repository to build.gradle:
google()
Third, change the build.gradle dependency:
classpath 'com.android.tools.build:gradle:3.0.1'
The second and third changes apply the latest version of the Android plug-in.
When I try to sync after these changes it fails again with the following new error:
Plugin with id 'com.android.model.application' not found.
The error refers to the first line of build.gradle:
apply plugin: 'com.android.model.application'
What is happening and why? I recently added NDK to Android Studio. The project I'm trying to sync includes C code. I'm not completely certain I added NDK correctly. I wonder if that could be part of the problem.
First, the gradle-wrapper.properties is incorrect. You must include \ in it. It should be something like this:
#Sat Jun 17 17:47:18 CEST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
Then, add the experimental classpath to project build.gradle. Something like this:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath "com.android.tools.build:gradle-experimental:0.7.0-alpha4"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
Check the Experimental Plugin User Guide for details.
Go to your build.gradle version or update it
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
}
You should change you dependencies classpath
All steps are here :
Open build.gradle and change the gradle version to the recommended version:
classpath 'com.android.tools.build:gradle:1.3.0' to
classpath 'com.android.tools.build:gradle:2.3.2'
Hit 'Try Again'
In the messages box it'll say 'Fix Gradle Wrapper and re-import project' Click that, since the minimum gradle version is 3.3
A new error will popup and say The SDK Build Tools revision (23.0.1) is too low for project ':app'. Minimum required is 25.0.0 - Hit Update Build Tools version and sync project
A window may popup that says Android Gradle Plugin Update recommended, just update from there.
Now the project should be runnable now on any of your android virtual devices.
Make sure your Gradle version is compatible with your Android Gradle Plugin.
https://stackoverflow.com/questions/24795079
https://developer.android.com/studio/releases/gradle-plugin#updating-gradle
I got "Error converting bytecode to dex" in a Chromecast project with Remote Display API. I solved this by adding "multiDexEnabled true", but this only generated another error:
Error:Execution failed for task
':app:transformClassesWithJarMergingForDebug'.>
com.android.build.api.transform.TransformException:
java.util.zip.ZipException: duplicate entry:
com/google/android/gms/internal/zzlg.class
I have checked my Gradle files, but I can not find any conflict. I read other similar threads and tried their code fixes, but no use here. How can I proceed with this?These are my gradle files:
Gradle files
First, try to clean/rebuild the project because usually that kind of error will be gone after you clean/rebuild the project.
From this documentation, when you add multiDexEnabled true in the gradle.files, make sure you also add compile 'com.android.support:multidex:x.x.x' in the dependencies.
For more information, check these related SO questions:
How to enable multidexing with the new Android Multidex support library
java.util.zip.ZipException: duplicate entry
You may be compiling the same dependency multiple times. For example, play-services-cast depends on appcompat-v7. You can prevent recompiling the same dependency with:
compile ('com.google.android.gms:play-services-cast:8.3.+')
{
exclude group: 'com.android.support', module: 'appcompat-v7'
}
Use the shell command gradlew -q YourApp:dependencies to print your app's dependency graph; then in your build.gradle, exclude dependencies that show up multiple times.
I don't know why it happen, but when I want to run a project, I get this message error :
Error:Execution failed for task ':transformClassesWithJarMergingForDebug'.
> com.android.build.api.transform.TransformException:
java.util.zip.ZipException: duplicate entry: android/support/v4/app/FragmentContainer.class
I tried to clean / rebuild project many times, but I got always same error when I run it.
build.gradle:
http://pastebin.com/nnE9bpN7
Do you have any solutions please? I'm really stuck at that.
Thanks
compileSdkVersion 'Google Inc.:Google APIs:23' is supposed to be compileSdkVersion 23. You're adding Google Play services via dependencies.
libs folder is not supposed to contain any support libraries such as support-v4. These are added again as a maven dependency:
compile "com.android.support:support-v4:23.1.1"
compile "com.android.support:appcompat-v7:23.1.1"
compile "com.android.support:design:23.1.1"