Hey im trying to make a running tracker app for my school project and I need to sync this gradle code from a youtube video I saw to my project
https://github.com/philipplackner/RunningAppYT/blob/master/app/build.gradle
I try to sync it to my sdk version 31 and I get errors
I dont know what to do please help
So far I tried that and it's not working:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
apply plugin: "androidx.navigation.safeargs.kotlin"
apply plugin: "org.jetbrains.kotlin.android"
android {
compileSdkVersion 31
buildToolsVersion "29.0.3"
defaultConfig {
applicationId "com.example.runningproject"
minSdkVersion 21
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
}
kotlinOptions {
jvmTarget = JavaVersion.VERSION_1_8.toString()
}
}
buildscript {
repositories {
google()
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.20-Beta"
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'androidx.core:core-ktx:1.9.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
// Material Design
implementation 'com.google.android.material:material:1.9.0-alpha01'
// Architectural Components
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.1"
// Room
implementation "androidx.room:room-runtime:2.5.0"
kapt "androidx.room:room-compiler:2.5.0"
// Kotlin Extensions and Coroutines support for Room
implementation "androidx.room:room-ktx:2.5.0"
// Coroutines
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.5'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.1'
// Coroutine Lifecycle Scopes
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.1"
implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.5.1"
// Navigation Components
implementation "androidx.navigation:navigation-fragment-ktx:2.5.3"
implementation "androidx.navigation:navigation-ui-ktx:2.5.3"
// Glide
implementation 'com.github.bumptech.glide:glide:4.11.0'
kapt 'com.github.bumptech.glide:compiler:4.11.0'
// Google Maps Location Services
implementation 'com.google.android.gms:play-services-location:21.0.1'
implementation 'com.google.android.gms:play-services-maps:18.1.0'
// Dagger Core
implementation "com.google.dagger:dagger:2.28.3"
kapt "com.google.dagger:dagger-compiler:2.25.2"
// Dagger Android
api 'com.google.dagger:dagger-android:2.35.1'
api 'com.google.dagger:dagger-android-support:2.28.1'
kapt 'com.google.dagger:dagger-android-processor:2.23.2'
// Easy Permissions
implementation 'pub.devrel:easypermissions:3.0.0'
// Timber
implementation 'com.jakewharton.timber:timber:4.7.1'
// MPAndroidChart
implementation 'com.github.PhilJay:MPAndroidChart:v3.1.0'
}
}
plugins {
id 'com.android.application' version '7.3.0' apply false
id 'com.android.library' version '7.3.0' apply false
id 'kotlin-android'
id("org.jetbrains.kotlin.android") version "1.8.20-Beta"
}
Related
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
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'
Whenever I run the app for the first time, I get the following exception
com.mypckg.myapp E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.mypckg.myapp, PID: 6460
android.content.res.Resources$NotFoundException: Resource ID #0x20c0016
at android.content.res.ResourcesImpl.getValue(ResourcesImpl.java:237)
at android.content.res.Resources.getInteger(Resources.java:1127)
at org.chromium.ui.base.DeviceFormFactor.isTablet(chromium-TrichromeWebViewGoogle.aab-stable-438907233:2)
at Vm.a(chromium-TrichromeWebViewGoogle.aab-stable-438907233:2)
at Lc.run(chromium-TrichromeWebViewGoogle.aab-stable-438907233:3)
at org.chromium.content.browser.BrowserStartupControllerImpl.e(chromium-TrichromeWebViewGoogle.aab-stable-438907233:10)
at org.chromium.content.browser.BrowserStartupControllerImpl.g(chromium-TrichromeWebViewGoogle.aab-stable-438907233:7)
at t6.run(chromium-TrichromeWebViewGoogle.aab-stable-438907233:20)
at org.chromium.base.ThreadUtils.f(chromium-TrichromeWebViewGoogle.aab-stable-438907233:2)
at sp0.j(chromium-TrichromeWebViewGoogle.aab-stable-438907233:32)
at rp0.run(chromium-TrichromeWebViewGoogle.aab-stable-438907233:2)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7682)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:516)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)
Then when I open the app for the second,third time, it works fine.
I am guessing this might be due to some libraries, so here is my app.gradle file
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
apply plugin: 'dagger.hilt.android.plugin'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.google.firebase.crashlytics'
android {
compileSdkVersion 29
buildToolsVersion "30.0.1"
defaultConfig {
applicationId "com.mypckg.myapp"
minSdkVersion 19
targetSdkVersion 29
versionCode 16
versionName "1.0.17"
multiDexEnabled true
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
setProperty("archivesBaseName", "MyApp"+ versionName +"_"+new Date().format( 'yyyy-MM-dd HH:mm' ))
}
buildTypes {
debug {
buildConfigField "String", 'BASE_URL', '"https://baseurl.com/"'
}
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
buildConfigField "String", 'BASE_URL', '"https://baseurl.com/"'
}
}
viewBinding {
enabled = true
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = JavaVersion.VERSION_1_8.toString()
}
}
dependencies {
def room_version = '2.2.6'
def retrofitVersion = '2.8.1'
def okhttpVersion = '4.5.0'
def daggerVersion = '2.31.2'
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.3.2'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
implementation 'com.android.support:multidex:1.0.3'
implementation 'com.google.android.material:material:1.4.0-alpha01'
implementation "androidx.room:room-runtime:$room_version"
kapt "androidx.room:room-runtime:$room_version"
kapt "androidx.room:room-compiler:$room_version"
implementation "androidx.room:room-rxjava2:$room_version"
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.0"
implementation 'androidx.fragment:fragment-ktx:1.3.0'
implementation "com.github.doyaaaaaken:kotlin-csv-jvm:0.11.0"
implementation "com.squareup.retrofit2:retrofit:$retrofitVersion"
implementation "com.squareup.retrofit2:converter-gson:$retrofitVersion"
implementation "com.squareup.okhttp3:okhttp:$okhttpVersion"
implementation "com.squareup.okhttp3:logging-interceptor:$okhttpVersion"
implementation 'com.squareup.retrofit2:adapter-rxjava2:2.3.0'
implementation "com.google.dagger:dagger:$daggerVersion"
kapt "com.google.dagger:dagger-compiler:$daggerVersion"
implementation "com.google.dagger:hilt-android:2.31.2-alpha"
kapt "com.google.dagger:hilt-android-compiler:2.31.2-alpha"
implementation 'androidx.hilt:hilt-lifecycle-viewmodel:1.0.0-alpha03'
kapt 'androidx.hilt:hilt-compiler:1.0.0-alpha03'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.4.1'
debugImplementation 'com.amitshekhar.android:debug-db:1.0.6'
implementation 'com.github.quickpermissions:quickpermissions-kotlin:0.4.0'
implementation 'com.facebook.android:audience-network-sdk:5.10.0'
implementation platform('com.google.firebase:firebase-bom:26.6.0')
implementation 'com.google.firebase:firebase-crashlytics-ktx'
implementation 'com.google.firebase:firebase-analytics-ktx'
implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.1.0"
implementation 'com.jakewharton.threetenabp:threetenabp:1.2.4'
implementation 'com.github.PhilJay:MPAndroidChart:v3.1.0'
}
and this is my project level build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = "1.4.31"
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.dagger:hilt-android-gradle-plugin:2.28-alpha'
classpath 'com.google.gms:google-services:4.3.5'
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.5.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
maven { url "http://jitpack.io/" }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Any help would be highly appreciated. Thanks
This issue was also mentioned in Samsung Developer Forum, but no solution offered. See https://forum.developer.samsung.com/t/android-content-res-resources-notfoundexception-in-org-chromium-ui-base-deviceformfactor-istablet/17544/4
Is there any more information on this issue? I see it in my app too. Initially I saw it ONLY on Samsung S21 phones with Android 12, now I got also a crash report on Crashlytics on one Pixel 3 phone with Android 12, and several on Samsung S21 with Android 11… It happens most often on this call:
String uas = WebSettings.getDefaultUserAgent(context);
I suspect that it happens only if called when no WebView control was created yet, as so far I did not find crashes from similar calls later in the app, when the control was created in it. Surrounding this line with try - catch does not help, as the crash seems to happen in another thread.
Greg
I have the same issue,
due I move MobileAds.initialize from the Application class to another class.
You can try to init MobileAds.initialize at Application class
I started a new project and put fire-base cloud:
apply plugin: 'com.android.application'
apply plugin: 'android-apt'
android {
compileSdkVersion 28
buildToolsVersion "28.0.3"
defaultConfig {
applicationId "android.example.com.squawker"
minSdkVersion 16
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'])
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
//noinspection GradleCompatible
implementation 'com.android.support:appcompat-v7:28.0.0'
testImplementation 'junit:junit:4.12'
// RecyclerView
implementation 'com.android.support:recyclerview-v7:28.0.0'
// Schematic dependencies for ContentProvider
apt 'net.simonvt.schematic:schematic-compiler:0.6.3'
implementation 'net.simonvt.schematic:schematic:0.6.3'
// Preferences Dependencies
implementation 'com.android.support:preference-v7:28.0.0'
// Firebase dependency
implementation 'com.google.firebase:firebase-messaging:17.3.4'
}
// Apply the Google Services plugin. Make sure to add the google-services.json file in the app
// folder. You download it from the Firebase console
apply plugin: 'com.google.gms.google-services'
and this error apeared:
WARNING: API 'variant.getJavaCompile()' is obsolete and has been replaced with 'variant.getJavaCompileProvider()'.
It will be removed at the end of 2019.
For more information, see https://d.android.com/r/tools/task-configuration-avoidance.
To determine what is calling variant.getJavaCompile(), use -Pandroid.debug.obsoleteApi=true on the command line to display a stack trace.
Affected Modules: app
This probably because of apt plugin which is already obsolete. So, you need to remove the following:
apply plugin: 'android-apt'
then change the following:
apt 'net.simonvt.schematic:schematic-compiler:0.6.3'
with:
annotationProcessor 'net.simonvt.schematic:schematic-compiler:0.6.3'
Similar to API 'variant.getExternalNativeBuildTasks()' is obsolete and has been replaced with 'variant.getExternalNativeBuildProviders() Happy Coding!
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,