How to solved this React native error "Task :app : checkDebugAarMetadata FAILED" - react-native

build.gradle
buildscript {
ext {
buildToolsVersion = "30.0.2"
minSdkVersion = 24
compileSdkVersion = 30
targetSdkVersion = 30
ndkVersion = "21.4.7075529"
}
repositories {
google()
mavenCentral()
}
dependencies {
classpath("com.android.tools.build:gradle:7.0.4")
classpath("com.facebook.react:react-native-gradle-plugin")
classpath("de.undercouch:gradle-download-task:4.1.2")
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
How to solve "Task :app:checkDebugAarMetadata FAILED" this React native error
Error
Error2
enter image description here

Related

A problem occurred evaluating project ':react-native-restart'

I don't know what happened in the build please help me to find the issue.
I'm doing upgrade my react-native app from 0.64.2 to 0.72.1
What went wrong:
A problem occurred evaluating project ':react-native-restart'.
No signature of method: build_afxi0qx2ay1lg1ud0qnu4nfni.android() is applicable for argument types: (build_afxi0qx2ay1lg1ud0qnu4nfni$_run_closure1) values: [build_afxi0qx2ay1lg1ud0qnu4nfni$_run_closure1#1fae07c5]
where
def safeExtGet(name) {
rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties[name]
}
android {
namespace 'co m.reactnativerestart'
compileSdkVersion safeExtGet('compileSdkVersion')
defaultConfig {
minSdkVersion safeExtGet('minSdkVersion')
targetSdkVersion safeExtGet('targetSdkVersion')
versionCode 1
versionName "1.0"
}
buildscript {
ext {
buildToolsVersion = "31.0.0"
minSdkVersion = 21
compileSdkVersion = 31
targetSdkVersion = 30
ndkVersion = "20.1.5948944"
googlePlayServicesAuthVersion = "16.0.1"
firebaseIidVersion = "18.0.0"
kotlin_version = '1.6.10' // <- add this line
}
I'm trying to solve the issue but it not resolved please guide me for the solution

React Native - upload to Google Play error: Your app currently targets API level 30 and must target at least API level 31

I got the following error while upload my app to google:
Your app currently targets API level 30 and must target at least API level 31 to ensure it is built on the latest APIs optimized for security and performance. Change your app's target API level to at least 31.
Here is my android/build.gradle:
buildscript {
ext {
buildToolsVersion = "30.0.2"
minSdkVersion = 21
compileSdkVersion = 30
targetSdkVersion = 30
ndkVersion = "21.4.7075529"
}
...
}
How can I upgrade app target API to level 31?
I recently had this warning in my google console.
To solve it, I simply updated the targetSdkVersion from 30 to 31 in android/app/build.gradle file, which gives the following code (I also had to make sure the compileSdkVersion was set to 31):
android {
compileSdkVersion 31 // You can use
//...
defaultConfig {
targetSdkVersion 31
// ...
}
And I had to modify the buildscript in the android/app file as below:
buildscript {
ext {
buildToolsVersion = '30.0.2'
minSdkVersion = 21
compileSdkVersion = 31 // You can use ``rootProject.ext.compileSdkVersion`` instead
targetSdkVersion = // You can use ``rootProject.ext.targetSdkVersion`` instead
ndkVersion = '21.4.7075529'
playServicesVersion = '17.0.0' // or find latest version
androidMapsUtilsVersion = '2.3.0'
}
// ...
}
buildscript {
ext {
buildToolsVersion = "31.0.0"
minSdkVersion = 21
compileSdkVersion = 31
targetSdkVersion = 31
ndkVersion = "20.1.5948944"
}
...
}
<activity
android:name=".MainActivity"
android:exported="true" ... >
Add android:exported="true" or android:exported="false" in AndroidManifest.xml
file.
buildscript {
ext {
buildToolsVersion = "31.0.0"
minSdkVersion = 21
compileSdkVersion = 31
targetSdkVersion = 31
ndkVersion = "20.1.5948944"
}
...
}
change compileSdkVersion = 31 and compileSdkVersion = 31 in android/gradle/build.gradle [REACT NATIVE APPS]
I also got the same error when I deploy my application on the Play Store
so simply update the targetSdkVersion = 30 to targetSdkVersion = 31 in Your_project/android/build.gradle
targetSdkVersion = 31
and then run
cd android
./gradlew clean

error when import kotlin project android studio 3.5.3

I try to import project
i get this error when import project in android studio 3.5.3
Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified
and this error
This version of Android Studio cannot open this project, please retry with Android Studio 3.6 or newer
import org.jetbrains.kotlin.config.KotlinCompilerVersion
plugins {
id("com.android.application")
kotlin("android")
kotlin("kapt")
}
// https://stackoverflow.com/a/52441962
fun String.runCommand(
workingDir: File = File("."),
timeoutAmount: Long = 60,
timeoutUnit: TimeUnit = TimeUnit.SECONDS
): String? = try {
ProcessBuilder("\\s".toRegex().split(this))
.directory(workingDir)
.redirectOutput(ProcessBuilder.Redirect.PIPE)
.redirectError(ProcessBuilder.Redirect.PIPE)
.start().apply { waitFor(timeoutAmount, timeoutUnit) }
.inputStream.bufferedReader().readText()
} catch (e: java.io.IOException) {
e.printStackTrace()
null
}
android {
compileSdkVersion(29)
buildToolsVersion("29.0.2")
viewBinding.isEnabled = true
val gitVersion = listOf(
"git rev-parse --abbrev-ref HEAD",
"git rev-list HEAD --count",
"git rev-parse --short HEAD"
).joinToString("-") { it.runCommand()?.trim() ?: "" } +
(if (("git status -s".runCommand() ?: "").isBlank()) "" else "-dirty")
defaultConfig {
applicationId = "com.test.cale"
minSdkVersion(15)
targetSdkVersion(29)
versionCode = 621
versionName = "6.2.1"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
resConfigs("en", "fa", "ckb", "ar", "ur", "ps", "glk", "azb", "ja")
setProperty("archivesBaseName", "PersianCalendar-$versionName-$gitVersion")
}
signingConfigs {
create("nightly") {
storeFile = rootProject.file("nightly.keystore")
storePassword = "android"
keyAlias = "androiddebugkey"
keyPassword = "android"
}
}
buildTypes {
create("nightly") {
signingConfig = signingConfigs.getByName("nightly")
versionNameSuffix = "-${defaultConfig.versionName}-$gitVersion-nightly"
applicationIdSuffix = ".nightly"
isMinifyEnabled = true
isShrinkResources = true
}
getByName("debug") {
versionNameSuffix = "-${defaultConfig.versionName}-$gitVersion"
applicationIdSuffix = ".debug"
}
getByName("release") {
isMinifyEnabled = true
isShrinkResources = true
// Maybe proguard-android-optimize.txt in future
// setProguardFiles(listOf(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"))
}
}
}
dependencies {
implementation(project(":equinox"))
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk7:${KotlinCompilerVersion.VERSION}")
implementation("androidx.appcompat:appcompat:1.1.0")
implementation("androidx.preference:preference-ktx:1.1.0")
implementation("androidx.recyclerview:recyclerview:1.1.0")
implementation("androidx.cardview:cardview:1.0.0")
implementation("androidx.viewpager2:viewpager2:1.0.0")
implementation("com.google.android.material:material:1.1.0-rc02")
implementation("com.google.android:flexbox:1.1.0")
implementation("com.google.android.apps.dashclock:dashclock-api:2.0.0")
val navVersion = "2.1.0"
implementation("androidx.navigation:navigation-fragment-ktx:$navVersion")
implementation("androidx.navigation:navigation-ui-ktx:$navVersion")
implementation("androidx.core:core-ktx:1.1.0")
implementation("androidx.fragment:fragment-ktx:1.1.0")
implementation("androidx.activity:activity-ktx:1.0.0")
implementation("androidx.browser:browser:1.0.0")
implementation("androidx.work:work-runtime-ktx:2.2.0")
// debugImplementation("com.squareup.leakcanary:leakcanary-android:2.0-alpha-2")
// debugImplementation("com.github.pedrovgs:lynx:1.1.0")
testImplementation("junit:junit:4.12")
androidTestImplementation("androidx.test:runner:1.2.0")
androidTestImplementation("androidx.test:rules:1.2.0")
androidTestImplementation("androidx.test.espresso:espresso-contrib:3.2.0")
androidTestImplementation("androidx.test.espresso:espresso-core:3.2.0")
}
please resolve the problem
Top-level Project Gradle
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath("com.android.tools.build:gradle:3.6.0-rc01")
classpath(kotlin("gradle-plugin", version = "1.3.61"))
}
}
allprojects {
repositories {
google()
jcenter()
maven("https://jitpack.io")
}
}
task("clean") {
delete(rootProject.buildDir)
}

Cause: org.gradle.api.internal.artifacts.DefaultModuleVersionSelector

cant import gradle project in intellij idea
Cause: org.gradle.api.internal.artifacts.DefaultModuleVersionSelector
I couldn't build the project through terminal also.Error in terminal is:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':commons:compileJava'.
Compilation failed;
gradle file:
buildscript {
repositories {
mavenCentral()
// maven { url "${artifactoryRepoUrl}" }
jcenter()
} ext {
springBootVersion = '1.4.2.RELEASE'
commonsVersion = '0.4.3'
recruiterVersion = '0.2.6'
jobseekerVersion = '0.1.9'
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.4.2.RELEASE")
classpath "org.jfrog.buildinfo:build-info-extractor-gradle:4+"
}
}
subprojects {
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'maven'
apply plugin: 'org.springframework.boot'
apply plugin: 'maven-publish'
repositories {
mavenLocal()
mavenCentral()
// maven { url "${artifactoryRepoUrl}" }
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
ext {
springCloudVersion = '1.1.2.RELEASE'
springSecurityVersion = '4.1.1.RELEASE'
springRedisVersion = '1.7.2.RELEASE'
jedisVersion = '2.7.2'
log4jVersion = '2.6.2'
jacksonVersion = '2.8.1'
apacheCommonsVersion = '2.4.2'
lombokVersion = '1.16.10'
jnaVersion = '3.0.9'
jestVersion = '2.0.3'
beanutilsVersion = '1.9.2'
jwtVersion = '0.6.0'
springAWSVersion = '1.1.0.RELEASE'
mysqlConnectorVersion = '6.0.3'
springJDBCVersion = '4.3.2.RELEASE'
dbcpVersion = '2.1.1'
springCloudAWSVersion = '1.0.4.RELEASE'
elasticClientVersion = '5.0.2'
swaggerVersion = '2.4.0'
jose4jVersion = '0.5.4'
}
configurations.all {
exclude group: 'org.springframework.boot', module: 'spring-boot-starter-logging'
exclude group: 'org.springframework.boot', module: 'logback-classic'
}
}
try changing gradle file like :
buildscript {
ext {
springBootVersion = '1.4.2.RELEASE'
commonsVersion = '0.4.3'
recruiterVersion = '0.2.6'
jobseekerVersion = '0.1.9'
}
repositories {
mavenCentral()
jcenter()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.4.2.RELEASE")
classpath "org.jfrog.buildinfo:build-info-extractor-gradle:4+"
}
}
subprojects {
...
Try to remove the following line:
classpath "org.jfrog.buildinfo:build-info-extractor-gradle:4+"

Add ViewPagerIndicator to project

In general such a problem trying to add ViewPagerIndicator the project.
Gradle: Execution failed for task ':SherlockTest:dexDebug'.
> Running D:\Programs\AS\sdk\build-tools\android-4.2.2\dx.bat failed. See output
depending:
SherlockTestProject
settings.gradle
include ':SherlockTest'
include ':libraries:ViewPagerIndicator'
include ':libraries:ActionBarSherlock'
SherlockTest
build.grandle
buildscript {
repositories {
maven { url 'http://repo1.maven.org/maven2' }
}
dependencies {
classpath 'com.android.tools.build:gradle:0.4'
}
}
apply plugin: 'android'
dependencies {
compile project(':libraries:ActionBarSherlock')
compile project(':libraries:ViewPagerIndicator')
}
android {
compileSdkVersion 17
buildToolsVersion "17.0.0"
defaultConfig {
minSdkVersion 7
targetSdkVersion 16
}
}
libraries\ActionBarSherlock
build.grandle
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.4'
}
}
apply plugin: 'android-library'
dependencies {
compile files('libs/android-support-v4.jar')
compile files('libs/android-support-v13.jar')
}
android {
compileSdkVersion 17
buildToolsVersion "17"
defaultConfig {
minSdkVersion 7
targetSdkVersion 16
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
}
}
libraries\ViewPagerIndicator
build.grandle
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.4'
}
}
apply plugin: 'android-library'
dependencies {
compile files('libs/android-support-v4.jar')
compile files('libs/android-support-v13.jar')
}
android {
compileSdkVersion 17
buildToolsVersion "17"
defaultConfig {
minSdkVersion 7
targetSdkVersion 16
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
res.srcDirs = ['res']
}
}
}
Since viewpagerindicator uses Maven, we should be able to include it like any maven project. Also, on maven, they have a tab for gradle projects. Link to project on maven page
I am starting to write an app using this as well, so we will see how it goes.
In your build.gradle,
dependencies{
...
compile 'com.viewpagerindicator:parent:2.4.1'
}