I fail to run the OboeAudioRecorder with the most recent Android Studio update.
Could you please tell me what's wrong?
It is probably due to a librairy in conflict with other ones.
Error message:
Build file '/Users/*****/Documents/OboeAudioRecorder-master/app/build.gradle' line: 1
A problem occurred evaluating project ':app'.
> Failed to apply plugin 'com.android.internal.application'.
> The option 'android.enablePrefab' is deprecated.
It was removed in version 4.1 of the Android Gradle plugin.
This property has been replaced by android.buildFeatures.prefab (DSL)
Gradle project:
to all sub-projects/modules. buildscript {
ext.kotlin_version = "1.5.21"
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.1.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
} }
allprojects {
repositories {
google()
jcenter()
} }
task clean(type: Delete) {
delete rootProject.buildDir }
Those lines are correctly built.
Gradle module:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 29
defaultConfig {
applicationId "com.example.oboeaudiorecorder"
minSdkVersion 23
targetSdkVersion 32
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
externalNativeBuild {
cmake {
cppFlags ""
}
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
externalNativeBuild {
cmake {
path "src/main/cpp/CMakeLists.txt"
version "3.18.1"
}
}
}
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}
I've also applied all the necessary updates in order to have the correct versions of gradle and CMake.
Source code: https://github.com/reuniware/OboeAudioRecorder
Related
C:/Users/LENOVO/.gradle/caches/transforms-2/files-2.1/2bcd0a6b95744b6f0ee26f9336bd22eb/jetified-annotation-jvm-1.6.0-beta01.jar!/META-INF/annotation.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.8.0, expected version is 1.6.0.
buildscript {
ext.kotlin_version = '1.4.32'
ext.anko_version='0.10.8'
repositories {
jcenter()
maven {
url 'https://maven.google.com/'
name 'Google'
}
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.2'
classpath 'com.google.gms:google-services:4.3.3'
classpath 'org.greenrobot:greendao-gradle-plugin:3.2.1'
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.10'
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.4.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
// Add the dependency for the Performance Monitoring plugin
classpath 'com.google.firebase:perf-plugin:1.4.1'
}
}
This project contains a few incompatible or even dangerous things, that also lead you to the problem you're having:
jcenter() is not in service anymore, so it should be replaced by mavenCentral() or your dependencies will not be correctly resolved.
You specify both Kotlin 1.4.32 (no longer maintained) and 1.6.10 (no longer ideal, but still usable) and the classes will definitely not be compatible between them.
Some of your other dependencies might be even newer and use Kotlin 1.8.0, so your older runtimes won't be able to read their metadata.
Recently, I faced a similar issue on creating a new project in Android studio with Compose Material3 template.
So I upgraded below libraries/plugins solve my issue. I also attached my gradle files for reference.
kotlin version to 1.8.0
kotlinCompilerExtensionVersion '1.4.0'
compose_version to 1.3.1
build.gradle(app)
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
}
android {
namespace 'com.hometech.anatomymuscles'
compileSdk 33
defaultConfig {
applicationId "com.hometech.anatomymuscles"
minSdk 23
targetSdk 33
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
useSupportLibrary true
}
}
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'
}
buildFeatures {
compose true
}
composeOptions {
kotlinCompilerExtensionVersion '1.4.0'
}
packagingOptions {
resources {
excludes += '/META-INF/{AL2.0,LGPL2.1}'
}
}
}
dependencies {
implementation 'androidx.core:core-ktx:1.9.0'
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.5.1'
implementation 'androidx.activity:activity-compose:1.6.1'
implementation "androidx.compose.ui:ui:$compose_version"
implementation "androidx.compose.ui:ui-tooling-preview:$compose_version"
implementation 'androidx.compose.material3:material3:1.1.0-alpha05'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_version"
debugImplementation "androidx.compose.ui:ui-tooling:$compose_version"
debugImplementation "androidx.compose.ui:ui-test-manifest:$compose_version"
}
build.gradle(project)
buildscript {
ext {
compose_version = '1.3.3'
}
}// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id 'com.android.application' version '7.4.1' apply false
id 'com.android.library' version '7.4.1' apply false
id 'org.jetbrains.kotlin.android' version '1.8.0' apply false
}
ive being trying to write a loggin with google , phone and email activity, but the app is not importing : com.firebase.ui.auth.AuthUI
this is my app build gradle
plugins {
id 'com.android.application'
id 'com.google.gms.google-services'
}
android {
compileSdk 32
defaultConfig {
applicationId "com.example.stockmng"
minSdk 22
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.7.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
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.firebase:firebase-auth:21.1.0'
implementation 'com.google.firebase:firebase-firestore:24.4.1'
implementation 'com.google.firebase:firebase-database:20.1.0'
implementation 'com.firebaseui:firebase-ui-auth:6.2.1'
implementation 'com.google.firebase:firebase-core:21.1.1'
implementation 'com.google.android.gms:play-services-auth:20.4.0'
//apply plugin: 'com.android.application'
implementation 'com.github,MrNouri:DynamicSizes:1.0'
}
and my project gradle
buildscript {
repositories{
google()
mavenCentral()
gradlePluginPortal()
maven { url 'https://jitpack.io'}
}
dependencies {
classpath 'com.google.gms:google-services:4.3.14'
}
}// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id 'com.android.application' version '7.2.1' apply false
id 'com.android.library' version '7.2.1' apply false
}
task clean(type: Delete) {
delete rootProject.buildDir
}
i tried adding, changing updating the implentations in app build gradle,
i have permission.internet and ACCES_NETWORK_STATE added to the manifest.
a configured the api keys,and oAuth updated,
also adding in google maven and maven central in repository en the project gradel,
nothing works.
y build is failing with the error message
Unable to resolve dependency for ':app#debugUnitTest/compileClasspath': Could not resolve androidx.constraintlayout:constraintLayout:1.1.3
ConstraintLayout version:1.1.3
Gradle plugin version : 4.0.1
Gradle version : 6.1.1
My app_build gradle is as follows
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.xxxxx.xxxxxxx"
minSdkVersion 19
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.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'
implementation 'androidx.annotation:annotation:1.1.0'
// To use the Java-compatible #Experimental API annotation
implementation "androidx.annotation:annotation-experimental:1.0.0"
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
def room_version = "2.2.5"
def lifecycle_version = "2.2.0"
implementation "androidx.room:room-runtime:$room_version"
annotationProcessor "androidx.room:room-compiler:$room_version"
// For Lifecycle dependencies:
implementation "androidx.lifecycle:lifecycle-extensions:$lifecycle_version"
annotationProcessor "androidx.lifecycle:lifecycle-compiler:$lifecycle_version"
// optional - RxJava support for Room
implementation "androidx.room:room-rxjava2:$room_version"
// Test helpers
testImplementation "androidx.room:room-testing:$room_version"
}
My project build.gradle is
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.0.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
maven {
// For Room Persistence Library
url "https://maven.google.com"
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
The package androidx.constraintlayout does not exist in jcenter()
https://jcenter.bintray.com/androidx/
what you can do however,
allprojects {
repositories {
mavenCentral()
google()
jcenter()
maven {
// For Room Persistence Library
url "https://maven.google.com"
}
} }
I'm having this error
ERROR: Unable to resolve dependency for ':app#debug/compileClasspath':
Could not find any version that matches
com.android.support:appcompat-v7:29.+.
I slept while the Android studio was downloading gradle ,so My laptop went in sleep mode and stopped everything.
Now I'm getting the error above. I think something is missing from the first run download ,How can i fix it ?
----------EDIT
apply plugin: 'com.android.application'
android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
defaultConfig {
applicationId "com.example.myapplication"
minSdkVersion 15
targetSdkVersion 29
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:29.+'
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'
}
and the second one
// 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.3.0'
// 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
}
According to Google: This is the stable release of Support Library 28.0.0 and is suitable for use in production. This will be the last feature release under the android.support packaging, and developers are encouraged to migrate to AndroidX.
Refer to https://developer.android.com/topic/libraries/support-library/revisions
This is why you are getting error on
implementation 'com.android.support:appcompat-v7:29.+'
Either migrate to androidX or you can use
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'
in your gradle
Hope this will help you
Happy Coding
I want to test a class using JUnit5 but at the time gradle runs the app:kaptDebugAndroidTestKotlin task I get the issue.
I have already tried the solutions in the following links but nothing helps so far:
NonExistentClass cannot be converted to Annotation
error: incompatible types: NonExistentClass cannot be converted to Annotation #error.NonExistentClass()
my project build.gradle file:
buildscript {
ext.kotlin_version = '1.3.40'
ext.anko_version='0.10.8'
ext.junit_version='5.5.0'
repositories {
google()
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "io.realm:realm-gradle-plugin:5.11.0"
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
my module build.gradle file:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
apply plugin: 'realm-android'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.hays.test"
minSdkVersion 15
targetSdkVersion 28
versionCode 1
versionName "1.0"
multiDexEnabled true
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
compileOptions {
sourceCompatibility 1.8
targetCompatibility 1.8
}
androidExtensions {
experimental = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
}
realm {
kotlinExtensionsEnabled = true
}
kapt {
correctErrorTypes = true
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.core:core-ktx:1.0.2'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.google.android.material:material:1.0.0'
testImplementation "org.junit.jupiter:junit-jupiter-api:$junit_version"
testImplementation "org.junit.jupiter:junit-jupiter-engine:$junit_version"
testImplementation "org.junit.vintage:junit-vintage-engine:$junit_version"
testImplementation 'io.mockk:mockk:1.9.3'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'io.reactivex.rxjava2:rxandroid:2.1.1'
implementation 'io.reactivex.rxjava2:rxjava:2.2.9'
implementation 'io.reactivex.rxjava2:rxkotlin:2.3.0'
implementation 'com.google.code.gson:gson:2.8.5'
implementation 'com.github.bumptech.glide:glide:4.9.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.9.0'
implementation 'com.squareup.okhttp3:okhttp:3.12.0'
implementation 'com.jakewharton.rxbinding2:rxbinding:2.2.0'
implementation 'com.jakewharton.rxbinding2:rxbinding-appcompat-v7:2.2.0'
implementation 'com.android.support:support-annotations:28.0.0'
implementation group: 'org.jetbrains.kotlinx', name: 'kotlinx-coroutines-android', version: '1.3.0-M1'
implementation "org.jetbrains.anko:anko:$anko_version"
}
and my gradle.properties file:
kotlin.code.style=official
org.gradle.jvmargs=-Xmx1536m
android.useAndroidX=true
android.enableJetifier=true
android.databinding.enableV2=true
I tried to run the test but what I get while compiling is the following:
C:\project_path\app\build\tmp\kapt3\stubs\debugAndroidTest\com\package\test\module\search\SearchPresenterTest.java:20: error: incompatible types: NonExistentClass cannot be converted to Annotation
#error.NonExistentClass()
The file under build folder has some of the following:
#error.NonExistentClass()
public final void setUpMocks() {
}
#error.NonExistentClass()
public final void onSearch() {
}
While the original kotlin test file is like the following lines:
#BeforeEach
fun setUpMocks() {
clearAllMocks()
}
#Test
fun onSearch() {
verify { view.onSearch() }
}
Seems that I mixed some JUnit4 dependencies with those of JUnit5 so by removing the following lines (like the AndroidJUnitRunner class) in the dependencies I got it working:
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
kapt("org.jetbrains.kotlin.kapt:org.jetbrains.kotlin.kapt.gradle.plugin:1.3.31:pom")
And I added back again those of the jupiter packages:
testImplementation "org.junit.jupiter:junit-jupiter-api:$junit_version"
testImplementation "org.junit.jupiter:junit-jupiter-engine:$junit_version"
testImplementation "org.junit.vintage:junit-vintage-engine:$junit_version"
Also the org.junit classes in all the tests have to be replaced by their equivalent of the org.junit.jupiter package.
That made it compile the test without issues.