How to Create an APK in Android Studio? [duplicate] - apk

This question already has answers here:
':app:lintVitalRelease' error when generating signed apk
(28 answers)
Closed 2 years ago.
I want to make an APK in Android Studio but when I create it, it shows this error:
Lint found fatal errors while assembling a release target.
To proceed, either fix the issues identified by lint, or modify your build script as follows:
...
android {
lintOptions {
checkReleaseBuilds false
// Or, if you prefer, you can continue to check for errors in release builds,
// but continue the build even when errors are found:
abortOnError false
}
}
...

I have faced same issue when creating signed apk from android studio. I just change little bit change on build.gradle file inside android {}
lintOptions {
checkReleaseBuilds false
abortOnError false
}

Related

LeakCanary not installed in launcher

I did the change as suggested in app:build.gradle ->
debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.9.1'
But when i pushed my apk, then i cannot see the Leak Canary in my launcher
Nay idea why?
#Harsh,
Did you implement an app with multiple buidtypes?
If yes you need to change the LeakCanary dependency follow your build types:
Example:
your build type is
buildTypes {
dev{}
....
release{}
}
if you want to install with the dev variant, your dependency should be like this: devImplementation 'com.squareup.leakcanary:leakcanary-android:xxx_xxx'
If not: remove this line in build gradle
variantFilter { variant ->
if (variant.buildType.name == "debug") {
setIgnore(true)
}
}

Error when trying to run 'gradlew assembleRelease' in the Windows command line : jest-haste-map: Haste module naming collision

I am trying to generate a .apk file of my react native project with the 'gradlew assembleRelease' command. I'm using AWS Amplify, which is where the naming collision seems to be coming from. The version of react native I'm running is 0.59.9.
I've tried creating a 'rn-cli.config.js' file in the root folder and replacing the code in the 'metro.config.js' with the 'rn-cli.config.js' code, which was unsuccessful. I can't remove the problem folder either because that creates more errors.
I've also tried stopping and restarting the Gradle daemon, which hasn't worked either. This is the error I'm getting:
Configure project :app
WARNING: The specified Android SDK Build Tools version (25.0.0) is ignored, as it is below the minimum supported version (28.0.3) for Android Gradle Plugin 3.4.0.
Android SDK Build Tools 28.0.3 will be used.
To suppress this warning, remove "buildToolsVersion '25.0.0'" from your build.gradle file, as each version of the Android Gradle Plugin now has a
default version of the build tools.
Task :app:bundleReleaseJsAndAssets
warning: the transform cache was reset.
error jest-haste-map: Haste module naming collision:
Duplicate module name: myreactnativeapp_cfnlambda_ff57ce62
Paths: C:\Users\Kim\Desktop\myReactNativeApp\amplify\backend\interactions\reactLex\src\package.json collides with C:\Users\Kim\Desktop\myReactNativeApp\amplify#current-cloud-backend\interactions\reactLex\src\package.json
This error is caused by hasteImpl returning the same name for different files.. Run CLI with --verbose flag for more details.
Task :app:bundleReleaseJsAndAssets FAILED
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':app:bundleReleaseJsAndAssets'.
Process 'command 'cmd'' finished with non-zero exit value 1
The code in the 'rn-cli.config.js' file looks like this:
const blacklist = require('metro-config/src/defaults/blacklist');
// blacklist is a function that takes an array of regexes and combines
// them with the default blacklist to return a single regex.
module.exports = {
resolver: {
blacklistRE: blacklist([/amplify\/.*/])
}
};'
Do I need to change the code in the 'rn-cli.config.js' file or is there another workaround I could try?

Xcode not generating app with latest changes

My latest changes in Ionic app are not reflected on simulator or in ipa file which i am generating with xcode 10.
I tried many solution like removed build folder, remove ios folder from platform and add it again but none of works.
Any one has idea what might be problem is ?
Only use these commands
cordova clean
and
npm run clean
For Xcode 10 you likely will need to force the use of the legacy build system. This is described in this blog post.
Summary: Create a build.json file in the root of your project with the following contents:
{
"ios": {
"debug": {
"buildFlag": [
"-UseModernBuildSystem=0"
]
},
"release": {
"buildFlag": [
"-UseModernBuildSystem=0"
]
}
}
}

