My app is working fine, but after adding Mobile Ads SDK, it stops syncing.
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "abc
minSdkVersion 16
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
sourceSets {
main {
assets.srcDirs = ['src/main/assets', 'src/main/assets/images', 'src/main/assets/databases']
res.srcDirs =['src/main/res', 'src/main/res/menu', 'src/main/res/anim', 'src/main/res/values-ja']
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:28.0.0-rc02'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.android.support:support-vector-drawable:28.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'
implementation 'com.sothree.slidinguppanel:library:3.4.0'
implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'com.readystatesoftware.sqliteasset:sqliteassethelper:+'
implementation 'com.google.android.gms:play-services-ads:17.1.1'
}
This is the error.
Manifest merger failed : Attribute
meta-data#android.support.VERSION#value value=(26.0.2) from
[com.android.support:recyclerview-v7:26.0.2]
AndroidManifest.xml:25:13-35
is also present at [com.android.support:customtabs:26.1.0] AndroidManifest.xml:25:13-35 value=(26.1.0).
Suggestion: add 'tools:replace="android:value"' to element at AndroidManifest.xml:23:9-25:38 to override.
I don't know what the error means, have anyone encountered the same problem?
Problem:
Problem is support library version is getting conflicted.
Solution:
First step you need to try is using a common version of support library, you can declare a common variable:
supportLibraryVersion=28.0.0
And refer the same for all the dependencies of the same package:
implementation "com.android.support:appcompat-v7:$supportLibraryVersion"
implementation "com.android.support:support-v4:$supportLibraryVersion"
Second step:
You need to debug the dependencies list, use the ./gradlew dependencies command which will list dependencies tree. Analyse the dependencies tree, you will get to see which library is internally referring which version of the support library:
For example, this older version of the library:
com.android.support:recyclerview-v7:26.0.2
The mobile Ads SDK might have a support library version which is different that is being used in your application. The error clearly says that there is a different version in your AndroidManifest.xml file. The error also suggests -
add 'tools:replace="android:value"' to element at AndroidManifest.xml:23:9-25:38 to override
It also shows the lines where you need to add this. I think that should solve the problem.
Open Your AndroidManifest.xml .you will see Merged Manifest below it . Now from your error log.
[com.android.support:recyclerview-v7:26.0.2]
AndroidManifest.xml:25:13-35 is also present at
[com.android.support:customtabs:26.1.0] AndroidManifest.xml:25:13-35
value=(26.1.0).
Your manifest is having conflict with two version for same library.So click on Merged Manifest and your will get
add 'tools:replace="android:value"' to element at
AndroidManifest.xml:23:9-25:38 to override
Click on it . and issue will be solved.
Related
I'm writing an android plugin for unity to be able to check if notifications are enabled for the game. I have one java class with a method for checking if notifications are enabled. When i build the plugin and then the .apk with unity everything works fine. But after installation, when calling the mehthod i get the following exception:
java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/core/app/NotificationManagerCompat;
The Java class
package com.example.plugin;
import android.app.Activity;
import androidx.core.app.NotificationManagerCompat;
public class NotificationPlugin {
public static boolean areNotificationEnabled(Activity unityActivity) {
return NotificationManagerCompat.from(unityActivity).areNotificationsEnabled();
}
}
buld.gradle
apply plugin: 'com.android.library'
android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
defaultConfig {
minSdkVersion 14
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles 'consumer-rules.pro'
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
}
gradle.properties
org.gradle.jvmargs=-Xmx1536m
android.useAndroidX=true
android.enableJetifier=true
Haven't found a solution anywhere else yet. Thank in advance. It's probably a super simple fix that i miss.
Update
Custom gradle.properties in unity set with android.enableJetifier and android.useAndroidX set to true
Jetifier was enabled in unity
Androidx.Core libary was added to the dependencies of the gradle.build file of the plugin
None of the above solved the issue
Solution
As Hamid Yusifli suggested in his answer a custom gradle build template needs to be enabled (Project Settings>Player>Publishing Settings>Custom Main Gralde Template) and the dependencies for the libary need to be added (implementation 'androidx.core:core:1.5.0' in my case). This solved the issue.
So, seems like in your case unity ignores your library gradle dependencies,
there are many different reasons why this could happen. To force unity to include missing dependencies you must provide a custom Gradle build template and add your dependencies in that file.
I am trying to develop an SFTP client using sshj on Android studio such that the App can connect securely to the server using SFTP over ssh. The code was running fine, but when I added the "sshj-0.10.0" module, it gives me this complicated error.
The "sshj-0.10.0" module is needed to run server code using net library as below:
import net.schmizz.sshj.SSHClient;
import net.schmizz.sshj.sftp.SFTPClient;
I added the module the project and configured it in the dependencies in build.gradel of the app as shown below:
What I have tried so far (but not limited to):
1- Clean Project then Rebuild Project - failed
2- Invalidate Caches / Restart - failed
3- Delete .gradle and .idea from my root project- failed
4- Added
android {
defaultConfig {
multiDexEnabled true
}
}
and
dependencies {// Multidex
implementation 'com.android.support:multidex:1.0.3'
implementation project(path: ':sshj-0.10.0')
}
No solution was worked with me.
Here is my build.gradle(:app)
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.mohsenali.autosen"
minSdkVersion 23
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
android {
defaultConfig {
multiDexEnabled true
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:2.0.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'
//TedPermission
implementation 'gun0912.ted:tedpermission:1.0.3'
implementation files('D:/SKKU_PhD/Android/workspace_2018_projects/AutoSen/app/libs/commons-net-3.7.1.jar')
// Multidex
implementation 'com.android.support:multidex:1.0.3'
implementation project(path: ':sshj-0.10.0')
}
I know that this kind of error is popular but I tried many possible solutions available on SO since two days ago but none of them has helped me. So please don't mark it duplicated, maybe someone could help. Thanks.
Finally, I solved this error bu creating "libs" folder in the root of "app" project, and added the .jar library to it. After that I updated the code in "build.gradle(:app)" by adding this line: "implementation files('path to/app/libs/jsch-0.1.55.jar')".
I changed the name of the package to "com.xxx.xxx" with Refactor > Rename and changed the name of the package and application identifiers tomanifest and gradle. Successful synchronization, everything is OK. According to the instructions delevopers.google Getting Started and delevopers.google Intermediate Ads ads built into my application, previously included in the project structure AdMob. When using gradle, but it cost me to try to run the application on a physical level.
Manifest merge error: Attribute application # appComponentFactory value = (android.support.v4.app.CoreComponentFactory) from [com.android.support:support-compat:28.0.0] AndroidManifest.xml: 22: 18-91
also present in [androidx.core: core: 1.0.0] AndroidManifest.xml: 22: 18-86 value = (androidx.core.app.CoreComponentFactory).
Suggestion: add 'tools: replace = "android: appComponentFactory"' to the <application> element in AndroidManifest.xml: 8: 5-27: 19 to override.
If you advertise android.useAndroidX = true and android.enableJetifier = true in the gradle properties, then everything becomes even worse, because my MainActivity.java extendit isAppCompatActivity, which is not used with the above gradle properties (android.useAndroidX = true)
Well since you did not post your build.gradle file
I suspect that you have the old android support libraries and you are trying to migrate to AndroidX, According to your error it appears that you should be using this one instead
implementation "androidx.appcompat:appcompat:1.0.2"
of
implementation "com.android.support:support-compat:28.0.0"
And a couple of other files related files in that same manner, now before trying to manually fix the paths of androidx , I would recommend that you update to the latest version of Android Studio (3.4.2) and do click Migrate to AndroidX inside the refactor menu
Now sometimes, the error might be in the libraries you want to depend to
If that's the case , heres a workaround ...
configurations {
all*.exclude module: 'support-v4' // This removes all other versions of `support-v4` if gets duplicated from all the artifacts.
api project(':your-awesome-library-goes-here')
}
also if there is a slight chance that you are using butterknife
android{
.
.
// Butterknife requires Java 8.
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
.
.
}
Do a sync , if you still see errors ... then try to check for dependencies to see which library is the culprit
./gradlew app:androidDependencies
Where app is your module's name
Cheers
It is because in gradle you have to also change it to androidX and check your dependency with this
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.google.android.gms:play-services-ads:18.1.1'
implementation 'com.google.android.material:material:1.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
}
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example1.*appname*"
minSdkVersion 22
targetSdkVersion 28
versionCode 3
versionName "3.0"
**testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"**//check this is their or not
}
sometimes we forget to define testInstruement runner
I'm porting my current android apk to meet recent playstore directive - " targetSdkVersion 26"
This my gradle file. I started off with compileSdkVersion 26 and ended up at 28. So for 28 I had to use AndroidX dependencies. Im stuck at the error as posted in subject line. Any help would be very much appreciated.
The error message is
AGPBI: {"kind":"error","text":"error: duplicate value for resource \u0027attr/actionBarSize\u0027 with config \u0027\u0027.","sources":[{"file":"/Users/sk/.gradle/caches/transforms-1/files-1.1/appcompat-1.0.0.aar/34c8fa33903fb2b3203e5c70952da588/res/values/values.xml","position":{"startLine":1303,"startColumn":4,"startOffset":70911,"endColumn":68,"endOffset":70975}}],"original":"","tool":"AAPT"}
AGPBI: {"kind":"error","text":"error: resource previously defined here.","sources":[{"file":"/Users/sk/.gradle/caches/transforms-1/files-1.1/appcompat-1.0.0.aar/34c8fa33903fb2b3203e5c70952da588/res/values/values.xml","position":{"startLine":1303,"startColumn":4,"startOffset":70911,"endColumn":68,"endOffset":70975}}],"original":"","tool":"AAPT"}
:app:mergeDebugResources
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
buildToolsVersion "28.0.3"
defaultConfig {
applicationId "pack.age.net"
minSdkVersion 16
//Since no updates to app can be published in Playstore beginning Nov 1, 2018 - bumping targetSdk to 26 from 19
targetSdkVersion 26
//Double check this before you move this to production
versionCode 22
versionName "3.3"
// Enabling multidex support.
multiDexEnabled true
//Language resources
resConfigs "en", "hi"
}
buildTypes {
release {
//Shrink your code
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
debuggable true
}
}
lintOptions {
checkReleaseBuilds false
}
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE'
}
repositories {
mavenCentral()
maven {
url "http://dl.bintray.com/journeyapps/maven"
}
}
useLibrary 'org.apache.http.legacy'
}
dependencies {
//implementation 'com.android.support:support-v4:28.0.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
// implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'androidx.appcompat:appcompat:1.0.0'
// implementation 'com.android.support:design:28.0.0'
implementation 'com.google.android.material:material:1.0.0'
implementation 'com.google.firebase:firebase-messaging:17.3.4'
//Hockey App for Crash Analytics
implementation 'net.hockeyapp.android:HockeySDK:5.1.1'
//Sundry library files
implementation files('libs/commons-codec-1.9.jar')
implementation files('libs/ksoap2-android-assembly-3.6.0-jar-with-dependencies.jar')
implementation files('libs/libphonenumber-6.2.jar')
//Mutlidex Support
implementation 'com.android.support:multidex:1.0.0'
//Square Picasso Image View
implementation 'com.squareup.picasso:picasso:2.5.2'
//Calligraphy for custom fonts
implementation 'uk.co.chrisjenx:calligraphy:2.2.0'
implementation 'com.squareup.okhttp3:okhttp:3.10.0'
testImplementation 'junit:junit:4.12'
//Apache Commons
implementation 'org.apache.commons:commons-lang3:3.7'
implementation 'com.github.chrisbanes:PhotoView:2.2.0'
// Supports Android 4.0.3 and later (API level 15)
implementation 'com.journeyapps:zxing-android-embedded:2.0.1#aar'
// Supports Android 2.1 and later (API level 7), but not optimal for later Android versions.
// If you only plan on supporting Android 4.0.3 and up, you don't need to include this.
implementation 'com.journeyapps:zxing-android-legacy:2.0.1#aar'
// Convenience library to launch the scanning and encoding Activities.
// It automatically picks the best scanning library from the above two, depending on the
// Android version and what is available.
implementation 'com.journeyapps:zxing-android-integration:2.0.1#aar'
// Version 3.0.x of zxing core contains some code that is not compatible on Android 2.2 and earlier.
// This mostly affects encoding, but you should test if you plan to support these versions.
// Older versions e.g. 2.2 may also work if you need support for older Android versions.
implementation 'com.google.zxing:core:3.0.1'
//Firebase
implementation 'com.google.firebase:firebase-core:16.0.1'
}
apply plugin: 'com.google.gms.google-services'
hello there~ I too got a disaster moving to Androidx... according to google document you should locate the gradle property and add these two lines which works fine for me!
android.enableJetifier=true
android.useAndroidX=true
Good Luck dude~
The proper answer might be, to update the Firebase dependencies to have versions, which already use androidx dependencies and if this should not be enough, to also enable the Jetfier, in case other libraries pull in com.android.support dependencies, which need to be re-written. To do so, add this into the gradle.properties file:
android.enableJetifier=true
android.useAndroidX=true
PS_ANDROIDBUILDTOOLSVERSION=29.0.1
android.aapt2FromMavenOverride=${Android_home}/build-tools/29.0.1/aapt2
disable aapt2 from maven
We need to change XML layout, any support value need to change to androiddx value
android.support.v4.widget.SwipeRefreshLayout need to change to androidx.swiperefreshlayout.widget.SwipeRefreshLayout
I am trying to integrate Facebook sign in feature to my android app using Firebase-UI library. I am following this tutorial - https://firebase.google.com/docs/auth/android/firebaseui?authuser=0
But I am getting below error while trying to build gradle:
The library com.google.android.gms:play-services-basement is being requested by various other libraries at [[15.0.1,15.0.1]], but resolves to 16.0.1. Disable the plugin and check your dependencies tree using ./gradlew :app:dependencies.
Below is my app level build.gradle file
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "company.com.mygame"
minSdkVersion 15
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.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 'pl.droidsonroids.gif:android-gif-drawable:1.2.0'
implementation 'com.facebook.android:facebook-android-sdk:4.37.0'
implementation 'com.google.firebase:firebase-core:16.0.4'
implementation 'com.firebaseui:firebase-ui-auth:4.2.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'
}
apply plugin: 'com.google.gms.google-services'
I saw below links -
com.google.android.gms:play-services-measurement-base is being requested by various other libraries
https://github.com/OneSignal/OneSignal-Gradle-Plugin/issues/37
But then I get this error -
Manifest merger failed : uses-sdk:minSdkVersion 15 cannot be smaller than version 16 declared in library [com.firebaseui:firebase-ui-auth:4.2.0] C:\Users\me\.gradle\caches\transforms-1\files-1.1\firebase-ui-auth-4.2.0.aar\xxx\AndroidManifest.xml as the library might be using APIs not available in 15
Suggestion: use a compatible library with a minSdk of at most 15,
or increase this project's minSdk version to at least 16,
or use tools:overrideLibrary="com.firebase.ui.auth" to force usage (may lead to runtime failures)
But the issue is still not fixed. I have just started learning android, not sure what am I missing.
I had the same issue
Just make sure that you have the latest versions of all the dependencies. I used the current versions for Firebase core and auth.
You can get the latest versions from here .
Using the latest version at current point of time:
in app/build.gradle :
dependencies {
...
// Add these code
implementation 'com.google.firebase:firebase-core:16.0.8'
implementation 'com.google.firebase:firebase-auth:16.2.0'
}
in android/build.gradle :
buildscript {
ext {
...
minSdkVersion = 16
...
}
}
Your error says : uses-sdk:minSdkVersion 15 cannot be smaller than version 16 and your build.gradle as minSdkVersion 15. Try to change it to 16 and see if that works for you.
All the best for learning android. May the force be with you.
Over and out,
Aashish