Android wear application from targetSDk 28 to 30 - android

I m upgrading my Android wear project using Android Studio.
So I change the follow code:
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.medicinanucleare.cardio"
minSdkVersion 26
targetSdkVersion 28
versionCode 4
versionName "1.3"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
}
}
with this:
android {
compileSdkVersion 30
defaultConfig {
applicationId "com.medicinanucleare.cardio"
minSdkVersion 26
targetSdkVersion 30
versionCode 4
versionName "1.3"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
}
}
as you can see I change the targetSdkVersion from 28 to 30.
But now I have some errore on build.gradle file:
implementation 'com.android.support:percent-v4:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.android.support:wear:28.0.0'
implementation 'com.android.support:recyclerview-v7:28.0.0'
these lines are not recognized. I try also to comment the code but I have this error while I try to compile the application:
java.lang.RuntimeException: Duplicate class android.support.v4.app.INotificationSideChannel found in modules core-1.3.2-runtime.jar (androidx.core:core:1.3.2) and support-compat-28.0.0-runtime.jar (com.android.support:support-compat:28.0.0)
I try also to migrande application to Androidx but the operation failed.

Related

"compileSdkVersion is not specified. Please add it to build.gradle.", although I have "compileSdk"

I have in app level build.gradle this, why gradle doesn't recognize shorter version of compileSdkVersion?
android {
compileSdk 32
defaultConfig {
applicationId "androidx.car.app.sample.helloworld"
minSdkVersion 29
targetSdkVersion 32
versionCode 1
versionName "1.0"
}
buildTypes {
release {
// Enables code shrinking, obfuscation, and optimization.
minifyEnabled true
proguardFiles getDefaultProguardFile(
'proguard-android-optimize.txt'),
'proguard-rules.pro'
}
}
compileOptions {
targetCompatibility = JavaVersion.VERSION_1_8
sourceCompatibility = JavaVersion.VERSION_1_8
}
namespace "androidx.car.app.sample.helloworld"
}

Exclude a source file from source set in gradle build

Created a bare-bone Empty Activity sample app in Android Studio. Tried multiple ways but unable to exclude a file. App launches normally while I expect it should not have worked.
android {
compileSdk 31
defaultConfig {
applicationId "com.example.myapp"
minSdk 23
targetSdk 31
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
debug {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
sourceSets {
debug {
//java.exclude("src/main/java/com/example/myapp/MainActivity.kt")
java {
exclude "**/*.kt"
}
kotlin {
exclude "**/*.kt"
}
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
}
Anything wrong with sourceset config?

Could not resolve dependency for retrofit

I still got error even after changing retrofit 2.3.0 to 2.6.2 I am stucking with this for a long time please help me to resolve this
android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
defaultConfig {
applicationId "com.example.blog"
minSdkVersion 15
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
implementation 'com.squareup.retrofit2:retrofit:2.6.2'
implementation 'com.squareup.retrofit2:convertor-gson:2.6.2'
Your external libraries should be inside dependencies.
It should something like below
android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
defaultConfig {
applicationId "com.example.blog"
minSdkVersion 15
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies{
// other external libraries
implementation 'com.squareup.retrofit2:retrofit:2.6.2'
implementation 'com.squareup.retrofit2:convertor-gson:2.6.2'
}

java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex || Android

**
While runing the code I encounter this error "Unable to merge dex || Android in the android studio
This is basically use of map in the android application**
This is the Build.gradle code
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.example.npatel7.carparking"
minSdkVersion 24
targetSdkVersion 26
versionCode 1
versionName "image1.0"
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
repositories {
mavenCentral()
}
}
Please assist me

Why did Xml.newPullParser() returns null in Android test?

I use Android Studio 2.0 and i am a fresher in android.
In my source code,Xml.newPullParser() it works well
But,when I input it in junit test(test directory),I found it returns null.Why did it happens?I was confused with it.
Second question,there are two directories(test and androidTest),what's the diffence between them?And I should use which one?
package com.ecust.ecusthelper.util.network.httpurlconnection;
import android.util.Xml;
import org.junit.Assert;
import org.junit.Test;
import org.xmlpull.v1.XmlPullParser;
public class XmlTest {
#Test
public void testXmlNonNull() {
XmlPullParser pull = Xml.newPullParser();
if (pull == null)
Assert.fail("Why here is null");
}
}
my build.gradle
apply plugin: 'com.android.application'
apply plugin: 'me.tatarka.retrolambda'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "com.ecust.ecusthelper"
minSdkVersion 15
targetSdkVersion 23
versionCode 2
versionName '1.1'
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
testOptions {
unitTests.returnDefaultValues = true
}
}
dependencies {
testCompile 'junit:junit:4.12'
debugCompile 'com.squareup.leakcanary:leakcanary-android:1.4-beta2'
releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.4-beta2'
testCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.4-beta2'
compile 'com.android.support:appcompat-v7:23.2.1'
....
}
I think you need to specify test runner in defaultConfig section of your build.gradle:
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
so it would look like this:
defaultConfig {
applicationId "com.ecust.ecusthelper"
minSdkVersion 15
targetSdkVersion 23
versionCode 2
versionName '1.1'
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}

Categories

Resources