Problems with implementing and running Here API - java

I'm trying to build an app with the Here Maps API.
Based on this example , I try to build the very basic form of a Here map in my app.
By following the instructions I still had to manage a load of issues. I managed most of them I think but there are some problems with or in the Java compiler (I guess?). It tells me that a deprecated API has to be overwritten.
When I use the "Make Project" function, Android Studio gives me 4 errors after checking the Java compiler:
Caused by: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Error while
merging dex archives
Caused by: com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives
Caused by: com.android.tools.r8.CompilationFailedException: Compilation failed to complete
Caused by: com.android.tools.r8.utils.AbortException: Error: Program type already present: com.a.a.a$a
Is there something with the example from Here Developers that is outdated right now and has to be fixed manually? I just used the instructions in that example, nothing else.

Please check if your gradle file dependencies are looking something like this. Include HERE-sdk.aar explicitly like given below:
dependencies {
implementation fileTree(dir: 'libs', include: ['HERE-sdk.aar'])
implementation 'com.android.support:appcompat-v7:28.0.0-rc02'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
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'
compile 'com.google.code.gson:gson:2.8.0'
}

Which version of Android Studio do you use? Do you use additional dependencies in your app?
Seems there are mismatches in dex archives. To solve that, could you pease try to update app/build.gradle with the following?
android {
defaultConfig {
multiDexEnabled true
}
}

Related

Error: Program type already present: com.google.firebase.auth.FirebaseAuthException

I am getting following error while building my project while I haven't used firebase auth in my project:
Error: Program type already present: com.google.firebase.auth.FirebaseAuthException
I have tried following but nothing seems to work
Use navigation option
clean rebuild
invalid cache
exclude group module
my dependencies are as:
dependencies {
implementation fileTree( dir: 'libs',include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support:support-vector-drawable:27.1.1'
implementation 'android.arch.lifecycle:extensions:1.1.1'
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'
implementation ('com.google.firebase:firebase-admin:6.8.0'){
exclude module:'com.google.firebase-auth'
}
}
implementation 'com.google.firebase:firebase-firestore:19.0.1'
You can't use the Firebase Admin SDK in an Android app. It can only be used in a trusted environment, such as your development machine, a server you control, or Cloud Functions.
If you remove this dependency, the error should disappear:
implementation ('com.google.firebase:firebase-admin:6.8.0'){
This problem usually come from a naming conflict (Most probably because a class appears more than once in your project either in the form of dependencies or a mistake).
To find the list of dependencies for the module 'x' we can run
./gradlew x:dependencies to retrieve a list of all the libraries.
From the dependency tree, you an figure out if there is a class/library with the same name being used by two libraries. Based on this finding, you can choose to exclude the module in one of the libraries that are causing the conflict.

Error [duplicateplatformclasses] while building app in release mode

After updating Android Studio and updated GDAA to Google Drive REST API as GDAA is deprecated, but now I can not build my app in release mode which had no issues before. Here is the complete error message:
org.gradle.api.GradleException: Lint found fatal errors while assembling a release target. To proceed, either fix the issues identified by lint, or modify your build script as follows:
...
android {
lintOptions {
checkReleaseBuilds false
// Or, if you prefer, you can continue to check for errors in release builds,
// but continue the build even when errors are found:
abortOnError false
}
}
And in the lint-results-release-fatal.xml file I get these messages:
'commons-logging' defines classes that conflict with classes now
provided by Android. Solutions include finding newer versions or
alternative libraries that don't have the same problem (for example,
for httpclient use HttpUrlConnection or okhttp instead), or
repackaging the library using something like jarjar.
'httpclient' defines classes that conflict with classes now provided
by Android. Solutions include finding newer versions or alternative
libraries that don't have the same problem (for example, for
httpclient use HttpUrlConnection or okhttp instead), or repackaging
the library using something like jarjar.
Here is my gradle dependencies:
dependencies {
testImplementation 'junit:junit:4.12'
implementation 'com.android.support:support-core-utils:27.1.1'
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:recyclerview-v7:27.1.1'
implementation 'com.android.support:support-v4:27.1.1'
implementation 'com.android.support:multidex:1.0.3'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.google.android.gms:play-services-ads:17.1.3'
implementation 'com.google.android.gms:play-services-auth:16.0.1'
implementation 'com.google.http-client:google-http-client-gson:1.26.0'
implementation('com.google.api-client:google-api-client-android:1.26.0') {
exclude group: 'org.apache.httpcomponents'
}
implementation('com.google.apis:google-api-services-drive:v3-rev136-1.25.0') {
exclude group: 'org.apache.httpcomponents'
}
}
I tried this and this but no luck.
After trying all other solutions with no luck, I suddenly discovered that this version of Android Studio 3.3.2 does not detect libraries which are out of date and found that the library causing the problem was this:
implementation 'com.google.http-client:google-http-client-gson:1.26.0'
As this is the suspected library from this question.
I simply updated this library to the latest version which is this at the moment:
implementation 'com.google.http-client:google-http-client-gson:1.28.0'
And the problem was solved.
I post this question and give answer just because I could not find the right answer and for those struggling with the same problem could be the right solution.

