Here is it my sreen:
What settings should I set?
How to avoid deprecated class?
I would like to use espresso, after that try to use UiAutomator, how to set needed necessary settings?
I lost almost whole day.
#RunWith(AndroidJUnit4::class)
#LargeTest
class MainActivityTest {
#Rule
#JvmField
var activityTest = ActivityTestRule(MainActivity::class.java)
fun c(){
assertEquals(1,1)
}
}
GRADLE
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 29
buildToolsVersion "29.0.3"
defaultConfig {
applicationId "com.example.network"
minSdkVersion 23
targetSdkVersion 29
versionCode 1
versionName "1.0"
"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 "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.core:core-ktx:1.3.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.13'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test:rules:1.2.0'
//okhttp library
implementation("com.squareup.okhttp3:okhttp:4.7.2")
// coroutines
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.7'
//gson
implementation 'com.google.code.gson:gson:2.8.6'
//recycler
implementation "androidx.recyclerview:recyclerview:1.1.0"
//picasso
implementation 'com.squareup.picasso:picasso:2.71828'
//broadcast
implementation 'com.android.support:design:26.1.0'
//interceptor
implementation 'com.squareup.okhttp3:logging-interceptor:3.7.0'
}
You've not set the test runner correctly.
This line:
"android.support.test.runner.AndroidJUnitRunner"
should be instead:
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
as you are using the new androidx libraries instead of the old support ones.
Without this you'll get this No tests were found errors. Don't forget to add the testInstrumentationRunner keyword.
And add junit to androidTestImplementation also in de gradle file:
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
Related
When I try to build my project I get this error:
The given artifact contains a string literal with a package reference 'android.support.design.widget' that cannot be safely rewritten
I Found many similar questions but they were not helpful to me I work with this Library:
And this is my code from Build:gradle
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 28
buildToolsVersion '28.0.3'
defaultConfig {
applicationId "com.majaxtn.codingup"
minSdkVersion 21
targetSdkVersion 28
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 'com.android.support:customtabs:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.yarolegovich:discrete-scrollview:1.4.9'
implementation 'com.google.firebase:firebase-core:17.4.3'
implementation 'com.google.firebase:firebase-auth:19.3.1'
implementation 'com.google.firebase:firebase-database:19.3.0'
implementation 'com.firebaseui:firebase-ui-auth:4.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.13'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'androidx.recyclerview:recyclerview:1.2.0-alpha03'
implementation 'androidx.appcompat:appcompat:1.1.0'
}
apply plugin: 'com.google.gms.google-services'
And below is the screen with my problem
Screenshot with error
I suggest you upgrade to AndroidX:
dependencies {
implementation
'com.google.android.material:material:1.1.0'
implementation 'androidx.appcompat.appcompat:1.1.0'
implementation
'androidx.constraintlayout.constraintlayout:1.1.3'
implementation 'androidx.browser.browser:1.0.0
}
PS: the versions are not the latest though, just pointing you in the right direction.
Remove these:
implementation
'com.android.support:customtabs:28.0.0'
implementation 'com.android.support:support-v4:28.0.0
implementation
'com.android.support.constraint:constraint-layout:1.1.3'
Edit:
Add this in your gradle.properties file:
android.useAndroidX=true
android.enableJetifier=true
Then do a clean build after you sync.
Cheers!
I am new to Android Studio and I'm trying to learn how to use navigation drawer. However, I can't make it appear in preview. I have tried doing it automatically when creating a new activity but the result is the same here is what it looks like
These are the dependencies:
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
defaultConfig {
applicationId "com.example."
minSdkVersion 21
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 {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'com.google.android.material:material:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.squareup.picasso:picasso:2.5.2'
implementation 'androidx.navigation:navigation-fragment:2.0.0'
implementation 'androidx.navigation:navigation-ui:2.0.0'
implementation 'androidx.lifecycle:lifecycle-extensions:2.0.0'
implementation 'com.google.firebase:firebase-auth:16.0.5'
implementation 'com.google.firebase:firebase-database:16.0.4'
implementation 'com.google.firebase:firebase-storage:16.0.4'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}
If you want show in editor preview - tools:openDrawer="start"
I found similar question:
What's the purpose of tools:openDrawer="start" when creating a DrawerLayout (with NavigationView) from the wizard?
I want to add the app:layout_behavior attribute in xml file but it not supported. Which library should I add in gradle file?
compile 'com.android.support:design:22.2.0
when I add this compile library android Studio gives error I have to androidx library to support that app:layout_behavior.
apply plugin: 'com.android.application'
android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
defaultConfig {
applicationId "com.example.expensemanager"
minSdkVersion 16
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 {
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 'com.google.firebase:firebase-analytics:17.2.0'
implementation 'com.google.firebase:firebase-auth:19.0.0'
implementation 'com.google.firebase:firebase-database:19.1.0'
implementation 'com.google.firebase:firebase-functions:19.0.1'
implementation 'androidx.cardview:cardview:1.0.0'
}
apply plugin: 'com.google.gms.google-services'
please help me what should i implement to support app:layout_behavior
Use the Material Components Library which is a drop-in replacement for Android's Design Support Library.
implementation 'com.google.android.material:material:1.1.0-beta02'
or the latest stable version:
implementation 'com.google.android.material:material:1.0.0'
I know GeoDataClient can be import by adding 'com.google.android.gms:play-services-places' in build.gradle.
But Google say "'com.google.android.gms:play-services-places'is deprecated".
So we have to use 'com.google.android.libraries.places:places:1.1.0'.
By the way 'com.google.android.libraries.places:places:1.1.0' doesn't contain GeoDataClient and PlaceDetectionClient.
How could I resolve those two objects?
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.fuckingtest"
minSdkVersion 21
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'
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.google.android.gms:play-services-maps:17.0.0'
implementation 'com.google.android.gms:play-services-location:17.0.0'
implementation 'com.google.android.libraries.places:places:1.1.0'
}
add to dependencies in build.gradle
implementation 'com.google.android.libraries.places:places-compat:1.1.0'
instead of
implementation 'com.google.android.libraries.places:places:1.1.0'
I'm trying to set up my SettingsFragment but
import PreferenceFragmentCompat hasn't been working.
Is there a way of doing this with AndroidX?
Dependency
implementation 'androidx.preference:preference:1.0.0-rc02'
Gradle flie
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.idealorb.payrollapp"
minSdkVersion 19
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
android.defaultConfig.vectorDrawables.useSupportLibrary = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.0.0-rc02'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.google.android.material:material:1.0.0-rc02'
implementation 'com.google.android.gms:play-services-auth:16.0.0'
implementation 'com.google.firebase:firebase-auth:16.0.3'
implementation 'com.google.firebase:firebase-core:16.0.3'
implementation 'androidx.legacy:legacy-support-v4:1.0.0-rc02'
implementation 'androidx.lifecycle:lifecycle-extensions:2.0.0-rc01'
implementation 'android.arch.navigation:navigation-fragment:1.0.0-alpha05'
implementation 'android.arch.navigation:navigation-ui:1.0.0-alpha05'
implementation 'androidx.preference:preference:1.0.0-rc02'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.0-alpha4'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0-alpha4'
}
compileSdkVersion 28
You have to set compileSdkVersion to 29 in order to use androidx-namespaced libraries