useOldManifestMerger causes build error - android

I'm trying to use this new feature available in the version 0.10.0 of the Gradle Plugin for Android. But I keep getting this error message:
FAILURE: Build failed with an exception.
What went wrong: Execution failed for task ':xxxxxx:processDebugManifest'.
Manifest merger failed : uses-sdk:minSdkVersion 1 cannot be smaller than version 7 declared in library
com.android.support:appcompat-v7:19.1.0
Here's my build.gradle
apply plugin: 'android'
android {
compileSdkVersion 19
buildToolsVersion '19.0.3'
useOldManifestMerger false
defaultConfig {
minSdkVersion 9
targetSdkVersion 19
}
buildTypes {
release {
runProguard true
proguardFile 'proguard-zap.cfg'
signingConfig signingConfigs.release
debuggable false
zipAlign true
}
debug {
packageNameSuffix ".debug"
debuggable true
runProguard false
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
}
dependencies {
compile fileTree(dir: 'libs')
compile 'com.android.support:appcompat-v7:+'
compile 'com.google.android.gms:play-services:+'
compile 'com.google.code.gson:gson:+'
androidTestCompile files('libs/espresso-1.1-bundled.jar')
}
How do I solve this?

I had the same error.
As a temporary fix, you can add this in your manifest file:
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="19"
tools:replace="minSdkVersion, targetSdkVersion"/>
The tools namespace is declared as follow: xmlns:tools="http://schemas.android.com/tools". The downside of this fix is that you have to keep build.gradle and the manifest in sync with the value in minSdkVersion and targetSdkVersion. Hopefully it will be fixed in 0.10.1.

Looks like it was fixed in 0.10.4

Related

Support library v4 aar in doesn't convert automatically to androidX in unity project

I have an AR project in unity and i just added Mapbox to the project which immediately caused this error:
What went wrong:
Could not determine the dependencies of task ':launcher:lintVitalRelease'.
Could not resolve all artifacts for configuration ':launcher:debugRuntimeClasspath'.
Failed to transform artifact 'support-v4-25.1.0.aar (:support-v4-25.1.0:)' to match attributes {artifactType=jar}.
>>>> Execution failed for JetifyTransform: C:\Users\EFGH\Documents\GitHub\national-trail\NationalTrail\Temp\gradleOut\unityLibrary\libs\support-v4-25.1.0.aar.
>>>>> Failed to transform 'C:\Users\EFGH\Documents\GitHub\national-trail\NationalTrail\Temp\gradleOut\unityLibrary\libs\support-v4-25.1.0.aar' using Jetifier. Reason: The given artifact contains a string literal with a package reference 'android.support.v4' that cannot be safely rewritten. Libraries using reflection such as annotation processors need to be updated manually to add support for androidx.. (Run with --stacktrace for more details.)
I have googled this error in so many variations but found nothing relevant, i have deleted the Library folder and rebuilt it but the error persists, i have added android.useAndroidX=true and android.enableJetifier=true in my gradle.properties file but it didn't do anything.
Here is my mainTemplate.gradle:
// GENERATED BY UNITY. REMOVE THIS COMMENT TO PREVENT OVERWRITING WHEN EXPORTING AGAIN
apply plugin: 'com.android.library'
**APPLY_PLUGINS**
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.google.android.gms:play-services-maps:17.0.1'
implementation 'com.google.android.gms:play-services-location:18.0.0'
**DEPS**}
android {
compileSdkVersion **APIVERSION**
buildToolsVersion '**BUILDTOOLS**'
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
defaultConfig {
minSdkVersion **MINSDKVERSION**
targetSdkVersion **TARGETSDKVERSION**
ndk {
abiFilters **ABIFILTERS**
}
versionCode **VERSIONCODE**
versionName '**VERSIONNAME**'
consumerProguardFiles 'proguard-unity.txt'**USER_PROGUARD**
}
lintOptions {
abortOnError false
}
aaptOptions {
noCompress = ['.ress', '.resource', '.obb'] + unityStreamingAssets.tokenize(', ')
ignoreAssetsPattern = "!.svn:!.git:!.ds_store:!*.scc:.*:!CVS:!thumbs.db:!picasa.ini:!*~"
}**PACKAGING_OPTIONS**
}**REPOSITORIES**
**IL_CPP_BUILD_SETUP**
**SOURCE_BUILD_SETUP**
**EXTERNAL_SOURCES**
And here is my launcherTemplate.gradle: ( i have no idea what the ** SOMEWORD ** means..)
// GENERATED BY UNITY. REMOVE THIS COMMENT TO PREVENT OVERWRITING WHEN EXPORTING AGAIN
apply plugin: 'com.android.application'
dependencies {
implementation project(':unityLibrary')
}
android {
compileSdkVersion **APIVERSION**
buildToolsVersion '**BUILDTOOLS**'
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
defaultConfig {
minSdkVersion **MINSDKVERSION**
targetSdkVersion **TARGETSDKVERSION**
applicationId '**APPLICATIONID**'
ndk {
abiFilters **ABIFILTERS**
}
versionCode **VERSIONCODE**
versionName '**VERSIONNAME**'
}
aaptOptions {
noCompress = ['.ress', '.resource', '.obb'] + unityStreamingAssets.tokenize(', ')
ignoreAssetsPattern = "!.svn:!.git:!.ds_store:!*.scc:.*:!CVS:!thumbs.db:!picasa.ini:!*~"
}**SIGN**
lintOptions {
abortOnError false
}
buildTypes {
debug {
minifyEnabled **MINIFY_DEBUG**
proguardFiles getDefaultProguardFile('proguard-android.txt')**SIGNCONFIG**
jniDebuggable true
}
release {
minifyEnabled **MINIFY_RELEASE**
proguardFiles getDefaultProguardFile('proguard-android.txt')**SIGNCONFIG**
}
}**PACKAGING_OPTIONS****SPLITS**
**BUILT_APK_LOCATION**
bundle {
language {
enableSplit = false
}
density {
enableSplit = false
}
abi {
enableSplit = true
}
}
}**SPLITS_VERSION_CODE****LAUNCHER_SOURCE_BUILD_SETUP**
I figuered out that some .aar files are being moved from the imported Mapbox asset to a Temp folder, and more specifically from Assets\Mapbox\Core\Plugins\Android into Temp\gradleOut\unityLibrary\libs so it has to be related to the problem somehow.. as shown in the following figure:
I am really stuck on the line Libraries using reflection such as annotation processors need to be updated manually to add support for androidx since this is the only partially-useful line in the error, but i have no idea what it mean to UPDATE the library manually..? update what exactly? and from where? to where? how?

Error: Invoke-customs are only supported starting with Android O (--min-api 26)

I have recently started learning how to program Android devices via Android Studio. My first app was running fine until I upgraded to Android Studio 3.4 this morning.
I'm getting the following compilation errors:
Caused by: com.android.builder.dexing.DexArchiveBuilderException: Failed to process C:\Users\Technical.gradle\caches\transforms-2\files-2.1\4f3f8638c6a9f961dae488a0387efb6b\jars\classes.jar
Caused by: com.android.builder.dexing.DexArchiveBuilderException: Error while dexing.
Caused by: com.android.tools.r8.CompilationFailedException: Compilation failed to complete
Caused by: com.android.tools.r8.utils.AbortException: Error: Invoke-customs are only supported starting with Android O (--min-api 26)
Is there a way of reverting back to my previous version of Android Studio?
If not what has changed in the new version that is causing a failure in creating the dex file?
I have tried adding android.enableD8=true in gradle.properties as suggested here but no luck.
EDIT #1:
Have also tied adding multiDexEnabled true to the default configuration in the app build.gradle file but the same compilation errors persist.
That build file in full...
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "qdivision.org.qrtracker"
minSdkVersion 15
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
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'
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.github.felHR85:UsbSerial:6.0.5'
}
Try to add below to your app/build.gradle to make your Android project compilation be compatible with Java 8.
android {
....
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
....
}
I had to remove useProguard true from the buildTypes configuration.
According to the documentation minifyEnabled true is enough to obfuscate your code with R8.
Example:
android {
buildTypes {
debug {
versionNameSuffix "-dev"
minifyEnabled true // <- remove this line when using instant run
useProguard true // <- remove this line
signingConfig signingConfigs.release
proguardFiles getDefaultProguardFile('proguard-android.txt'), "proguard-rules.pro"
}
release {
shrinkResources true
minifyEnabled true
useProguard true // <- remove this line
signingConfig signingConfigs.release
proguardFiles getDefaultProguardFile('proguard-android.txt'), "proguard-rules.pro"
}
}
}
for me following command in BUILD.GRADLE removed the error.
defaultConfig {
applicationId "com.example.myapptestheader"
minSdkVersion 21
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
I just added
multiDexEnabled true
What is relevant in this stacktrace is this line:
Caused by: com.android.tools.r8.utils.AbortException: Error: Invoke-customs are only supported starting with Android O (--min-api 26)
As there is not kotlin library in your dependencies, I assume you’re working with java. I would try answers in this issue
in your Android Studio go to build.gradle(Module:App)
then add this compileOptions{} block into android{} block
android{
compileOptions {
sourceCompatibility 1.8
targetCompatibility 1.8
}
}
If you are using Google Cloud library, try to decrease the version to 1.90
Add the following to make your app to be compiled by java8 compiler.
android {
.....
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
And disable instant-run found at
Preferences->Build,Execution,Deployment->Debugger->Instant Run
I have added to all modules these code:
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
But error was still there.
In my case some of my modules used classpath 'me.tatarka:gradle-retrolambda' and it gave the conflict with this:
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
So I have to migtrated from Retrolambda by this link:
https://developer.android.com/studio/write/java8-support#migrate_from_retrolambda
Please add this line in build.gradle file.
android{
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
I had the same problem. Mine was caused by ... org.apache.commons:commons-lang .... I do not have the complete error message at the moment. This error only occurred during a Rebuild or Clean Build.
I Resolved by changing the org.apache.commons:commons-text:1.8 in my build.gradle to org.apache.commons:commons-text:1.6.
Note - There was a suggestion here to disable "Instant Run" in Android Studio. This feature was not available in my Android Studio. Version -
Android Studio 3.5.1
Build #AI-191.8026.42.35.5900203, built on September 26, 2019
Windows 10 10.0
for kotlin you should also add kotlinOptions:
android {
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = JavaVersion.VERSION_1_8.toString()
}
}
for me solution with Java 8 started work only after I have removed all ting related to retrolambda.
For anyone else hitting this, I encountered this problem after adding a dependency on this Jackson library:
implementation("com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.11.1")
The "compileOptions" solution above fixed the issue for me
This still works in 2021 please try it.
android {
compileSdkVersion 30
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
defaultConfig {
applicationId "com.example.android.bakingapp"
minSdkVersion 15
targetSdkVersion 30
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
For my case, It was also showing after adding the following lines -
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
So I fixed my problem just simply update my minSdkVersion from 19 to 21 and then finally it worked !!!
I faced this error after upgrading the core libraries in build.gradle to there latest versions luckily accepted answer worked for me.
The reason of working of accepted answer was the change in the latest version of core library targeting api level 30 which is written in java8 therefore adding dependency to java8 solved it.
As of December 2021, this is what works.
The reason why I have ran into this is because of missing skd version 26 and missing java version 8. Under your build.gradle(app) folder, add the following code to make sure that you have the correct dependencies, default configurations and android compatibilities. You don't need to know what they mean yet, just know they exist. Basically you are trying to make sure that Android can read previous version of things. Here is the code that I run to ensure that my apps run.
apply plugin: 'com.android.application'
android {
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
compileSdkVersion 26
compileSdkVersion 27
compileSdkVersion 30
buildToolsVersion "30.0.2"
defaultConfig {
applicationId "com.example.firstfirstapp"
minSdkVersion 16
targetSdkVersion 26
targetSdkVersion 30
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'),
'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "androidx.cardview:cardview:1.0.0"
implementation 'androidx.appcompat:appcompat:1.3.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.1'
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support:design:26.1.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
implementation 'com.android.support:appcompat-v7:26.0.0'
}
add this line:- multiDexEnabled true in build. gradle
in` defaultConfig {
...
multiDexEnabled true
}
Also make minsdk = 26
try this:
defaultConfig {
...
multiDexEnabled true
}
If you are trying to run apk directly from android studio, please try to avoid enabling
minifyEnabled true
Comment the following line.
// minifyEnabled true
// shrinkResources true
But you can use above line while building apk.

Error:(33, 13) Failed to resolve: com.facebook.android:audience-network-sdk:4.+

Below is code from my build.gradle file.
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion '24.0.0'
useLibrary 'org.apache.http.legacy'
defaultConfig {
applicationId "com.test"
minSdkVersion 19
targetSdkVersion 19
jackOptions {
enabled true
}
}
buildTypes {
release {
minifyEnabled true
proguardFiles 'proguard.cfg'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
incremental false
}
dexOptions {
dexInProcess false
}
}
dependencies {
compile files('libs/StartAppInApp-3.4.2.jar')
compile 'com.google.code.gson:gson:2.6.1'
compile 'com.squareup.okio:okio:1.6.0'
compile 'com.squareup.okhttp:okhttp:2.7.0'
compile 'com.squareup.retrofit:retrofit:1.9.0'
compile 'com.facebook.android:audience-network-sdk:4.+'
}
When I do Sync project with gradle files, it gives me error.
Error:(33, 13) Failed to resolve: com.facebook.android:audience-network-sdk:4.+
Can anyone tell me why I'm getting this error?
The latest version 4.14.0 is not available at the moment.
Use 4.13.0 for the time being to avoid the gradle error.
compile 'com.facebook.android:audience-network-sdk:4.13.0'
use the specific version of facebook sdk like:
dependencies {
compile 'com.facebook.android:audience-network-sdk:4.14.0'
}
gradle will not allow any special symbles or charecters to resolve the repository.so use the facebooksdk for the specific version based on your requirement like bellow in dependency
compile 'com.facebook.android:audience-network-sdk:4.8.2'
Version 4.14.1 has been deployed with the fix. So you can now go ahead and use the latest version via gradle. Specifying 4.+ will automatically use the 4.14.1 version.

Manifest merger failed when using Recyclerview for lower SDK version

I can getting the following error:
Error:Execution failed for task ':app:processDebugManifest'.
Manifest merger failed : uses-sdk:minSdkVersion 15 cannot be different than version L declared in library .../com.android.support/recyclerview-v7/21.0.0-rc1/AndroidManifest.xml
Below is my build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.1"
defaultConfig {
minSdkVersion 15
targetSdkVersion 20
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:recyclerview-v7:21.0.0-rc1'
compile 'com.android.support:cardview-v7:21.0.0-rc1'
...
}
Using
<uses-sdk
tools:node="replace" />
does not work anymore.
I have looked at this. The solution suggested place following code in gradle.build
android.applicationVariants.all { variant ->
variant.processResources.manifestFile = file('src/main/AndroidManifest.xml')
variant.processManifest.enabled=false }
But I get error
Error:(21, 0) Could not find property 'processResources' on com.android.build.gradle.internal.api.ApplicationVariantImpl_Decorated#dac7b2d.
No matter where I place the code in gradle.build
Replace:
compile 'com.android.support:recyclerview-v7:21.0.0-rc1'
compile 'com.android.support:cardview-v7:21.0.0-rc1'
with:
compile 'com.android.support:recyclerview-v7:21.0.0'
compile 'com.android.support:cardview-v7:21.0.0'
to use the production release versions of those libraries, instead of the L-only preview versions. They will work back to API Level 7.

Can't import an eclipse project into android studio?

I am trying to learn android in android studio.Now i imported an eclipse project in android studio and now while trying to run it it is not building.Some problems in gradle may be..
Error:Execution failed for task ':app:processDebugManifest'.
Manifest merger failed : uses-sdk:minSdkVersion 8 cannot be smaller than version L declared in library com.android.support:support-v4:21.0.0-rc1
my build.gradle
apply plugin: 'android'
android {
compileSdkVersion 19
buildToolsVersion "19.1.0"
defaultConfig {
applicationId "com.example.practise"
minSdkVersion 8
targetSdkVersion 19
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:support-v4:+'
compile 'com.android.support:gridlayout-v7:+'
}
Can anyone help me to find out the problem??
Change your dependencies
dependencies {
compile 'com.android.support:support-v4:19.1.0'
compile 'com.android.support:gridlayout-v7:19.1.0'
}
Using the +, you are getting the last release.
Currently the last release is the compile 'com.android.support:support-v4:21 and it has a minSdk='L' because it is a preview release.
Use it only to test the android 'L' preview.
Try editing the following line to your Android Manifest file, like so:
dependencies {
compile 'com.android.support:support-v4:21+'
}
Then your project should build.
Change your dependencies in app/build.gradle to lower version
apply plugin: 'com.android.application'
android {
compileSdkVersion 20
buildToolsVersion "20.0.0"
defaultConfig {
applicationId "com.eusecom.snowsmsden"
minSdkVersion 16
targetSdkVersion 20
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:support-v4:20.+'
compile 'com.android.support:appcompat-v7:20.+'
}

Categories

Resources