Gradle incompatibility with admob [duplicate]

This question already has answers here:
All com.android.support libraries must use the exact same version specification
(54 answers)
Closed 4 years ago.
I'm trying to add a banner add to a new app of mine and I've hit a roadblock adding the Gradle dependencies. I've been following the Admob tutorial on how to do it Admob Get Started Link
What I'm trying to use is the following
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.google.android.gms:play-services-ads:17.0.0'
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'}
However the line with "appcompat-v7:27.1.1" gets underlined with the following message:
All com.android.support libraries must use the exact same version
specification, Found version 27.1.1, 26.1.0. Examples include
com.android.support:animated-vector-drawable:27.1.1
andcom.android.supports:customtabs:26.1.0
This underline warning only shows up when I add in the dependency for admob, specifically:
implementation 'com.google.android.gms:play-services-ads:17.0.0'
How/what should I be doing to fix this? I was testing this out earlier in the week and I didn't have any errors, the only thing I've added since then is permissions for phone vibration which I can't imagine has any effect. My app crashes on the opening screen
The issue is happening because there are two different versions of support libraries sync one by ads and another by app compat
To solve the issue use
configurations.all
{ resolutionStrategy.force 'com.android.supports:customtabs:27.1.1'
resolutionStrategy.force 'com.android.support:animated-vector-drawable:27.1.1'
 }
dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']
........
Have you tried adding the library with the old version, but with new version??
com.android.support:customtabs:26.1.0 is your error so you need to add this:
implementation "com.android.support:customtabs:27.1.1"
It's an confusing error because you are not directly using this library, but more of the libraries you use, depend on this one, so you have to explicitly set which version to use

Gradle build successfully but Getting Runtime Error Error:Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'

Error:Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'. > Could not create service of type AnnotationProcessorDetector using JavaGradleScopeServices.createAnnotationProcessorDetector().
I'm getting the above error, I tried alot of things (Set jdk path,add support-annotation library e.t.c)to remove this error but nothing changed. I'm using Android Studio 3.0.1 and toolbar inside my app,minSdk 15 ,maxSdk 26.
This is my gradle:
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.0
testImplementation 'junit:junit:4.12'
There would be sure some error with this, try to toggle gradle view. See below image. You will find error..
Also click on red titled line in this view, it will tell you error.

Failed to resolve project: Android library and Java library module dependency

I'm trying to create a project which includes an Android library and a Java library in Android Studio (3.1). The Java library depends on the Android library. Both are modules in my project like this:
MyProject
|-android
|-java
Both appear in settings.gradle:
include ':android', ':java'
And the Java library depends on the Android library like this:
java (build.gradle):
apply plugin: 'java-library'
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation project(':android')
}
...
android (build.gradle):
apply plugin: 'com.android.library'
...
When trying to sync the project I'm getting the following error:
Failed to resolve: project::android
Why?
P.S. The other way around (Android depending on Java) works just fine.
First let's try to fix the build error. Let's run ./gradlew build --stacktrace to see a more detailed output:
Caused by: org.gradle.internal.component.AmbiguousConfigurationSelectionException:
Cannot choose between the following configurations of project :androidLibrary:
debugApiElements
releaseApiElements
AGP is confused which variant to choose. After inspecting this answer, we can find how to overcome the issue:
implementation project(path: ':androidLibrary', configuration: 'default')
After trying to sync the project with that setup you'll see following output in console:
Ignoring dependency of module 'androidLibrary' on module 'javaLibrary'. Java modules cannot depend on Android modules
Thus, seems like what you try to do is not supported by the plugin.
Refer to similar question, where Nick Cardoso tries to clarify the case.

Categories

Resources