I have migrated my project to androidx. my project depends on some third party libraries, i'm using one arr file in my project. after migration, i'm getting error like below.
Unable to resolve dependency for ':app#debug/compileClasspath': Failed
to transform file 'csjsdk-beta.aar' to match attributes
{artifactType=processed-aar} using transform JetifyTransform Show
Details Affected Modules: csjsdkdemo-app
here is app level gradle file
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.demo.csjbot.csjsdkdemo"
minSdkVersion 21
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'
}
}
sourceSets {
main {
// 将 jniLib 指向 libs
jniLibs.srcDir 'libs'
}
}
repositories {
flatDir {
dirs 'libs'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "androidx.appcompat:appcompat:1.1.0"
implementation 'androidx.constraintlayout:constraintlayout: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(name: 'csjsdk-beta', ext: 'aar')
implementation 'io.netty:netty-all:4.1.23.Final'
implementation 'com.google.code.gson:gson:2.8.1'
}
can anyone help me on this?
Try clearing your gradle caches which should be stored here: C:\Users\<username>\.gradle\caches\transforms-1, and then rebuild the project.
Edit:
Change your dependencies in build.gradle to use AndroidX namespace:
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "androidx.appcompat:appcompat:1.1.0"
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation(name: 'csjsdk-beta', ext: 'aar')
implementation 'io.netty:netty-all:4.1.23.Final'
implementation 'com.google.code.gson:gson:2.8.1'
After migrating into Android X, you need to do some steps to clear all the un-used imports.
To clear all those un-used imports :-
Right click on src:- You will get an option "Optimise imports"
Once you are done with this optimisation. Check it out all the changes in github.
If still you are getting same issue.
Close the project. Re-import the project again.
Related
In my gradle, I have a conflict in versions that gives me the error Cannot resolve symbol 'R' but I don't know what is the wrong version.
In my gradle, I have a conflict in versions that gives me the error Cannot resolve symbol 'R' but I don't know what is the wrong version.
Already tried every other solution:
Clean and Rebuild project
Sync project
Clean cache
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.example.ves.gennaio3"
minSdkVersion 14
targetSdkVersion 26
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:26.1.0'
implementation 'com.android.support:cardview-v7:26.1.0'
implementation 'com.android.support:design:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:support-v4:26.1.0'
implementation 'com.android.support:recyclerview-v7:26.1.0'
implementation 'com.google.firebase:firebase-auth:16.0.4'
implementation 'com.google.firebase:firebase-database:16.0.3'
implementation 'com.google.firebase:firebase-ml-vision:17.0.1'
implementation 'com.google.firebase:firebase-firestore:17.1.1'
compile 'com.github.satyan:sugar:1.5'
compile 'com.rmtheis:tess-two:6.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'
}
apply plugin: 'com.google.gms.google-services'
You cloud try the following:
File -> Invalidate Caches / Restart Android Studio -> Invalidate and Restart
Android Studio maintains information about which files are dependent on which other files. This means you not only have to Gradle sync your files, but you also need to invalidate studio caches.
hello im using android studio and i want to integrate roboelectric here is my build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
///////////
applicationId "com.inducesmile.androidmapdrawroute"
///////////////
applicationId "com.application.zarbagaskazay.colivoiturage"
minSdkVersion 15
targetSdkVersion 27
versionCode 1
versionName "1.0"
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
testOptions {
unitTests {
includeAndroidResources = true
}
}
}
dependencies {
///////////////////////firebase//////////
implementation 'com.google.firebase:firebase-core:16.0.0'
implementation 'com.google.firebase:firebase-storage:16.0.1'
implementation 'com.google.firebase:firebase-auth:16.0.1'
///////////////////
implementation 'com.android.support:multidex:1.0.0'
implementation 'com.dropbox.core:dropbox-core-sdk:3.0.8'
implementation 'com.google.code.gson:gson:2.8.4'
implementation "com.github.danielnilsson9:color-picker-view:1.4.0#aar"
implementation 'com.android.support:palette-v7:27.1.1'
implementation 'com.android.volley:volley:1.0.0'
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
implementation 'com.android.support:support-v4:27.1.1'
implementation 'com.android.support:design:27.1.1'
implementation 'com.google.android.gms:play-services-maps:15.0.1'
implementation 'com.google.android.gms:play-services-plus:15.0.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.android.support:gridlayout-v7:27.1.1'
////////// google directions //////////////////////////////// google directions //////////////////////
implementation 'com.google.android.gms:play-services-location:15.0.1'
implementation 'com.google.maps.android:android-maps-utils:0.4+'
///////////////////////// card view ////////////////
implementation 'com.android.support:cardview-v7:27.1.1'
implementation 'com.google.android.gms:play-services-maps:15.0.1'
implementation fileTree(dir: 'libs', include: ['*.jar'])
testImplementation 'org.robolectric:robolectric:4.0-alpha-2'
}
apply plugin: 'com.google.gms.google-services'
heree is my error of build
Unable to resolve dependency for ':app#debugUnitTest/compileClasspath': Could not resolve org.robolectric:robolectric:4.0-alpha-2.
Open File
Show Details
Unable to resolve dependency for ':app#releaseUnitTest/compileClasspath': Could not resolve org.robolectric:robolectric:4.0-alpha-2.
Open File
Show Details
You're trying to load a snapshot version. You probably want the release version.
Simply change the testImplementation line to:
testImplementation 'org.robolectric:robolectric:3.8'
If you know what you're doing and are sure you want to use the snapshot version (which is potentially unstable and not recommended unless absolutely necessary) you'll have to add a couple more things.
repositories {
maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
}
dependencies {
testCompile "org.robolectric:robolectric:4.0-alpha-3-SNAPSHOT"
}
In my case gradle offline mode was enable
Be sure to disable gradle offline mode in settings. Steps to disable gradle offline mode
Go to File > Settings
Select Gradle under **Build, Execution & Deployment*
Uncheck Offline work under Global Gradle Settings
Click Apply button
In offline mode gradle will not download library and will give same error even if you are connected to internet.
This is my dependencies file and there is an underlined red colored text on the compile 'com.android.support:appcompat-v7.27.1.1'
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.abc.mcaproject"
minSdkVersion 21
targetSdkVersion 27
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'])
compile 'com.android.support:appcompat-v7.27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
implementation 'com.google.firebase:firebase-database:11.6.0'
implementation 'com.google.firebase:firebase-messaging:11.6.0'
implementation 'com.google.firebase:firebase-auth:11.6.0'
implementation 'com.google.firebase:firebase-storage:11.6.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'
This because of this I am having problems changing themes in the styles.xml
when you hover over the red line it may show you the image like this which I have attached below.
What it tells you is there is a conflict of the version in some libraries so it suggests us to add those. For my case first, it showed for CardView and then for Design. So I added to it. Below is the code for it.
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.0'
implementation 'com.payumoney.sdkui:plug-n-play:1.2.0'
implementation 'com.android.support:cardview-v7:27.1.1'
implementation 'com.android.support:design:27.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'
}
so kindly add those it may be 2 or more than that.
Hope that helps.
In Android Studio 3.0 ,the compile configuration is now deprecated and should be replaced by implementation or api.
Just replace:
implementation 'com.android.support:appcompat-v7.27.1.1'
compile with implementation
testCompile with testImplementation.
debugCompile with debugImplementation.
androidTestCompile with androidTestImplementation.
compileOnly is still valid. It was added in 3.0 to replace provided and not compile.
for more information read this gradel doc
Reason of fail
You are using incompatible version of firebase with 27.1.1 support version.
Current version > 16.0.0 and you use 11.6.0.
Solution
Update your firebase dependencies versions. I suggest update target sdk version also.
Below is updated gradle as of date 1-10-2018, you can see firebase page to check latest version.
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.abc.mcaproject"
minSdkVersion 21
targetSdkVersion 28
versionCode 1
versionName "1.0"
}
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.0'
implementation 'com.google.firebase:firebase-database:16.0.2'
implementation 'com.google.firebase:firebase-messaging:17.3.2'
implementation 'com.google.firebase:firebase-auth:16.0.3'
implementation 'com.google.firebase:firebase-storage:16.0.2'
}
apply plugin: 'com.google.gms.google-services'
Suggestion
Migrate to androidx because Android will not update support libraries after version 28.0.0.
just goto-> files->project structures->app->flavors
change your min SDK version and target SDK version to "API 27:"
then go to properties and check that your compile SDK version has also changed to the above version which you selected.
This worked for me.
The error is Error
:Execution failed for task
':app:transformDexArchiveWithExternalLibsDexMergerForDebug'. >
java.lang.RuntimeException: java.lang.RuntimeException:
com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
I have tried all the solutions given on stackoverflow but none of them worked for me.
This is app level gradle file. I think I am using all the latest dependencies.
app level build.gradle file is uploaded here. help me to solve this problem
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId"com.example.pratikrathi.registerapp"
minSdkVersion 20
targetSdkVersion 26
versionCode 1
versionName "1.0"
multiDexEnabled = true
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:26.1.0'
implementation 'com.android.support:design:26.1.0'
implementation 'com.android.support.constraint:constraintlayout:1.0.2'
implementation 'com.android.support:cardview-v7:26.1.0'
implementation 'com.google.firebase:firebase-auth:11.8.0'
compile 'com.google.firebase:firebase-core:11.8.0'
compile 'com.google.firebase:firebase-database:11.8.0'
compile 'com.google.firebase:firebase-storage:11.8.0'
compile 'com.google.firebase:firebase-firestore:11.8.0'
compile 'com.google.firebase:firebase-crash:11.8.0'
implementation 'com.android.support:support-v4:26.1.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation
'com.android.support.test.espresso:espresso-core:3.0.1'
compile 'de.hdodenhof:circleimageview:2.2.0'
compile 'com.theartofdev.edmodo:android-image-cropper:2.6.+'
implementation 'com.github.bumptech.glide:glide:4.6.1'
annotationProcessor 'com.github.bumptech.glide:compiler:4.6.1'
}
apply plugin: 'com.google.gms.google-services'
You are mixing old firebase dependencies with the new firebase dependencies.
You need to remove the following from your root build.gradle dependencies:
classpath 'com.firebase:firebase-client-android:2.3.1'
Then check and remove old firebase depedencies from your module build.gradle. Please read https://firebase.google.com/support/guides/google-android
UPDATE
You also have a duplicated support library.
'com.theartofdev.edmodo:android-image-cropper:2.6.+' library implicitly using support library version 27+, which you can check from its root build.gradle.
You can fix it by exclude support library from image-cropper like this:
implementation ("com.theartofdev.edmodo:android-image-cropper:2.6.+") {
exclude group: 'com.android.support'
exclude module: 'appcompat-v7'
}
Or updating all of your support library to version 27.1.0.
I built a normal android app which uses Firebase to store data(name,email and number) and it runs perfectly but i have a dependency conflict error which i am unable to solve. the message which i get "Message Gradle Build" is:
Error:Execution failed for task ':app:preDebugAndroidTestBuild'.
Conflict with dependency 'com.android.support:support-annotations' in project ':app'. Resolved versions for app (25.2.0) and test app (25.4.0) differ. See https://d.android.com/r/tools/test-apk-dependency-conflicts.html for details.
and my build.gradle file contains:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.arya.anish.myfirebaseexample"
minSdkVersion 19
targetSdkVersion 26
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.constraint:constraint-layout:1.0.2'
implementation 'com.google.firebase:firebase-database:11.0.4'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}
apply plugin: 'com.google.gms.google-services'
how to overcome this error?
try adding this to your app level .gradle file
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.google.firebase:firebase-database:11.0.4'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation('com.android.support.test.espresso:espresso-core:3.0.1') {
exclude group: 'com.android.support', module: 'support-annotations'
}
}
finally figured out how to solve the dependency conflict
i added this line in the build.gradle file in the depndencies block:
compile 'com.android.support:support-annotations:27.0.2'
and bingo, no errors now.