Getting Error after using Applovin plugin Android Studio - android

My App was working perfectly and smoothly without adding the applovin SDK, how do I solve the issue of the problem that I encountered?
Here's my Gradle file (Root)
buildscript {
repositories {
maven { url 'https://artifacts.applovin.com/android' }
google()
}
dependencies {
//4.3.1
classpath 'com.android.tools.build:gradle:4.3.1'
classpath 'com.google.gms:google-services:4.3.10'
classpath "com.applovin.quality:AppLovinQualityServiceGradlePlugin:3.0.0"
}
}// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id 'com.android.application' version '7.1.1' apply false
id 'com.android.library' version '7.1.1' apply false
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Here's my Gradle app level
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'applovin-quality-service'
applovin {
apiKey "OkvHFuab6SR_8RzKBqWGvaAdGFTuBmTQiITRJzo2fV0PulrwAyX1OfftyR3O9JsC5eGR7vbUp76zHLFI6TQ1FF"
}
android {
compileSdk 31
defaultConfig {
applicationId "com.test.app"
minSdk 21
targetSdk 31
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
//FIREBASE
implementation platform('com.google.firebase:firebase-bom:28.0.0')
implementation 'com.google.android.gms:play-services-auth:20.2.0'
implementation 'com.google.firebase:firebase-auth'
implementation 'com.google.firebase:firebase-database:'
implementation 'com.firebaseui:firebase-ui-database:8.0.1'
implementation 'com.google.firebase:firebase-storage'
//CONSTANT SIZE
implementation 'com.intuit.sdp:sdp-android:1.0.6'
implementation 'com.intuit.ssp:ssp-android:1.0.6'
//NEUMORPH
implementation 'com.github.fornewid:neumorphism:0.3.0'
//ANIMATED BOTTOM BAR NAVIGATION
implementation 'com.github.chetankoli1.BottomNavigation:chetanbottomnavigation:0.0.3'
//LOAD IMAGES FROM ONLINE
implementation 'com.github.bumptech.glide:glide:4.13.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.13.0'
//CIRCLE IMAGE
implementation 'de.hdodenhof:circleimageview:3.1.0'
//ADS
implementation 'com.applovin:applovin-sdk:11.4.0'
implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'com.google.android.material:material:1.6.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}
This is the error that i am getting when trying to run the app
> Task :app:safedkAdjustInputsDebug FAILED
AGPBI: {"kind":"warning","text":"API 'MergedFlavor.getApplicationId()' is obsolete and has been replaced with 'Variant.getApplicationId()'.\nIt will be removed in version 7.0 of the Android Gradle plugin.\nGradle Properties must be used to change Variant information.\nFor more information, see https://d.android.com/r/tools/use-properties.\nTo determine what is calling MergedFlavor.getApplicationId(), use -Pandroid.debug.obsoleteApi=true on the command line to display more information.","sources":[{}]}
FAILURE: Build completed with 2 failures.
1: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':app:processDebugManifest'.
> Error processing manifest file for variantdebug
* Try:
Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:processDebugManifest'.
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.lambda$executeIfValid$1(ExecuteActionsTaskExecuter.java:188)
at org.gradle.internal.Try$Failure.ifSuccessfulOrElse(Try.java:282)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeIfValid(ExecuteActionsTaskExecuter.java:186)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:174)
at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:109)
at org.gradle.api.internal.tasks.execution.FinalizePropertiesTaskExecuter.execute(FinalizePropertiesTaskExecuter.java:46)
at org.gradle.api.internal.tasks.execution.ResolveTaskExecutionModeExecuter.execute(ResolveTaskExecutionModeExecuter.java:51)
at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:57)
API 'MergedFlavor.getApplicationId()' is obsolete and has been replaced with 'Variant.getApplicationId()'.
It will be removed in version 7.0 of the Android Gradle plugin.
Gradle Properties must be used to change Variant information.
For more information, see https://d.android.com/r/tools/use-properties.
To determine what is calling MergedFlavor.getApplicationId(), use -Pandroid.debug.obsoleteApi=true on the command line to display more information.
https://docs.gradle.org/7.2/userguide/validation_problems.html#missing_annotation for more details about this problem.
- In plugin 'applovin-quality-service' type 'com.safedk.gradleplugin.tasks.AdjustInstrumentationInputsTask' property 'variant' is missing an input or output annotation.
Reason: A property without annotation isn't considered during up-to-date checking.
Possible solutions:
1. Add an input or output annotation.
2. Mark it as #Internal.
To make it short, here's the cause of the problem
org.gradle.api.GradleException: Error processing manifest file for variantdebug
and,
Caused by: groovy.lang.MissingPropertyException: Could not get unknown property 'manifestOutputDirectory' for task ':app:processDebugManifest' of type com.android.build.gradle.tasks.ProcessMultiApkApplicationManifest.
Any help is highly appreciable

