I have some issues trying to generate a new release of my apk.
(However the app runs normally in debug with react-native run-android
)
First of all i had this Output message:
Task :react-native-maps:compileReleaseJavaWithJavac Note: Some input files use or override a deprecated API. Note: Recompile with -Xlint:deprecation for details. Note: Some input files use unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details.
FAILURE: Build failed with an exception.
> What went wrong: Could not resolve all files for configuration ':react-native- maps:lintClassPath'.
Could not find com.android.tools.lint:lint-gradle:26.1.0. Searched in the following locations: file:/C:/Users/kev_w/AppData/Local/Android/Sdk/extras/m2repository/com/android/tools/lint/lint-gradle/26.1.0/lint-gradle-26.1.0.pom file:/C:/Users/kev_w/AppData/Local/Android/Sdk/extras/m2repository/com/android/tools/lint/lint-gradle/26.1.0/lint-gradle-26.1.0.jar file:/C:/Users/kev_w/AppData/Local/Android/Sdk/extras/google/m2repository/com/android/tools/lint/lint-gradle/26.1.0/lint-gradle-26.1.0.pom file:/C:/Users/kev_w/AppData/Local/Android/Sdk/extras/google/m2repository/com/android/tools/lint/lint-gradle/26.1.0/lint-gradle-26.1.0.jar file:/C:/Users/kev_w/AppData/Local/Android/Sdk/extras/android/m2repository/com/android/tools/lint/lint-gradle/26.1.0/lint-gradle-26.1.0.pom file:/C:/Users/kev_w/AppData/Local/Android/Sdk/extras/android/m2repository/com/android/tools/lint/lint-gradle/26.1.0/lint-gradle-26.1.0.jar file:/C:/Users/kev_w/.m2/repository/com/android/tools/lint/lint-gradle/26.1.0/lint-gradle-26.1.0.pom file:/C:/Users/kev_w/.m2/repository/com/android/tools/lint/lint-gradle/26.1.0/lint-gradle-26.1.0.jar https://jcenter.bintray.com/com/android/tools/lint/lint-gradle/26.1.0/lint-gradle-26.1.0.pom https://jcenter.bintray.com/com/android/tools/lint/lint-gradle/26.1.0/lint-gradle-26.1.0.jar file:/C:/Users/kev_w/Desktop/Ulabs/appreactnative/testApp/node_modules/react-native/android/com/android/tools/lint/lint-gradle/26.1.0/lint-gradle-26.1.0.pom file:/C:/Users/kev_w/Desktop/Ulabs/appreactnative/testApp/node_modules/react-native/android/com/android/tools/lint/lint-gradle/26.1.0/lint-gradle-26.1.0.jar Required by: project :react-native-maps*
1.What i did to fix this:
Adding google()
in my android/build.gradle >> allprojects {...}
:
buildscript {
repositories {
mavenLocal()
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
mavenLocal()
jcenter()
google()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
After adding this, the build is successfull, but my apk crashes instantly when i open it...
As i said in the beginning, before adding google()
, my project was running normally in debug with react-native run-android
.
But now, neither the apk nor the debug project works.
It crashes without any log.
Then i've tried to run apk build removing google()
and adding lintOptions
in my android/app/build.gradle:
android {
(...)
lintOptions {
checkReleaseBuilds false
abortOnError false
}
}
in my android/app/build.gradle
, to avoid the lint-gradle error > IT DID NOT WORK.
Here is my whole android/app/build.gradle
:
project.ext.react = [
entryFile: "index.js"
]
apply from: "../../node_modules/react-native/react.gradle"
apply from: "../../node_modules/react-native-vector-icons/fonts.gradle"
/**
* Set this to true to create two separate APKs instead of one:
* - An APK that only works on ARM devices
* - An APK that only works on x86 devices
* The advantage is the size of the APK is reduced by about 4MB.
* Upload all the APKs to the Play Store and people will download
* the correct one based on the CPU architecture of their device.
*/
def enableSeparateBuildPerCPUArchitecture = false
/**
* Run Proguard to shrink the Java bytecode in release builds.
*/
def enableProguardInReleaseBuilds = false
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "com.testapp"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
ndk {
abiFilters "armeabi-v7a", "x86"
}
}
signingConfigs {
release {
if (project.hasProperty('MYAPP_RELEASE_STORE_FILE')) {
storeFile file(MYAPP_RELEASE_STORE_FILE)
storePassword MYAPP_RELEASE_STORE_PASSWORD
keyAlias MYAPP_RELEASE_KEY_ALIAS
keyPassword MYAPP_RELEASE_KEY_PASSWORD
}
}
}
splits {
abi {
reset()
enable enableSeparateBuildPerCPUArchitecture
universalApk false // If true, also generate a universal APK
include "armeabi-v7a", "x86"
}
}
android {
lintOptions {
abortOnError false
checkReleaseBuilds false
}
}
buildTypes {
release {
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
signingConfig signingConfigs.release
}
}
// 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]
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 {
compile project(':react-native-linear-gradient')
compile fileTree(dir: "libs", include: ["*.jar"])
compile "com.android.support:appcompat-v7:23.0.1"
compile "com.facebook.react:react-native:+" // From node_modules
compile project(':react-native-linear-gradient')
compile project(':react-native-device-info')
/*implementation project('react-native-maps')*/
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:11.0.4'
implementation 'com.google.android.gms:play-services-maps:11.0.4'
}
// 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'
}
I've spent hours trying to find out a solution on the net, but nothing worked for me. Either i've my run-android
working and app not crashing but could not build any apk, or I can build it but it crashes immediately when i run it (apk or run-android)...
If anyone could save my mental health please ^^...
Have you tried with google() before jcenter() ? It worked for me:
buildscript {
repositories {
google()
jcenter()
gradlePluginPortal()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.1'
// NOTE: Do not place your application dependencies here;
}
}
allprojects {
repositories {
google()
jcenter()
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With