Sometime when you try to build the app you may encounter this FAILURE.
..."Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0."
Most common Solution
Run the Gradle build with a command line argument --warning-mode=all to see what exactly the deprecated features are.
It will give you a detailed description of found issues with links to the Gradle docs for instructions how to fix your build.
Adding --stacktrace to that, you will also be able to pinpoint where the warning comes from, if it's triggered by outdated code in one of the plugins and not your build script.
Solution 2
if the abouve Solution dont work Try this one
cd android && ./gradlew clean && ./gradlew :app:bundleRelease
Solution 3
The process below worked in many case-
First check Gradle Version:
Then go to app/build.gradle and change classpath 'com.android.tools.build:gradle:<plugin_version>
Solution 4
if your project is incompatible with Gradle 8.0 .Here's what worked for you:
First write this line of code in the Android Studio terminal:
./gradlew build --warning-mode all
When you do that, you will be shown in the logcat what is found to be deprecated or an issue in your project, for me it was the jcenter() repository that needed to be removed in my settings.gradle file and also I needed to update classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.21" to classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.30" in my build.gradle project file.
Once I did these things, my project built perfectly and installed on my emulator
Sometime when you try to do a HTTPS POST request to your server. you get SSLHandshakeException - Chain chain validation failed, all the time. but when using POSTMAN you get a response from the server. What can be causing this error when I try to send the request from the application?
Most common Solution
In many case it was the wrong date on phone.
Fixing date resolved an issue
Solution 2
if the abouve Solution dont work Try this one
The problem may be that the certificate was expired.
Solution 3
If you're using an emulated device it may solve the problem if you just 'Cold Boot' it.
Sometimes the date on those things can get stuck if you let them run for some time, which results in this expired-certificate-problem.
Solution 4
In my case, I fetch this issue on Android Emulator.
When I clear emulator cache has resolved the issue.
If You Can Build A Website, You Can Build An Android App!
Android.js simple takes your node.js website and puts it into a WebView.
Yeah, i know that's a lot of disadvantages there but it also provides different APIs for you to interact with.
an android.js application isn't only a WebView like a front end of a site, it can also interact with the backend and interact with files and much more!
main.js is the main file or we can say it is back process of your app which execute all the code written in node, so you have to write all the node js code inside main.js
index.html is the first view which is render by app initially
package.json to keep track of all your node packages
assets to store all assets of your app
time to build
cd AndroidApp
androidjs b
it will generate apk file inside dist folder
if this build command fails or generated any error, try to build with force command
androidjs b -f
Why not to use it
Android.js isn't better than react-native
But, at least you can (somewhat) throw your existing code in it and generate an API to work on a device just like android application. React native stays the best way to make Android applications with react (JavaScript).
execution of the command ./gradlew leads to the following output:
usr$ ./gradlew tasks
Error: Could not find or load main class org.gradle.wrapper.GradleWrapperMain
What is gradle wrapper
gradlew is the gradle wrapper executable - batch script on windows and shell script elsewhere. The wrapper script when invoked, downloads the defined gradle version and executes it. By distributing the wrapper with your project, anyone can work with it without needing to install Gradle beforehand. Even better, users of the build are guaranteed to use the version of Gradle that the build was designed to work with.
Restoring gradle wrapper
It used to be that you needed to add a wrapper task to your build.gradle to restore gradle wrapper and all its dependencies. For instance:
Newer versions of gradle do not require this. It is now a built-in task. Just run:
gradle wrapper
You can also supply additional flags to specify versions etc
gradle wrapper --gradle-version 6.2 --distribution-type all
When you run this task, a gradle wrapper script, and the required jar files are added to your source folders. Properties are stored in gradle/wrapper/gradle-wrapper.properties
(You may need to install gradle locally to run this. brew install gradle on mac for instance. See more detailed instructions here)
Why was it missing in the first place?
OP seems to have deleted something that gradle wrapper depends on.
But a common reason is that a .gitignore entry prevents wrapper jars from being checked into git. Note that the .gitignore in effect may be in the source folder, or a global one in your user home folder or git global configuration. It is common to have a *.jar entry in .gitignore.
You can add an exception for gradlew's jar files in .gitignore
Instead of forcefully adding the jar, which you'll need to remember to do in each Gradle project, I added an override to re-include the wrapper jar in my global .gitignore:
*.jar
!gradle/wrapper/gradle-wrapper.jar
This is useful to me as I have many projects that use Gradle; Git will now remind me to include the wrapper jar.
We are now seeing this error when building one of our library modules:
$ ./gradlew library_module:assemble
Execution failed for task ':library_module:bundleDebugAar'.
> Direct local .aar file dependencies are not supported when building an AAR.
The resulting AAR would be broken because the classes and Android resources from any local .aar
file dependencies would not be packaged in the resulting AAR. Previous versions of the Android
Gradle Plugin produce broken AARs in this case too (despite not throwing this error). The
following direct local .aar file dependencies of the :library_module project caused this error:
______.aar
Most common Solution
I recently encountered the same issue, the fix was to remove the library from libs/ and import it using File -> New -> New Module -> Import .JAR/.AAR Package, then referencing it in the library module build.gradle file:
When building an Android library that depends on other Android libraries (i.e., aar files), you will get the following error message if you include the aar files as dependencies in the project:
Direct local .aar file dependencies are not supported when building an AAR. The resulting AAR would be broken because the classes and Android resources from any local .aar file dependencies would not be packaged in the resulting AAR. Previous versions of the Android Gradle Plugin produce broken AARs in this case too (despite not throwing this error).
As the above message states, when you build an Android library project, any aar it depends on is not packaged. If you built this way prior to AGP (Android Gradle Plugin) 4, you probably noticed that you had to include the aar dependencies on the project consuming your library.
You can compile your Android library project by specifying that the aar dependencies are compileOnly. See this for more info on when to use compileOnly.
So just add the following to your appbuild.gradle file:
compileOnly files('libs/some-library.aar')
Note that if you do this you will have to include the aar dependencies on the application project that consumes your library.
Alternatively, you can create a module that imports your aar dependency as @Sandi mentioned in the answer above.
Another way is to publish your aar dependencies to a maven repository and then add them to your library project like this:
I want to call out @StefMa's comment on this question which was incredible simple and solved this issue for me, but it's buried among many other comments on this thread and is easily missed.
The 'correct' answer on this thread no longer works because it's not possible to import AARs in Android Studio anymore as referred to in that answer. But, the solution referred to in StefMa's comment linking to this GitHub post does, and it works perfectly.
Long story short - put your AAR into a separate module.
There's no need to muck around with creating lib directories, just follow these directions -
Create a new directory in your project's root directory. The image below shows two of them - spotify-app-remote and spotify-auth, but one is sufficient. Within that, put your AAR in, and create a new build.gradle file.
Within the build.gradle file, add the following, replacing the aar filename with the name of your AAR file -
implementing a UI where a bottom sheet will appear above the keyboard with an EditText for the user to enter a value. The problem is the View is being partially overlapped by the keyboard, covering up the bottom of the bottom sheet.
As already mentioned in the Comments a few times, you might also need to set the state of the BottomSheetDialog to STATE_EXPANDED like in Nordknight's answer below
This might be a redundant answer. Although just pointing out the issue.
If you're using BottomSheetDialogFragment, the only way is to enable the attribute android:windowIsFloating to true. This will enable the whole window to be on top of whatever is trying to take the space behind it.
Then in your onCreate() of your dialog, set this style.
overridefunonCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
// set the window no floating style
setStyle(DialogFragment.STYLE_NORMAL, R.style.AppRoundedBottomSheetDialogThemeNoFloating)
}
This is handy for those who frequently use bottom sheets and may want to deal with EditText and soft keyboard overlapping each other.
Note: The class KeyboardUtil by mikepenz has an issue in which on certain phones, the content view with input field is automatically pushed above keyboard despite giving bottom padding to the whole content view supplied.
This code works fine at Fragment's onCreateView method (thanks for ADM)
Solution 4
Some answers seem to do the trick better than others but will need modification when using the new material design components instead of the older support libraries while also using kotlin
In the article I'll show how to automate taking screenshots of the Android application written in Jetpack Compose.
1. Create test
Start with setting up instrumented test. This test will not check anything, it will only perform actions such clicking button and take screenshots of the application.
First, set up testing in app/build.gradle:
android{// other propertiesdefaultConfig{// other propertiestestInstrumentationRunner"androidx.test.runner.AndroidJUnitRunner"// Add this line}}// ...dependencies{// other dependenciesandroidTestImplementation"androidx.compose.ui:ui-test-junit4:$compose_version"// Add this line}
Now, let's suppose this is the Activity we want to take screenshots of:
packagecom.exampleimportandroidx.compose.ui.test.junit4.createAndroidComposeRuleimportandroidx.compose.ui.test.onNodeWithTextimportandroidx.compose.ui.test.performClickimportandroidx.test.ext.junit.runners.AndroidJUnit4importorg.junit.Ruleimportorg.junit.Testimportorg.junit.runner.RunWith@RunWith(AndroidJUnit4::class)classScreenshotTest{@get:Rulevalrule=createAndroidComposeRule<MainActivity>()@TestfunmakeScreenshot(){// TODO: Take screenshot before clicking buttonrule.onNodeWithText("Show greeting").performClick()// TODO: Take screenshot after clicking button}}
2. Take the screenshot
In order to take screenshot and save it as an image, use the following functions:
All screenshots taken by the code are stored in the emulator or phone.
To fetch them manually you can use Device File Explorer, which is build in Android Studio. Screenshots can be found in the following directory: /data/data/$applicationId/files/
In some cases turning off animations is needed to run tests. To do it, use these commands:
adb shell settings put global window_animation_scale 0
adb shell settings put global animator_duration_scale 0
adb shell settings put global transition_animation_scale 0
Some users have reported that their devices need to be reboot to apply these settings. If that's your case, you can use the following command:
adb shell "su 0 am start -a android.intent.action.REBOOT"
Turn off keyboard
Soft keyboard can affect screenshots by cropping them. To disable it use the following commands:
# Show all keyboards (-a for all, -s for short summary).
adb shell ime list -s-a# Disable keyboards:
adb shell ime disable <<keyboard id>>
# Example: adb shell ime disable com.android.inputmethod.latin