Buiild:failed compileSDKVersion is not specified (minSdkVersion 16 ; compileSdkVersion 29) - react-native

I have this problem in my react native project. I'm getting the following warning in android studio:
compileSDKVersion is not specified
This my build.gradle:
This happened after done unlink and uninstall in image-picker
buildscript {
ext {
buildToolsVersion = "29.0.2"
minSdkVersion = 16
compileSdkVersion = 29`enter code here`
targetSdkVersion = 29
}
repositories {
google()
jcenter()
}
dependencies {
classpath("com.android.tools.build:gradle:3.5.3")
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
mavenLocal()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url("$rootDir/../node_modules/react-native/android")
}
maven {
// Android JSC is installed from npm
url("$rootDir/../node_modules/jsc-android/dist")
}
google()
jcenter()
maven { url 'https://www.jitpack.io' }
}
}

Related

Missing plugin in `eas build` of react-native project

I am in the process of trying to build a preview Android version using EAS build, but when I run eas build -p android --profile android-preview I get this error:
[stderr] A problem occurred evaluating project ':unimodules-core'.
[stderr] >
[stderr] Plugin with id 'maven' not found.
Now I see people are suggesting replacing this:
apply plugin: 'maven'
With this, in the build.gradle file:
apply plugin: 'maven-publish'
But I don't find that reference to maven anywhere in my project. And my build.gradle file looks like this:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext {
buildToolsVersion = findProperty('android.buildToolsVersion') ?: '31.0.0'
minSdkVersion = Integer.parseInt(findProperty('android.minSdkVersion') ?: '21')
compileSdkVersion = Integer.parseInt(findProperty('android.compileSdkVersion') ?: '31')
targetSdkVersion = Integer.parseInt(findProperty('android.targetSdkVersion') ?: '31')
if (findProperty('android.kotlinVersion')) {
kotlinVersion = findProperty('android.kotlinVersion')
}
frescoVersion = findProperty('expo.frescoVersion') ?: '2.5.0'
kotlinVersion: '1.6.20'
if (System.properties['os.arch'] == 'aarch64') {
// For M1 Users we need to use the NDK 24 which added support for aarch64
ndkVersion = '24.0.8215888'
} else {
// Otherwise we default to the side-by-side NDK version from AGP.
ndkVersion = '21.4.7075529'
}
}
repositories {
google()
mavenCentral()
}
dependencies {
classpath('com.android.tools.build:gradle:7.2.1')
classpath('com.facebook.react:react-native-gradle-plugin')
classpath('de.undercouch:gradle-download-task:5.0.1')
classpath('org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.20')
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
def REACT_NATIVE_VERSION = new File(['node', '--print', "JSON.parse(require('fs').readFileSync(require.resolve('react-native/package.json'), 'utf-8')).version"].execute(null, rootDir).text.trim())
allprojects {
configurations.all {
resolutionStrategy {
force "com.facebook.react:react-native:" + REACT_NATIVE_VERSION
}
}
repositories {
mavenLocal()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url(new File(['node', '--print', "require.resolve('react-native/package.json')"].execute(null, rootDir).text.trim(), '../android'))
}
maven {
// Android JSC is installed from npm
url(new File(['node', '--print', "require.resolve('jsc-android/package.json')"].execute(null, rootDir).text.trim(), '../dist'))
}
google()
mavenCentral {
// We don't want to fetch react-native from Maven Central as there are
// older versions over there.
content {
excludeGroup 'com.facebook.react'
}
}
maven { url 'https://www.jitpack.io' }
}
}
How can I resolve this? Any help would be appreciated.

React-native latest changes/code is not being reflected in the build after running assembleRelase command

I am facing the problem with my release apk which is not updated with my latest code(If i made any changes in code, that reflects locally but not reflecting in release apk). I am using ./gradlew assembleRelease.
I have tried several solutions as
Release APK Not Updating With JavaScript Code
I have shared my build.gradle file for reference.
buildscript {
ext {
buildToolsVersion = "29.0.2"
minSdkVersion = 19
compileSdkVersion = 29
targetSdkVersion = 29
}
repositories {
google()
jcenter()
}
dependencies {
classpath("com.android.tools.build:gradle:4.1.1")
classpath 'com.google.gms:google-services:4.3.4'
}
}
allprojects {
repositories {
mavenLocal()
maven {
url("$rootDir/../node_modules/react-native/android")
}
maven {
url("$rootDir/../node_modules/jsc-android/dist")
}
maven {
url 'https://maven.cashfree.com/release'
}
google()
jcenter()
maven { url 'https://www.jitpack.io' }
}
}

React Native : Task :react-native-maps:compileDebugRenderscript FAILED

