Project can't compile after adding admob library - java

When I add adomb library to my project apps stop working without showing any errurs on android studio. See here.
plugins {
id 'com.android.application'
}
android {
compileSdk 32
defaultConfig {
applicationId "com.ozayd.azkar"
minSdk 23
targetSdk 32
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.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 'androidx.appcompat:appcompat:1.5.1'
implementation 'com.google.android.material:material:1.6.1'
testImplementation 'junit:junit:4.13.2'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}

It's maybe conflict version between your app and admob.
try upgrade admob version :
//with appcompat & material:
implementation 'androidx.appcompat:appcompat:1.4.2'
implementation 'com.google.android.material:material:1.6.1'
implementation 'com.google.android.gms:play-services-ads:21.0.0'
implementation 'com.google.android.play:core:1.10.3'
then sync project again.
If it don't work, try add resolutionStrategy in gradle file:
android {
defaultConfig {
configurations.all {
resolutionStrategy {
force 'androidx.appcompat:appcompat:1.5.1'
force 'com.google.android.material:material:1.6.1'
}
}
}
}
then clean project and re sync

Related

How to integrate allure report with gradle, junit4 and espresso?

I am trying to generate allure report for android tests, but when I run command .\gradlew clean test, only testcases in test folder are there in the report. there are no tests from androidTest package. is there something wrong in the command or the build.gradle file. I am new to this, not able to figure it out.
I am using Android studio. Attaching build.gradle script.
buildscript {
repositories {
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath "io.qameta.allure.gradle.allure:allure-plugin:2.11.2"
}
}
plugins {
id 'com.android.application'
id "io.qameta.allure" version "2.11.2"
}
android {
compileSdk 32
defaultConfig {
applicationId "com.example.tabbedactivity"
minSdk 21
targetSdk 32
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
testInstrumentationRunner "io.qameta.allure.espresso.AllureAndroidRunner
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
buildFeatures {
viewBinding true
}
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.5.1'
implementation 'com.google.android.material:material:1.7.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.5.1'
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.1'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.4'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.0'
implementation 'com.google.guava:guava:30.1.1-jre'
implementation 'org.seleniumhq.selenium:selenium-java:4.4.0'
implementation 'io.github.bonigarcia:webdrivermanager:5.3.0'
implementation 'io.qameta.allure:allure-junit4:2.19.0'
}
tasks.withType(Test) {
exclude '**/calltest/Summary.class'
}
Attached the copy of build.gradle file.

App will not launch on emulator but android studio is telling me it has launched the applicaton

I had this issue with my android studio and I solved it with this answer.
Now my application is running on android studio and I will get a notification from android studio that the application has been installed and is launched but the application will not open on an emulator or on a physical device.
After android studio says the app has been installed the icon will show on the device bit if I click on it, I will get "App isn't installed" toast.
What can I do?
App level build.gradle file contains:
plugins {
id 'com.android.application'
}
android {
compileSdkVersion 31
defaultConfig {
configurations.all {
resolutionStrategy { force 'androidx.core:core:1.6.0' }
}
applicationId "com.olalekanamoo.service"
minSdkVersion 16
targetSdkVersion 31
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.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 {
// def work_version = "2.6.0"
// // Force WorkManager 2.6.0 for transitive dependency
// implementation("androidx.work:work-runtime:$work_version") {
// force = true
// }
implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'com.google.android.material:material:1.5.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}
My physical device that I use for debugging is running android 11.
I also tried this solution but it didn't work.

Chaquopy How can I import pattern library?

I would like to import pattern library of python.
The build gradle (app) is like below.
plugins {
id 'com.android.application'
id 'kotlin-android'
id 'com.chaquo.python'
}
android {
compileSdkVersion 30
buildToolsVersion "30.0.3"
defaultConfig {
applicationId "com.example.chaquopy"
python{
pip{
install "pattern"
}
}
sourceSets{
main{
python{
srcDirs = ["src/main/python"]
}
}
}
minSdkVersion 23
targetSdkVersion 30
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
ndk {
abiFilters "armeabi-v7a", "arm64-v8a", "x86", "x86_64"
}
// Here is local python.exe folder.
python{
buildPython "C:/Users/xxxx/AppData/Local/Programs/Python/Python38/python.exe"
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.3.2'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.3.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}
Sync task finished successfully,
but it failed when I build the project, because of the failure to install mysqlclient.
Can I import pattern library using Chaquopy?
I'll appreciate your help.
It looks like Pattern doesn't actually require mysqlclient: in fact, it defaults to using SQLite. So you can modify it to remove the requirement:
Download the sdist from https://pypi.org/project/Pattern/#files.
Extract it.
Edit Pattern-3.6/setup.py to remove the "mysqlclient" requirement.
Create a .zip or .tar.gz file from the modified Pattern-3.6 directory.
Install this file by its filename, as shown in the Chaquopy documentation.

Can't implement firebase dependencies on my android app

i'm developing an Android Studio App and trying to create a user register activity. I already added firebase into the project but when i try to add the firebase database dependencies, the app crashes instantly and not a single error is reported. However, when i remove the 3 implements from the build gradle, it runs correctly. Here i leave both build gradle codes. Thanks.
Build gradle project:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.6.4'
classpath 'com.google.gms:google-services:4.3.8'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Build gradle app (this works properly):
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 29
buildToolsVersion "29.0.3"
defaultConfig {
applicationId "com.example.jota02"
minSdkVersion 26
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.3.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
//new implements
implementation 'com.google.android.material:material:1.3.0'
implementation 'com.google.android.material:material:1.4.0-beta01'
implementation platform('com.google.firebase:firebase-bom:28.0.1')
}
Build gradle app (this crashes):
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 29
buildToolsVersion "29.0.3"
defaultConfig {
applicationId "com.example.jota02"
minSdkVersion 26
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.3.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
//new implements
implementation 'com.google.android.material:material:1.3.0'
implementation 'com.google.android.material:material:1.4.0-beta01'
implementation platform('com.google.firebase:firebase-bom:28.0.1')
implementation 'com.google.firebase:firebase-auth:21.0.1'
implementation 'com.google.firebase:firebase-core:19.0.0'
implementation 'com.google.firebase:firebase-database:20.0.0'
}
SOLVED
The problem just was that i was running an old Android Studio version. I updated Android Studio and checked the gradle versions and now it's all working properly, thanks.
When you use firebase-bom dependency, you no need to mention version for firebase-database and other firebase library.
firebase-bom will choose right version for you or if you want particular version of firebase remove firebase-bom.so add dependency like below
// Import the BoM for the Firebase platform
implementation platform('com.google.firebase:firebase-bom:28.0.1')
// When using the BoM, you don't specify versions in Firebase library dependencies
implementation 'com.google.firebase:firebase-auth'
implementation 'com.google.firebase:firebase-core'
implementation 'com.google.firebase:firebase-database'

Android Studio 3.0 Unresolved reference: SupportedLanguages for AIConfiguration class in Dialogflow(api.ai)

I am building a chatbot Android app in Kotlin, through queries to a Dialogflow agent. I am using the Dialogflow android client github repository Readme and the sample app provided in that repository as the basis to build the app. As referenced in the above sources, java code for AIConfiguration.SupportedLanguages works fine:
import ai.api.android.AIConfiguration;
.....
private void initService(final LanguageConfig selectedLanguage) {
final AIConfiguration.SupportedLanguages lang = AIConfiguration.SupportedLanguages.fromLanguageTag(selectedLanguage.getLanguageCode());
.....
You can find the full usage of this here.
When I am implementing this in Kotlin:
import ai.api.android.AIConfiguration
....
private fun initService() {
//final AIConfiguration.SupportedLanguages lang = AIConfiguration.SupportedLanguages.fromLanguageTag(selectedLanguage.getLanguageCode());
val config = AIConfiguration(CLIENT_ACCESS_TOKEN,
AIConfiguration.SupportedLanguages.EnglishGB,
AIConfiguration.RecognitionEngine.System)
....
in Android 3.0 I am getting a gradle error of "Unresolved reference: SupportedLanguages" for AIConfiguration.SupportedLanguages. AIConfiguration.RecognitionEngine is resolving just fine. Why is this problem happening? What solution/work-around can I implement?
My higher level build.gradle file:
apply plugin: 'com.android.feature'
android {
compileSdkVersion 27
baseFeature true
defaultConfig {
minSdkVersion 23
targetSdkVersion 27
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
buildToolsVersion '27.0.1'
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
api 'com.android.support:appcompat-v7:27.0.0'
api 'com.android.support:design:27.0.0'
api 'com.android.support.constraint:constraint-layout:1.0.2'
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'ai.api:sdk:2.0.7#aar'
compile 'ai.api:libai:1.6.12'
//compile project(':ailib')
application project(':app')
feature project(':chatbot')
}
My module build.gradle file:
apply plugin: 'com.android.feature'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 27
defaultConfig {
minSdkVersion 23
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'
}
}
buildToolsVersion '27.0.1'
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation"org.jetbrains.kotlin:kotlin-stdlib-jre8:$kotlin_version"
implementation project(':base')
//add the google gson library
compile 'com.google.code.gson:gson:2.8.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'
}
One workaround I found that is working is to use ai.api.AIConfiguration.SupportedLanguages which is resolving instead of ai.api.android.AIConfiguration.SupportedLanguages which is not resolving in kotlin in Android Studio 3.0 as mentioned in the question.
However, calling ai.api.android.AIConfiguration.SupportedLanguages works just fine in Java code, in which case it is resolving correctly in Android Studio 3.0. Since ai.api.android.AIConfiguration implements ai.api.AIConfiguration, why this issue is arising is puzzling!
Just use this line instead of previous -
ai.api.AIConfiguration.SupportedLanguages.English,

Categories