Related

Android faild build the project (Caused by: java.lang.ClassNotFoundException: org.antlr.v4.runtime.CharStreams)

FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':app:kaptDebugKotlin'.
A failure occurred while executing org.jetbrains.kotlin.gradle.internal.KaptExecution
java.lang.reflect.InvocationTargetException (no error message)
Try:
Run with --info or --debug option to get more log output. Run with --scan to get full insights.
Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:kaptDebugKotlin'.
.......
Caused by: java.lang.NoClassDefFoundError: org/antlr/v4/runtime/CharStreams
....
Caused by: java.lang.ClassNotFoundException: org.antlr.v4.runtime.CharStreams
... 45 more
Build.gradle file (module):
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
defaultConfig {
applicationId "org.bloodwyn.userdata"
minSdkVersion 24
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
configurations.all() {
resolutionStrategy.force "org.antlr:antlr4-runtime:4.5.3"
resolutionStrategy.force "org.antlr:antlr4-tool:4.5.3"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
dataBinding {
enabled = true
}
compileOptions {
coreLibraryDesugaringEnabled = true
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = JavaVersion.VERSION_1_8.toString()
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
coreLibraryDesugaring "com.android.tools:desugar_jdk_libs:1.0.9"
//kotlin
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
//android
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.core:core-ktx:1.3.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation "androidx.recyclerview:recyclerview:1.1.0"
// For control over item selection of both touch and mouse driven selection
implementation "androidx.recyclerview:recyclerview-selection:1.1.0-rc01"
//retrofit
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
//okhttp
implementation 'com.squareup.okhttp3:okhttp:4.7.2'
implementation 'com.squareup.okhttp3:logging-interceptor:4.7.2'
//rxjava
implementation 'io.reactivex.rxjava3:rxjava:3.0.2'
implementation 'io.reactivex.rxjava3:rxandroid:3.0.0'
implementation "com.github.akarnokd:rxjava3-retrofit-adapter:3.0.0"
//room
def room_version = "2.2.5"
implementation "androidx.room:room-runtime:$room_version"
implementation "androidx.room:room-rxjava2:$room_version"
kapt "androidx.room:room-compiler:$room_version"
//tests
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.ext:truth:1.2.0'
androidTestImplementation 'com.google.truth:truth:1.0'
androidTestImplementation 'androidx.test:core:1.2.0'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test:rules:1.2.0'
debugImplementation 'androidx.fragment:fragment-testing:1.2.5'
//mock http server for tests
testImplementation 'com.squareup.okhttp3:mockwebserver:4.6.0'
//room test
testImplementation "androidx.room:room-testing:$room_version"
}
build.gradle project:
buildscript {
ext.kotlin_version = '1.3.72'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.0.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
I added this:
configurations.all() {
resolutionStrategy.force "org.antlr:antlr4-runtime:4.5.3"
resolutionStrategy.force "org.antlr:antlr4-tool:4.5.3"
}
becouse if i dont i got the "ANTLR Tool version 4.5.3 used for code generation does not match the current runtime version 4.7.1ANTLR Runtime version 4.5.3 used for parser compilation does not match the current runtime version 4.7.1" exception
I have some suggestions that may help some folks with auto-regenerating the ANTLR4 code for use on Android with Android Studio and Gradle. A complete working example of my setup is found with my project here.
First, to answer part of the poster's question. The org.antlr:antlr4-runtime:4.5.3 and org.antlr:antlr4-tool:4.5.3 packages seem dated. Even though many older posts suggest using these dependencies. I have found that the following will include the most recent version of ANTLR4 (check the ANTLR4 repository for updated versions):
dependencies {
// ...
implementation 'org.antlr:antlr4:4.9.1'
}
With typical Android applications, we need to apply the following stock plugin first:
apply plugin: 'com.android.application'
The problem is that this breaks Gradle's use with the ANTLR4 plugin. A work around is to install the antlr4 utility in your shell path and then do something like the following in the application build.gradle configuration:
/* NOTE: The gradle plugin with Android does not work, this is a shell command within the standard system paths. */
def generateAntlrJava(String grammarFile) {
def scriptRunCmd = "antlr -o app/src/main/antlr-gen -package 'com.my.package.name' -Dlanguage=Java" +
" -listener -visitor -long-messages -lib 'path/to'" +
" -Xexact-output-dir 'path/to" + grammarFile + "'";
def cmdResult = ['bash', '-c', scriptRunCmd].execute();
cmdResult.waitFor();
return cmdResult.text
}
task PreBuildGenAntlr4JavaSources {
println 'REMOVING OLD ANTLR4 JAVA SOURCES ==> '
file(new File('app/src/main/antlr-gen')).deleteDir()
println 'GENERATING ANTLR4 JAVA SOURCES ==> '
file(new File('app/src/main/antlr-gen')).mkdirs()
generateAntlrJava("MyScriptLexer.g4")
generateAntlrJava("MyScriptParser.g4")
outputs.upToDateWhen { false } /* Make the task run every time (no UP-TO-DATE skippage) */
}
preBuild.dependsOn PreBuildGenAntlr4JavaSources
task cleanPreBuildGenAntlr4JavaSources {
println 'REMOVING OLD ANTLR4 JAVA SOURCES ==> '
file(new File('app/src/main/antlr-gen')).deleteDir()
println 'GENERATING ANTLR4 JAVA SOURCES ==> '
file(new File('app/src/main/antlr-gen')).mkdirs()
generateAntlrJava("MyScriptLexer.g4")
generateAntlrJava("MyScriptParser.g4")
}
clean.dependsOn cleanPreBuildGenAntlr4JavaSources
That's it. The only solution that worked for my use case :)

Could not resolve androidx.databinding:databinding-compiler:3.5.3

I just Convert my project to androidX and project build successfully. But when I want to run that time it's created this error in android studio 3.5.3 with java enabled.
Here's my project gradle:
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.3'
classpath 'com.google.gms:google-services:4.3.3'
}
}
allprojects {
repositories {
google()
jcenter()
maven { url "https://jitpack.io" }
}
}
My module gradle file: All dependency I add here.
apply plugin: 'com.android.application'
android {
dataBinding {
enabled = true
}
compileSdkVersion 28
defaultConfig {
applicationId "com.exam.test"
minSdkVersion 16
targetSdkVersion 28
versionCode 1
versionName "1.0.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
multiDexEnabled true
signingConfig signingConfigs.release
}
}
compileOptions {
targetCompatibility JavaVersion.VERSION_1_8
sourceCompatibility JavaVersion.VERSION_1_8
}
//Dependencies
dependencies {
api 'com.google.android.material:material:1.0.0'
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.google.android.material:material:1.0.0'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.recyclerview:recyclerview:1.1.0'
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
implementation 'com.google.android.gms:play-services-location:16.0.0'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
implementation 'com.google.code.gson:gson:2.8.5'
implementation('com.crashlytics.sdk.android:crashlytics:2.8.0#aar') {
transitive = true
}
implementation 'androidx.biometric:biometric:1.0.1'
}
apply plugin: 'com.google.gms.google-services'
googleServices.disableVersionCheck = true
Build output: Here pom details not download when running the application
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'.
> Could not resolve all task dependencies for configuration ':app:debugAnnotationProcessorClasspath'.
> Could not resolve androidx.databinding:databinding-compiler:3.5.3.
Required by:
project :app
> Could not resolve androidx.databinding:databinding-compiler:3.5.3.
> Could not get resource 'https://dl.google.com/dl/android/maven2/androidx/databinding/databinding-compiler/3.5.3/databinding-compiler-3.5.3.pom'.
> Could not GET 'https://dl.google.com/dl/android/maven2/androidx/databinding/databinding-compiler/3.5.3/databinding-compiler-3.5.3.pom'.
> Remote host closed connection during handshake
* 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.
these type of problems occure because of some library are not in harmoney with each other
then you should update maybe your problem will be gone .
i had same problem and now resolved it.
first upgrade your gradle
distributionUrl=https://services.gradle.org/distributions/gradle-5.6.4-all.zip
second update your kotlin-plugin
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.61"
third update your android studio to last version 3.6 or higher
note : this part maybe show error then you should update your constraint layout
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta3'
i hope you resolve it
Finally, I solved it by increasing internet speed.
It's because of internet issues. As regular internet, it's created problems. But when I increased internet speed now the problem is solved.
Now it's working properly.

I implemented VirtualAPK library and getting Execution failed for task ':app:compileDebugJavaWithJavac'

I am implemented VirtualAPK library and failed to build project
My Project gradle file:
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.1'
classpath 'com.didi.virtualapk:gradle:0.9.8.6'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Also I implemented library and applied as per library guide in Module gradle:
apply plugin: 'com.android.application'
apply plugin: 'com.didi.virtualapk.host'
android {
compileSdkVersion 28
dataBinding {
enabled = true
}
defaultConfig {
applicationId "com.example.vspace"
minSdkVersion 19
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.didi.virtualapk:core:0.9.8'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
And after that I am trying to build project and getting Error like():
Compiling with JDK Java compiler API.
Created classpath snapshot for incremental compilation in 0.024 secs.
[INFO][VAHostPlugin] Used compileClasspath: debug
> Task :app:compileDebugJavaWithJavac FAILED
:app:compileDebugJavaWithJavac (Thread[Daemon worker,5,main]) completed. Took 2.586 secs.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:compileDebugJavaWithJavac'.
> java.lang.NoSuchMethodException: No similar method computeBuildMapping with params [class org.gradle.invocation.DefaultGradle_Decorated] could be found on type class com.android.build.gradle.internal.ide.ModelBuilder.
* Try:
Run with --stacktrace option to get the stack trace. Run with --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
I was also tried to downgrade and upgrade gradle version and also tried with old Android Studio 3.0.1 and with 3.4.1. But nothing is working here. So, if any one can help then its surely acceptable.
I also refers This question but its can't helped me.
VirtualApk is doing this.....and computeBuildMapping is not supported(based on error in your post) in gradle 3.4.1.
if (project.extensions.extraProperties.get(Constants.GRADLE_3_1_0)) {
ImmutableMap<String, String> buildMapping = Reflect.on('com.android.build.gradle.internal.ide.ModelBuilder')
.call('computeBuildMapping', project.gradle)
.get()
compileArtifacts = ArtifactDependencyGraph.getAllArtifacts(
applicationVariant.variantData.scope, AndroidArtifacts.ConsumedConfigType.COMPILE_CLASSPATH, null, buildMapping)
} else {
compileArtifacts = ArtifactDependencyGraph.getAllArtifacts(
applicationVariant.variantData.scope, AndroidArtifacts.ConsumedConfigType.COMPILE_CLASSPATH, null)
}
so, try building your project with gradle plugin 3.1.0 and gradle version 4.4
dependencies {
classpath 'com.android.tools.build:gradle:3.1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
gradle-wrapper.properties
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip

Could not resolve com.android.tools.build:gradle:3.3.2

I was trying to add firebase auth to my android project but getting this error.
I have tried adding 'com.google.firebase:firebase-core:16.0.3' too but its taking more than 40 mins and still not syncing the gradle.
This is build.gradle file:
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 28
defaultConfig {
applicationId "myaid.startup"
minSdkVersion 21
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.google.firebase:firebase-auth:16.0.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
This is app.gradle file:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.2'
classpath 'com.google.gms:google-services:4.1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
This is the error:
FAILURE: Build failed with an exception.
What went wrong: A problem occurred configuring root project 'MyAid'.
Could not resolve all artifacts for configuration ':classpath'.
Could not resolve com.android.tools.build:gradle:3.3.2.
Required by:
project :
Could not resolve com.android.tools.build:gradle:3.3.2.
Could not get resource 'https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.3.2/gradle-3.3.2.pom'.
Could not GET 'https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.3.2/gradle-3.3.2.pom'.
Connection reset
Could not resolve com.android.tools.build:gradle:3.3.2.
Could not get resource 'https://jcenter.bintray.com/com/android/tools/build/gradle/3.3.2/gradle-3.3.2.pom'.
Could not GET 'https://jcenter.bintray.com/com/android/tools/build/gradle/3.3.2/gradle-3.3.2.pom'.
Connection reset
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
CONFIGURE FAILED in 2m 13s ERROR: Connection reset
I have resolved this problem by removing all my .gradle files, SDK files, .m2 files, .androidstudio files and then re-installing it.
Followed this answer: How to completely uninstall Android Studio
Please check your gradle's proxy settings. Enable it or disable it in the following file:
~/.gradle/gradle.properties
Like:
systemProp.https.proxyPort=1080
systemProp.http.proxyHost=127.0.0.1
systemProp.https.proxyHost=127.0.0.1
systemProp.http.proxyPort=1080
Advices:
If your connection to repositories is not stable, use a proxy
instead of direct connection.
If you used to use a proxy for
gradle, check if it is still working.

Why does android.arch.navigation cause Program type already present: android.support.v4.os.ResultReceiver$1?

I am using Android Studio version
Android Studio 3.2 Canary 14
Build #AI-181.4668.68.32.4763614, built on May 4, 2018
JRE: 1.8.0_152-release-1136-b02 x86_64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Mac OS X 10.11.6
While investigating the new Architectural navigation components android.arch.navigation I have encountered this build failure.
AGPBI: {"kind":"error","text":"Program type already present: android.support.v4.os.ResultReceiver$1","sources":[{}],"tool":"D8"}
:app:transformDexArchiveWithExternalLibsDexMergerForDebug FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
> com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives: ...
...
Program type already present: android.support.v4.os.ResultReceiver$1
My app gradle build resembles:-
apply plugin: 'com.android.application'
apply plugin: "androidx.navigation.safeargs"
android {
compileSdkVersion 'android-P'
defaultConfig {
applicationId "com.research.frager"
minSdkVersion 19
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
def nav_version = "1.0.0-alpha01"
implementation "android.arch.navigation:navigation-fragment:$nav_version"
implementation "android.arch.navigation:navigation-ui:$nav_version"
// optional - Test helpers
androidTestImplementation "android.arch.navigation:navigation-testing:$nav_version"
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.0.0-alpha1'
implementation 'androidx.constraintlayout:constraintlayout:1.1.0'
implementation 'androidx.lifecycle:lifecycle-extensions:2.0.0-alpha1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.0-alpha2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0-alpha2'
}
and project level gradle build:-
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.0-alpha14'
classpath "android.arch.navigation:navigation-safe-args-gradle-plugin:1.0.0-alpha01"
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
I have tried refactoring to AndroidX, however I get a message stating No usages found in project, so why is this "v4" class still being mentioned?
I've been looking at this issue and I have sorted the main issue here by excluding the support package when adding the dependency to the library, doing this:
implementation("android.arch.navigation:navigation-fragment:$nav_version") {
exclude group: 'com.android.support'
}
That would allow you to run the application. However, this artifact is using the support artifacts rather than the androidx artifacts. Looking at the documentation, we can see that NavHostFragment is extending support.v4.Fragment
https://developer.android.com/reference/androidx/navigation/fragment/NavHostFragment
So, in short, you are presented with three options, as far as I can see. The first one is to drop the androidx artifacts and use the support ones which eventually depends on how big your app is.
The second option is to drop the navigation library and go back to the classic way of dealing with navigation which, I guess, is probably undesirable for you.
The third option is to implement a navigation host of your own which I don't know how much work it would be.
This response will remain accurate until Google releases the androidx version of the library which I am surprised they haven't already.
Hope that was helpful.

Categories

Resources