I am trying to implement React Native MapView for Android. I did follow github installation instruction but i am facing compilation error when i try to run using react-native run-android command.
Task :react-native-maps:compileDebugRenderscript FAILED
FAILURE: Build failed with an exception.
What went wrong:
Could not resolve all files for configuration ':react-native-maps:debugCompileClasspath'.
Could not resolve com.android.support:support-compat:26.1.0.
Required by:
project :react-native-maps
Cannot find a version of 'com.android.support:support-compat' that satisfies the version constraints:
Dependency path 'MapViewDemo:react-native-maps:unspecified' --> 'com.facebook.react:react-native:0.59.0' --> 'com.android.support:appcompat-v7:28.0.0' -
-> 'com.android.support:support-compat:28.0.0'
Dependency path 'MapViewDemo:react-native-maps:unspecified' --> 'com.facebook.react:react-native:0.59.0' --> 'com.android.support:appcompat-v7:28.0.0' -
-> 'com.android.support:support-core-utils:28.0.0' --> 'com.android.support:support-compat:28.0.0'
Dependency path 'MapViewDemo:react-native-maps:unspecified' --> 'com.facebook.react:react-native:0.59.0' --> 'com.android.support:appcompat-v7:28.0.0' -
-> 'com.android.support:support-fragment:28.0.0' --> 'com.android.support:support-compat:28.0.0'
Dependency path 'MapViewDemo:react-native-maps:unspecified' --> 'com.facebook.react:react-native:0.59.0' --> 'com.android.support:appcompat-v7:28.0.0' -
-> 'com.android.support:support-vector-drawable:28.0.0' --> 'com.android.support:support-compat:28.0.0'
Dependency path 'MapViewDemo:react-native-maps:unspecified' --> 'com.google.android.gms:play-services-base:16.0.1' --> 'com.google.android.gms:play-serv
ices-basement:16.0.1' --> 'com.android.support:support-v4:26.1.0' --> 'com.android.support:support-compat:26.1.0'
Dependency path 'MapViewDemo:react-native-maps:unspecified' --> 'com.facebook.react:react-native:0.59.0' --> 'com.android.support:appcompat-v7:28.0.0' -
-> 'com.android.support:support-core-utils:28.0.0' --> 'com.android.support:loader:28.0.0' --> 'com.android.support:support-compat:28.0.0'
'com.android.support:support-annotations' strictly '26.1.0' because of the following rea
son: debugRuntimeClasspath uses version 26.1.0
Constraint path 'MapViewDemo:react-native-maps:unspecified' --> 'com.android.support:support-annotations' strictly '26.1.0' because of the following rea
son: debugRuntimeClasspath uses version 26.1.0
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
Get more help at https://help.gradle.org
BUILD FAILED in 5s
8 actionable tasks: 8 executed
error Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/getting-started.html
error Command failed: gradlew.bat app:installDebug
App level gradle
apply plugin: "com.android.application"
import com.android.build.OutputFile
project.ext.react = [
entryFile: "index.js"
]
apply from: "../../node_modules/react-native/react.gradle"
def enableSeparateBuildPerCPUArchitecture = false
/**
* Run Proguard to shrink the Java bytecode in release builds.
*/
def enableProguardInReleaseBuilds = false
android {
compileSdkVersion rootProject.ext.compileSdkVersion
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
defaultConfig {
applicationId "com.mapviewdemo"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
versionName "1.0"
}
splits {
abi {
reset()
enable enableSeparateBuildPerCPUArchitecture
universalApk false // If true, also generate a universal APK
include "armeabi-v7a", "x86", "arm64-v8a", "x86-64"
}
}
buildTypes {
release {
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
}
}
// applicationVariants are e.g. debug, release
applicationVariants.all { variant ->
variant.outputs.each { output ->
// For each separate APK per architecture, set a unique version code as described here:
// http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86-64": 4]
def abi = output.getFilter(OutputFile.ABI)
if (abi != null) { // null for the universal-debug, universal-release variants
output.versionCodeOverride =
versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
}
}
}
}
dependencies {
implementation project(':react-native-maps')
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
implementation "com.facebook.react:react-native:+" // From node_modules
implementation(project(':react-native-maps')) {
exclude group: 'com.google.android.gms', module: 'play-services-base'
exclude group: 'com.google.android.gms', module: 'play-services-maps'
}
implementation 'com.google.android.gms:play-services-base:16.1.0'
implementation 'com.google.android.gms:play-services-maps:16.1.0'
}
// Run this once to be able to run the application with BUCK
// puts all compile dependencies into folder libs for BUCK to use
task copyDownloadableDepsToLibs(type: Copy) {
from configurations.compile
into 'libs'
}
configurations.all {
resolutionStrategy {
force 'com.android.support:support-v4:28.0.0'
force 'com.android.support:appcompat-v7:28.0.0'
}
}
Project level gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext {
buildToolsVersion = "28.0.3"
minSdkVersion = 20
compileSdkVersion = 28
targetSdkVersion = 28
supportLibVersion = "28.0.0"
}
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
mavenLocal()
google()
jcenter()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
}
}
Package.json
{
"name": "MapViewDemo",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest"
},
"dependencies": {
"react": "16.8.3",
"react-native": "0.59.0",
"react-native-maps": "^0.23.0"
},
"devDependencies": {
"#babel/core": "7.3.4",
"#babel/runtime": "7.3.4",
"babel-jest": "24.5.0",
"jest": "24.5.0",
"metro-react-native-babel-preset": "0.53.0",
"react-test-renderer": "16.8.3"
},
"jest": {
"preset": "react-native"
}
}
After two day's of struggling i find my solution by my self.The real issue is my project using compileSdkVersion = 28 and react-native-maps node_module using different version of compileSdkVersion.
To solve this issue need to update react-native-maps node_module compileSdkVersion version.
project_name>node_modules>react-native-maps>lib>android>build.gradle
ext {
buildToolsVersion = "28.0.3"
minSdkVersion = 20
compileSdkVersion = 28
targetSdkVersion = 28
supportLibVersion = "28.0.0"
}
Module compile SDK version and support library version should be same as project compile SDK version and support library version.
this also worked for me.
Modify android/build.gradle as follows
1) Add google() inside repositories
buildscript {
repositories {
jcenter()
// add google() here
google()
2) Update com.android.tools.build.gradle to 3.1.0
buildscript {
repositories {
jcenter()
google()
}
dependencies {
// classpath 'com.android.tools.build:gradle:2.2.3'
// update from 2.2.3 to 3.1.0
classpath 'com.android.tools.build:gradle:3.1.0'
3) Add google() inside repositories after dependencies :
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.0'
}
allprojects {
repositories {
mavenLocal()
jcenter()
// add googgle() here
google()
4) Add android.enableAapt2=false to android/gradle.properties
android.enableAapt2=false // < --- add here
android.useDeprecatedNdk=true
MYAPP_RELEASE_STORE_FILE=my-release-key.keystore
MYAPP_RELEASE_KEY_ALIAS=my-key-alias
5) Update gradle version in android/gradle/wrapper/gradle-wrapper.properties :
// from version 2.14.1
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
// change to 4.10.1
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip
6) Run react-native run-android
did you able to make it work ?. i found another solution. in my case, this happens because of the version of react-native (0.59.0). so i change my react-native version in my package.json file form 0.59.0 to ^0.58.6. and the react-native-maps version to ^0.23.0. here are the other steps.
1) in app level settings.gradle, include this
include ':react-native-maps'
project(':react-native-maps').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-maps/lib/android')
2) in project level gradle, remove or comment
ext {
buildToolsVersion = "28.0.3"
minSdkVersion = 20
compileSdkVersion = 28
targetSdkVersion = 28
supportLibVersion = "28.0.0"
}
(inside buildscript{})
3) also in project level gradle,
change the classpath. build.gradle version to 3.1.1
classpath 'com.android.tools.build:gradle:3.1.1'
also add another url inside maven{} (inside allprojects{})
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "https://maven.google.com"
url "$rootDir/../node_modules/react-native/android"
}
4) now change app level gradle as follows
first, change compileSdkVersion to 28 and add new buildToolVersion
compileSdkVersion 28
buildToolsVersion "27.0.3"
then, change min and target SdkVersion as follows (inside defaultConfig)
defaultConfig {
applicationId "com.mapviewdemo"
minSdkVersion 16
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
5) in your AndroidManifest.xml,
first add this code. this is to give permission to access location on your device. add this before <aplication> tag.
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
then you have to add your meta-data before </application> tag.
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="AIzaSyBTSDBtI7_dfdfBeYkNAtdQ8sT67HiOuO0VU"/>
(add your own API key for android:value)
6) then run npm install and try whether this working or not. if this isn't working, you have to download Android SDK from android studio. in my case, i downloaded Android 7.0 and 6.0
i solved this problem using this npm install — save “react-native-maps#jerolimov/react-native-maps#fix-rn59rc-compile-issues”
from: https://github.com/react-native-community/react-native-maps/pull/2702
the problem is with React native 0.59+ that compile with compileSdkVersion 28 and maps use 26
After 2 days I found the problem in my project.
I changed the values of compileSdkVersion, supportLibVersion and playServicesVersion in
android/build.gradle and android/app/build.gradle files to the same values as in node_modules/react-native-maps/lib/android/build.gradle and node_modules/react-native-maps/build.gradle files, this worked for me.
Values of compileSdkVersion, supportLibVersion and playServicesVersion are same in all the below files.
in android/build.gradle file:
...
ext {
compileSdkVersion = 28
targetSdkVersion = 27
buildToolsVersion = "28.0.3"
minSdkVersion = 16
supportLibVersion = "28.0.0"
playServicesVersion = "16.1.0" // or set latest version
androidMapsUtilsVersion = "0.5+"
}
...
in android/app/build.gradle file:
...
android {
compileSdkVersion 28
buildToolsVersion "28.0.3"
defaultConfig {
applicationId "com.reactnativeapp2"
minSdkVersion 19
targetSdkVersion 26
versionCode 1
versionName "1.0"
ndk {
abiFilters "armeabi-v7a", "x86"
}
}
...
...
}
...
dependencies {
...
...
implementation 'com.google.android.gms:play-services-base:16.1.0'
implementation 'com.google.android.gms:play-services-maps:16.1.0'
}
...
in node_modules/react-native-maps/lib/android/build.gradle file:
...
android {
compileSdkVersion safeExtGet('compileSdkVersion', 28)
defaultConfig {
minSdkVersion safeExtGet('minSdkVersion', 16)
targetSdkVersion safeExtGet('targetSdkVersion', 27)
}
}
dependencies {
...
implementation "com.android.support:appcompat-v7:${safeExtGet('supportLibVersion', '28.0.0')}"
implementation "com.google.android.gms:play-services-base:${safeExtGet('playServicesVersion', '16.1.0')}"
implementation "com.google.android.gms:play-services-maps:${safeExtGet('playServicesVersion', '16.1.0')}"
implementation 'com.google.maps.android:android-maps-utils:0.5'
}
...
in node_modules/react-native-maps/build.gradle file:
...
ext {
minSdkVersion = 16
compileSdkVersion = 28
targetSdkVersion = 28
supportLibVersion = '28.0.0'
playServicesVersion = '16.1.0'
}
...

