I'm trying to use the android support recyclerView widget, and though I've added all the dependencies to my build.gradle file (I think), the line "import android.support.v7.widget.RecyclerView;" in my activity isn't resolving. I'm new to Android Studio, so I might be missing something very basic.
So far I've tried adding the google repository in allprojects of the project build gradle, as well as that of my module build gradle. I've also shifted around my dependencies and tried changing version numbers. And I tried invalidating caches and restarting. I do seem to be able to import "import androidx.recyclerview.widget.RecyclerView;", but that isn't the same from what I've heard.
This is my build gradle file:
//noinspection GradleCompatible
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
buildToolsVersion '28.0.3'
defaultConfig {
applicationId "com.example.chaos"
minSdkVersion 20
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
customDebugType {
debuggable true
}
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 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.android.support:design:28.0.0'
//implementation 'com.android.support:recyclerview-v7:28.0.0'
implementation 'android.arch.persistence.room:runtime:1.1.1'
annotationProcessor 'android.arch.persistence.room:compiler:1.1.1'
androidTestImplementation 'android.arch.persistence.room:testing:1.1.1'
// implementation 'com.android.support:support-v7'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.2-alpha02'
androidTestImplementation ('androidx.test.espresso:espresso-core:3.2.0-alpha02', {
exclude group: 'com.android.support', module: 'support-annotations'
})
}
And then this is the import I'm attempting in my main activity. It seems I can import android.support.v4 libraries, but v7 isn't even an auto-complete option. I'd appreciate the help!
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.RecyclerView;
I expect the import line to resolve, as it currently doesn't.
If you are using Android X, try this dependency instead
implementation 'androidx.recyclerview:recyclerview:1.0.0'
Related
So I am assuming I have differing versions of dependencies causing this issue but i cant seem to resolve it.
When I add the dependency: implementation 'com.google.android.gms:play-services-vision:18.0.0' Then I get an error Syncing my build gradle.
When I change the version to implementation 'com.google.android.gms:play-services-vision:15.0.0' Then It Syncs fine but my app keeps crashing as soon as I open it.
Please can someone help me sync my versions so my app doesnt crash.
I changed the version from 18.0.0 to 15.0.0.
My gradle:
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.ecommerce"
minSdkVersion 15
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
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'
implementation 'com.google.firebase:firebase-core:11.8.0'
implementation 'com.google.firebase:firebase-database:11.8.0'
implementation 'com.google.firebase:firebase-storage:11.8.0'
implementation 'com.firebaseui:firebase-ui-database:3.2.2'
implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'com.github.rey5137:material:1.2.5'
implementation 'com.android.support:cardview-v7:+'
implementation 'com.android.support:recyclerview-v7:+'
implementation 'io.paperdb:paperdb:2.6'
implementation 'com.android.support:design:28.0.0'
implementation 'de.hdodenhof:circleimageview:3.0.0'
implementation 'com.google.android.gms:play-services-vision:18.0.0'
implementation 'com.theartofdev.edmodo:android-image-cropper:2.7.+'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.sup`enter code here`port.test.espresso:espresso-core:3.0.2'
}
After some research I actually found out that Google stopped updating com.google.android.gms:play-services after 12.0.1. I changed the versions as well as my Firebase versions. Everthing Synced with no errors and seems to be running fine now.
first go to file and sync project with gradle file.. if it repeat itself, then go to file and invalidate caches/Restart it has work for me alot of time and also try and replace minSdkVersion 15 to minSdkVersion 21 and also with the look of it your firebase dependence are old check out https://firebase.google.com/docs/android/setup or google firebase dependencies
also make sure you add allprojects
{
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
}
to your build.gradle
I just created an empty android project while including the dependencies I need for the project I got an error only when I add com.google.firebase or com.google.android.gms it will generate error below.
/Users/macbookair/Desktop/ANDROID/APPTEST/app/src/main/AndroidManifest.xml:22:18-91
Error: Attribute application#appComponentFactory
value=(android.support.v4.app.CoreComponentFactory) from
[com.android.support:support-compat:28.0.0]
AndroidManifest.xml:22:18-91 is also present at
[androidx.core:core:1.0.0] AndroidManifest.xml:22:18-86
value=(androidx.core.app.CoreComponentFactory). Suggestion: add
'tools:replace="android:appComponentFactory"' to element
at AndroidManifest.xml:5:5-21:19 to override.
Please can anyone help me out, I have be trying for very long time to fix this error.
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.fexample.android.appz"
minSdkVersion 18
targetSdkVersion 28
versionCode 2
versionName "2.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
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 'org.apache.httpcomponents:httpcore:4.4.10'
implementation 'com.squareup.okhttp3:okhttp:3.13.1'
implementation 'com.facebook.android:facebook-login:4.41.0'
//If I uncomment the below line it will trigger error
//implementation 'com.google.android.gms:play-services-safetynet:17.0.0'
//implementation 'com.google.android.gms:play-services-auth:17.0.0'
//implementation 'com.google.firebase:firebase-core:17.2.0'
//implementation 'com.google.firebase:firebase-messaging:20.0.0'
}
android {
useLibrary 'org.apache.http.legacy'
}
apply plugin: 'com.google.gms.google-services'
android { sourceSets { main { assets.srcDirs = ['src/main/assets', 'src/main/assets/public'] } } }
From the below screenshot this implementation 'com.android.support:appcompat-v7:28.0.0' also has an error but when I build apk it create successfully, I don't think is good.
Dependencies using groupId com.android.support and androidx.* can not
be combined but found
IdeMavenCoordinates{myGroupId='com.android.support',
myArtifactId='support-fragment', myVersion='28.0.0', myPacking='aar',
myClassifier='null'} and
IdeMavenCoordinates{myGroupId='androidx.swiperefreshlayout',
myArtifactId='swiperefreshlayout', myVersion='1.0.0', myPacking='aar',
myClassifier='null'}
I'll suggest you try one of the following:
1) Migrate the whole project to use the androidx libraries which you can do under Refactor > Migrate to AndroidX from the menu bar.
2) Downgrade the versions of com.google.firebase and com.google.android.gms from 17.x.x to a lower version
Whenever i build my project in android studio it gives me the following error
Program type already present: com.google.android.gms.ads.identifier.AdvertisingIdClient$Info
below is my build.gradle file
lastly the line that has implementation 'com.android.support:design:27.0.0' also gives an error saying...
All com.android.support libraries must use the exact same version specification
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.example.iwatchug"
minSdkVersion 19
targetSdkVersion 27
versionCode 1
versionName "1.0"
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:design:27.0.0'
implementation 'com.google.firebase:firebase-auth:16.2.1'
implementation 'com.google.firebase:firebase-core:16.0.8'
implementation 'com.google.android.gms:play-services-maps:15.0.1'
implementation 'com.google.android.gms:play-services:7+'
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'
}
repositories {
google()
}
apply plugin: 'com.google.gms.google-services'
Remove the following line:
implementation 'com.google.android.gms:play-services:7+'
From the docs:
Note: Don't use the combined play-services target. It brings in dozens of libraries, bloating your application. Instead, specify only the specific Google Play services APIs your app uses.
You need to add specific google play services library, example:
implementation 'com.google.android.gms:play-services-vision:17.0.2'
I'm using Android Studio. I have two modules: the app (UI) and a library. When tested separately, both compile and work as they should, but when I try to use some of the library classes on the app, I can't build the project. I get this error:
Error: Program type already present: org.apache.xmlbeans.xml.stream.Location
My library build.gradle has just a few lines:
apply plugin: 'java-library'
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'org.apache.poi:poi:3.17'
implementation 'org.apache.poi:poi-ooxml:3.17'
}
sourceCompatibility = "7"
targetCompatibility = "7"
Then my app's build.gradle is this
android {
compileSdkVersion 28
defaultConfig {
applicationId "skrb.appprueba"
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'
}
}
}
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 'com.android.support:support-v4: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.android.support:design:28.0.0'
implementation project(path: ':coreLib')
}
When adding this (implementation project(path: ':coreLib'), I get the error and I don't know how to solve it.
Things that I tried:
Cleaning and rebuilding the project.
Setting multiDexEnabled to true
according to the error message, it should rather be:
implementation (project(path: ":coreLib")) {
exclude group: "org.apache.xmlbeans"
}
Try this one:
implementation(project(path: ':coreLib')) {
exclude module: 'poi'
exclude module: 'poi-ooxml'
}
Here you could find more information why this error happen.
I am trying to use Trusted Web Activity, following this guide : https://developers.google.com/web/updates/2017/10/using-twa
I did follow all the steps, but there are several words Android Studio cannot resolve by itself and I do not find any solution. The main problem seems to be org.chromium .
In bold the words it can't resolve :
in TwaSessionHelper.java :
import org.chromium.customtabsclient.shared.ServiceConnection;
import org.chromium.customtabsclient.shared.ServiceConnectionCallback;
...
public class TwaSessionHelper implements ServiceConnectionCallback
{
...
mConnection = new ServiceConnection(this);
in TwaLauncherActivity.java :
setContentView(R.layout.activity_twa_launcher);
and in the few lines of code :
TwaSessionHelper.TwaSessionCallback twaSessionCallback = mTwaSessionCallback.get();
What am I missing ?
Here is my build.gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "didi.a8bitpocketwrestlers"
minSdkVersion 17
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.+'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
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'
implementation 'com.android.support:customtabs:28.+'
}
Android Studio cannot resolve ServiceConnectionCallback class because a com.android.support:customtabs library does not contain/provide it. This class exists only in this GitHub repository and no any maven repository. So you not able to add a dependency on it in your build.gradle file, you have to download it and add it in your project manually.
From this GitHub repository download only shared directory, add it in your project as a module.
In your application build.gradle file add a dependency on the shared module.
compile project(':shared')