NDK Error "Unexpected native build target xyz. Valid targets are:"

I have an Android Studio project which depends on a native shared library. I have created a cmake file to compile the library and I have added a soft link to the shared library inside the android project (in src/main/jniLibs/armeabi). That way when the android project is built, the shared library is included in the package.
Here is the relevant part of build.gradle:
android {
...
externalNativeBuild {
cmake {
path "../cpp/CMakeLists.txt"
}
}
}
The problem is that gradle tries to open the shared library before invoking the instructions to build it.
Information:Gradle tasks [:app:assembleDebug]
Error:Could not list contents of 'app/src/main/jniLibs/armeabi/libfoo.so'. Couldn't follow symbolic link.
How can I invoke the cmake from inside the project and include the library in the project at the same time?
--
EDIT
In the cmake the shared library is built with ExternalProject_Add. Unfortunately gradle doesn't see that target, nor does it see imported shared libraries as targets. So this does not work:
add_library(libfoo SHARED IMPORTED GLOBAL)
add_dependencies(libfoo libactual)
I tried to invoke building the particular target with a gradle config:
defaultConfig {
...
externalNativeBuild {
cmake {
targets "libfoo"
}
}
}
But gradle still doesn't see it and fails with:
Unexpected native build target libfoo. Valid values are:
The valid values are basically an empty list.
Currently I work around this by creating a fictional executable depending on the library.
add_executable(libfoo a.c)
add_dependencies(libfoo libactual)
In my case, I added a new CMake target, but having none was cached somehow (by CMake or Gradle).
Simply close Android Studio, remove the entire build or .build directory, then open Android Studio and build again.
Note that sub-projects have their own separate build directory.
So, you may need to search for the word build, and after ensuring found result is not required, remove them too.
If still not fixed, remember that CMake has it's own separate cache files, which normallay are inside said directories unless you run CMake directly (outside of Android Studio).

Android Studio 2.2's incremental compiler can't see generated protobufs

I upgraded my stable version of Android Studio to 2.2 and now the IDE's "incremental compiler" can't find any of the symbols for generated protobuf classes. I open the project and it can build and deploy the app to a device just fine. But when I open a Java class file that contains generated protobuf references, Android Studio marks them as errors soon after the file opens. Every Java import of a generated proto class is marked with "Cannot resolve symbol".
I first noticed this a month ago on the canary channel but didn't think anything of it because I was floundering with other protobuf issues (upgrading to 3.0.0 with its javalite split). I forgot about it until today. It's still possible to work on the project, it's just that the IDE is near useless since it thinks there are errors (even though real compiles are fine with it).
For reference.
gradle-2.14.1
com.android.tools.build:gradle:2.2.0
com.google.protobuf:protobuf-gradle-plugin:0.8.0
com.google.protobuf:protobuf-lite:3.0.0
com.google.protobuf:protoc:3.0.0
com.google.protobuf:protoc-gen-javalite:3.0.0
And in the modules that contain .proto files:
protobuf {
protoc {
artifact = google_protoc_artifact
}
plugins {
javalite {
artifact = google_protoc_javalite_artifact
}
}
generateProtoTasks {
all().each { task ->
task.builtins {
remove java
}
task.plugins {
javalite { }
}
}
}
}
We had the same issue and found out the following:
1) In order for idea (studio) to see your source, you need to help it by adding the idea plugin to your module:
apply plugin: 'idea'
idea {
module {
// Use "${protobuf.generatedFilesBaseDir}/main/javalite" for LITE_RUNTIME protos
sourceDirs += file("${protobuf.generatedFilesBaseDir}/main/java");
}
}
2) Another bug, Android Studio seems to ignore any source directory under build/. You have to move your generated directory outside of build:
protobuf {
generatedFilesBaseDir = "$projectDir/src/generated"
}
These two changes fixed the problem introduced by Android Studio 2.2 for us.
In my case, I was using the kotlin protobuf plugin and to fix the error of the IDE not being able to resolve it. I tweaked the other answer above to point to the main folder.
// build.gradle.kts
plugins {
idea
}
idea {
module {
// explicitly tell intellij where to resolve generated proto files
sourceDirs.plusAssign(file("build/generated/source/proto/main/"))
}
}

Resources