A problem occurred configuring project ':app'

Getting error when trying react-native run-android.I don't know why I'm getting this error.
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':app'.
> Could not resolve all dependencies for configuration ':app:_debugApk'.
> A problem occurred configuring project ':react-native-vector-icons'.
> Could not resolve all dependencies for configuration ':react-native-vector-icons:classpath'.
> Could not find any matches for com.android.tools.build:gradle:2.3.+ as no versions of com.android.tools.build:gradle are available.
android\build.gradle is as follows.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
mavenLocal()
jcenter()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is
installed from npm
url "$rootDir/../node_modules/react-native/android"
}
}
}
gradle version: 3.3,
plugin:2.2.3
Upgrade react-native-vector-icons: "^6.0.2" in package.json
Then run npm i react-native-vector-icons
As a last step, cd android && ./gradlew clean.
Change dependencies from:
dependencies {
implementation "com.facebook.react:react-native:${safeExtGet('reactNativeVersion', '+')}"
}
to:
dependencies {
compile "com.facebook.react:react-native:${safeExtGet('reactNativeVersion', '+')}"
}
also change buildscript dependencies to use: classpath 'com.android.tools.build:gradle:2.2.3'
and maven { url "https://dl.bintray.com/android/android-tools/" } instead of google()
So your ../node_modules/react-native-vector-icons/android/build.gradle should look like this:
buildscript {
repositories {
maven { url "https://dl.bintray.com/android/android-tools/" }
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
}
}
apply plugin: 'com.android.library'
def safeExtGet(prop, fallback) {
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
}
android {
compileSdkVersion safeExtGet('compileSdkVersion', 26)
buildToolsVersion safeExtGet('buildToolsVersion', '26.0.3')
defaultConfig {
minSdkVersion safeExtGet('minSdkVersion', 16)
targetSdkVersion safeExtGet('targetSdkVersion', 26)
versionCode 1
versionName "1.0"
}
lintOptions {
abortOnError false
}
}
repositories {
mavenCentral()
}
dependencies {
compile "com.facebook.react:react-native:${safeExtGet('reactNativeVersion', '+')}"
}

react-native run-android Errors

I've tried several times to run a simple app from React Native on my phone but I think there is a big wall in front of me.
I previously have done following fixes:
change default classpath 'com.android.tools.build:gradle:2.3.0' to classpath 'com.android.tools.build:gradle:3.0.1'
add google() to repositories
change myapp/android/gradle/wrapper/gradle.properties as following:
...distributionUrl=https://services.gradle.org/distributions/gradle-4.1-
all.zip
so my build.gradle is this:
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
}
}
allprojects {
repositories {
mavenLocal()
jcenter()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
google()
}
}
ext {
buildToolsVersion = "26.0.3"
minSdkVersion = 16
compileSdkVersion = 26
targetSdkVersion = 26
supportLibVersion = "26.1.0"
}
and now the issue is following error:
I couldn't find more! I appreciate any help.