How to accept licences to install SDK packages - android

I'm trying to convert an existing Angular application to Android by using cordova and Android Studio. I'm stuck at the last step of a guide to covert, where I need to accept platforms;android-28 Android SDK Platform 28 in order to proceed.
I know there's already answers where you should simply use:
yes | sdkmanager --licenses
in order to accept all licenses, but I couldn't find any thread where to put that command.
I've never used Android Studio before. I've managed to find SDK Manager.

This command should be run on a Bash CLI

try this cmd to install sdk, cmake and so on:
echo y | ./tools/bin/sdkmanager "platform-tools" "platforms;android-28" "build-tools;28.0.3" "ndk-bundle" "cmake;3.6.4111459" --include_obsolete "extras;google;m2repository" \

Related

Android Studio Arctic Fox 2020.3.1 Patch 1 'My Application' error - solved [duplicate]

I am getting this error in jitpack, I've tried everything on the internet. Below is my error
Failed to install the following Android SDK packages as some licences have not been accepted.
platforms;android-26 Android SDK Platform 26
build-tools;28.0.3 Android SDK Build-Tools 28.0.3
To build this project, accept the SDK license agreements and install the missing components using the Android Studio SDK Manager.
And when i run ./sdkmanager --licenses
All SDK package licenses accepted.======] 100% Computing updates...
Using sudo with the above command gives
Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema
at com.android.repository.api.SchemaModule$SchemaModuleVersion.<init>(SchemaModule.java:156)
at com.android.repository.api.SchemaModule.<init>(SchemaModule.java:75)
at com.android.sdklib.repository.AndroidSdkHandler.<clinit>(AndroidSdkHandler.java:81)
at com.android.sdklib.tool.sdkmanager.SdkManagerCli.main(SdkManagerCli.java:73)
at com.android.sdklib.tool.sdkmanager.SdkManagerCli.main(SdkManagerCli.java:48)
Caused by: java.lang.ClassNotFoundException: javax.xml.bind.annotation.XmlSchema
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:582)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:190)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:499)
... 5 more
additional error log
File /opt/android-sdk-linux/.android/repositories.cfg could not be loaded.
Checking the license for package Android SDK Build-Tools 28.0.3 in /opt/android-sdk-linux/licenses
Warning: License for package Android SDK Build-Tools 28.0.3 not accepted.
Checking the license for package Android SDK Platform 26 in /opt/android-sdk-linux/licenses
Warning: License for package Android SDK Platform 26 not accepted.
I don't know why it's checking for licenses there when my sdk location is other
You need to accept the licences before building.
According to Android SDK docs you can use the following command depending on the sdkmanager location: Docs on --licenses option seems to be missing though.
yes | sdkmanager --licenses
GNU/Linux Distributions:
yes | ~/Android/Sdk/tools/bin/sdkmanager --licenses
macOS:
export JAVA_HOME=/Applications/Android\ Studio.app/Contents/jre/jdk/Contents/Home
yes | ~/Library/Android/sdk/tools/bin/sdkmanager --licenses
Windows:
%ANDROID_HOME%/tools/bin/sdkmanager --licenses
Flutter:
> flutter config --android-sdk 'path-of-android-sdk'(only for ubuntu user)
> flutter doctor --android-licenses
In Android Studio go to Tools -> SDK Manager.
Go to SDK Tools tab.
Select the Android SDK Command-line Tools (latest) and download by pressing Apply.
On Windows, you can find the sdkmanager.bat at
C:\Users\[your_user]\AppData\Local\Android\Sdk\cmdline-tools\latest\bin
in Windows OS go to your sdkmanager path then execute
./sdkmanager.bat --licenses
You can find your sdkmanager in C:\Users\USER\AppData\Local\Android\Sdk\tools\bin
OR
For those people not using android studio on window os. Go to your cmdline-tools\tool\bin and type cmd on the directory box to open the directory in your terminal. Then run sdkmanager --licenses
To find your actual android SDK path follow the red marked area of the below picture
If you are working with Flutter then this command would definitely work for you.
flutter doctor --android-licenses
Problem: SDK license not accepted
Step 1: Open SDK Manager
After opening the SDK manager, open the SDK tools tab as shown below
Step 2: Check the option Show Package Details
It'll list out all the versions of SDK tools
Step 3: Install the required SDK tool version
Check the specific version of SDK tools that is complaining (for me, it was 29.0.3 as shown above in the first screenshot) from the list, accept the agreement in the dialog that opens next and you're done.
MacOS Catalina
Step 1: Changing Android Studio Preference
Open-up your Android Studio
Press Command+, or go to top-left AppBar Android Studio > Preferences.
From Left Pane, select Appearance > System Settings > Android SDK
Select SDK Tools next to SDK Platforms and under Android SDK Location
Check mark Android SDK Command-line Tools (latest) and Press OK button.
Wait for installation to be finished
Step 2 (For Flutter Users):
Go to Terminal and run the following command
flutter doctor --android-licenses
Step 2 (For Android Users):
Go to the Terminal and run the following command
export JAVA_HOME=/Applications/Android\ Studio.app/Contents/jre/jdk/Contents/Home
yes | ~/Library/Android/sdk/tools/bin/sdkmanager --licenses
You can accept the license agreements of the stated SDKs by going to the SDK Manager (Settings > [Search for Android SDK]) then find the packages noted in the error message and find them there. Chances are, you'll find SDKs that are not fully installed and installing them will ask you to accept the license agreement.
use android-28 with build-tools at version 28.0.3; or build-tools at version 26.0.3.
or try this: yes | sudo sdkmanager --licenses
This works for me:
yes | ./sdkmanager "platforms;android-28"
yes | ./sdkmanager "build-tools;28.0.3"
yes | ./sdkmanager --licenses
For Android Studio Arctic Fox, it was solved for me by installing the Google Play Licensing Library.
Go to Preferences
Expand Appearance & Behavior
Then expand System Settings
Select Android SDK and go to SDK Tools tab
Install Google Play Licensing Library
If you are getting this error while using Flutter then please run the below command on command prompt.
flutter doctor --android-licenses
If you get below error after running the above command
Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema
at com.android.repository.api.SchemaModule$SchemaModuleVersion.<init>(SchemaModule.java:156)
at com.android.repository.api.SchemaModule.<init>(SchemaModule.java:75)
at com.android.sdklib.repository.AndroidSdkHandler.<clinit>(AndroidSdkHandler.java:81)
at com.android.sdklib.tool.sdkmanager.SdkManagerCli.main(SdkManagerCli.java:73)
at com.android.sdklib.tool.sdkmanager.SdkManagerCli.main(SdkManagerCli.java:48)
Then please do the below steps
Open android studio
Go to SDK manager
Click on SDK tools tab
Install Android SDK command line tool
Run flutter doctor --android-licenses again
In Android Studio go to: Tools > SDK Manager > SDK Tools
On the bottom right, check the "Show Package Details" box and download the version of sdk that you need:
Tried this on Android Studio and it worked for me:
Tools > SDK Manager (Make sure to check Show Packages below)
SDK Platforms > Show Packages > Android - 28
SDK Tools > Show Packages > 28.0.3
Appears to be a bug at the momment:
https://issuetracker.google.com/issues/123054726
Solution that worked for me:
Create a .travis.yml file in your project directory and copy these lines:
before_script:
- mkdir "$ANDROID_HOME/licenses" || true
- echo "24333f8a63b6825ea9c5514f83c2829b004d1fee" > "$ANDROID_HOME/licenses/android-sdk-license"
Reference:
https://github.com/square/RxIdler/pull/18/files
in Windows OS go to your sdkmanager path directory in cmd
You can find your sdkmanager in C:\Users\USER\AppData\Local\Android\Sdk\tools\bin
then execute the followwing command:
sdkmanager --licenses
after that it will ask to accept license agreement several times then accept all by just typing y on cmd
This works for me in Windows 10:
C:
cd \Users\YOUR_USER\AppData\Local\Android\Sdk\cmdline-tools\latest\bin
sdkmanager.bat --licenses
After, yes to all
On Mac OS 10.15.1, I got the same error even after accepted all the licenses by running sdkmanager --licenses It worked after I updated the ANDROID_HOME path configuration in the ~/.bash_profile to the following
export ANDROID_HOME=/Users/your_username/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
export PATH=$PATH:~/Library/Android/sdk/platform-tools
And reload the ~/.bash_profile
source ~/.bash_profile
I tried many solutions but didn't work for me.
The below solution works for me.
locate the sdkmanager file in android SDK.
In my case :
~/Android/Sdk/tools/bin
go to that path : cd ~/Android/Sdk/tools/bin
Accept licenses manually : ./sdkmanager --licenses
Enter Yes or y
If you are using flutter go with the following steps
1.open the command prompt
Then the following command
2.C:\Users\niroshan>flutter doctor
And you will see the issues as follows
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 1.22.2, on Microsoft Windows [Version 10.0.17763.1339], locale en-US)
[!] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
X Android licenses not accepted. To resolve this, run: flutter doctor --android-licenses
[!] Android Studio (version 4.1.0)
X Flutter plugin not installed; this adds Flutter specific functionality.
X Dart plugin not installed; this adds Dart specific functionality.
[√] VS Code (version 1.50.1)
[!] Connected device
! No devices available
! Doctor found issues in 3 categories.
Actually what you have to run is the below command
C:\Users\niroshan>flutter doctor --android-licenses
https://www.youtube.com/watch?v=g789PvvW4qo really helped me. What had done is open SDK Manager and download any new SDK Platform (dont worry it wont affect your desired api level).
Because with downlaoding any SDK Platforms(API level), you should accept licences. That's the trick worked for me.
I had the same problem when trying to run an app on my android device in a different project where I was working with some old version of tomcat8 and had to set the JAVA_OPTS variable and value. So I removed this system variable for JAVA_OPTS, which had a Variable value set to -Xms1024m (Remove the JAVA_OPTS system variable, but you can also store it for future use if you need to revert to using your old projects that might need it).
Then run the SDK manager bat file in your sdk path:
PS C:\Users[your_pc_username]\AppData\Local\Android\Sdk\tools\bin> .\sdkmanager.bat --licenses
Accept all licenses (Y).
How I solve this problem (AndroidStudio 4.2)
Click in Build tab
Select Failed to install the following Android SDK packages ... (warning)
Click Install missing SDK package(s)
On Ubuntu it still didn't work using the answers suggested.
This is what worked for me:
cd full-path-to-bin folder, where sdkmanager is located.
yes | ./sdkmanager --licenses --sdk_root="full-path-to-bin"
In the option --help it shows we can pass common args to it, which finally accepted ALL licences:
Usage:
...
sdkmanager --licenses [<common args>]
...
Common Arguments:
--sdk_root=<sdkRootPath>: Use the specified SDK root instead of the SDK containing this tool
To add to the answers, you can also change to the sdkmanager directory and in a sub shell and accept the licenses there
(
cd /home/user/android-sdk-linux/tools/bin
yes | ./sdkmanager --licenses
)
I just done File -> Invalidate caches and restart
Then install missing packages.
Worked for me.
On Windows:
Add USER Environment variables:
NOTE: Path should be appended
JAVA_HOME %ProgramFiles%\Android\Android Studio\jre
ANDROID_SDK_ROOT %LocalAppData%\Android\Sdk
Path %LocalAppData%\Android\Sdk
Run the below command to accept licenses:
NOTE: Accept all licenses (say y)
%ANDROID_SDK_ROOT%/tools/bin/sdkmanager.bat --licenses
Now run your app:
(like below, or another command that failed for you):
cd \myapp\
react-native run-android
in my case I just installed a new version of android studio on a new laptop and cloned the old repository where
buildToolsVersion "30.0.2" at application level build.gradle.
I just upgraded to 30.0.3 which android studio recommended on its own and the problem went away
I moved my Sdks and Avds folder as it was using lots of memory in local disk c, but after that I got the above issue.
For me Invalidate Caches/Restart solve the issue
File->Invalidate Caches/Restart
In my case updating buildToolsVersion in app level build.gradle worked perfectly. If you don't know which to use you can create new project and copy buildToolsVersion from that into existing one.
A one liner solution with downgrade to java 8:
sudo apt-get install openjdk-8-jdk -y && export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64 && flutter doctor --android-licenses

"Failed to install the following Android SDK packages as some licences have not been accepted" error

I am getting this error in jitpack, I've tried everything on the internet. Below is my error
Failed to install the following Android SDK packages as some licences have not been accepted.
platforms;android-26 Android SDK Platform 26
build-tools;28.0.3 Android SDK Build-Tools 28.0.3
To build this project, accept the SDK license agreements and install the missing components using the Android Studio SDK Manager.
And when i run ./sdkmanager --licenses
All SDK package licenses accepted.======] 100% Computing updates...
Using sudo with the above command gives
Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema
at com.android.repository.api.SchemaModule$SchemaModuleVersion.<init>(SchemaModule.java:156)
at com.android.repository.api.SchemaModule.<init>(SchemaModule.java:75)
at com.android.sdklib.repository.AndroidSdkHandler.<clinit>(AndroidSdkHandler.java:81)
at com.android.sdklib.tool.sdkmanager.SdkManagerCli.main(SdkManagerCli.java:73)
at com.android.sdklib.tool.sdkmanager.SdkManagerCli.main(SdkManagerCli.java:48)
Caused by: java.lang.ClassNotFoundException: javax.xml.bind.annotation.XmlSchema
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:582)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:190)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:499)
... 5 more
additional error log
File /opt/android-sdk-linux/.android/repositories.cfg could not be loaded.
Checking the license for package Android SDK Build-Tools 28.0.3 in /opt/android-sdk-linux/licenses
Warning: License for package Android SDK Build-Tools 28.0.3 not accepted.
Checking the license for package Android SDK Platform 26 in /opt/android-sdk-linux/licenses
Warning: License for package Android SDK Platform 26 not accepted.
I don't know why it's checking for licenses there when my sdk location is other
You need to accept the licences before building.
According to Android SDK docs you can use the following command depending on the sdkmanager location: Docs on --licenses option seems to be missing though.
yes | sdkmanager --licenses
GNU/Linux Distributions:
yes | ~/Android/Sdk/tools/bin/sdkmanager --licenses
macOS:
export JAVA_HOME=/Applications/Android\ Studio.app/Contents/jre/jdk/Contents/Home
yes | ~/Library/Android/sdk/tools/bin/sdkmanager --licenses
Windows:
%ANDROID_HOME%/tools/bin/sdkmanager --licenses
Flutter:
> flutter config --android-sdk 'path-of-android-sdk'(only for ubuntu user)
> flutter doctor --android-licenses
In Android Studio go to Tools -> SDK Manager.
Go to SDK Tools tab.
Select the Android SDK Command-line Tools (latest) and download by pressing Apply.
On Windows, you can find the sdkmanager.bat at
C:\Users\[your_user]\AppData\Local\Android\Sdk\cmdline-tools\latest\bin
in Windows OS go to your sdkmanager path then execute
./sdkmanager.bat --licenses
You can find your sdkmanager in C:\Users\USER\AppData\Local\Android\Sdk\tools\bin
OR
For those people not using android studio on window os. Go to your cmdline-tools\tool\bin and type cmd on the directory box to open the directory in your terminal. Then run sdkmanager --licenses
To find your actual android SDK path follow the red marked area of the below picture
If you are working with Flutter then this command would definitely work for you.
flutter doctor --android-licenses
Problem: SDK license not accepted
Step 1: Open SDK Manager
After opening the SDK manager, open the SDK tools tab as shown below
Step 2: Check the option Show Package Details
It'll list out all the versions of SDK tools
Step 3: Install the required SDK tool version
Check the specific version of SDK tools that is complaining (for me, it was 29.0.3 as shown above in the first screenshot) from the list, accept the agreement in the dialog that opens next and you're done.
MacOS Catalina
Step 1: Changing Android Studio Preference
Open-up your Android Studio
Press Command+, or go to top-left AppBar Android Studio > Preferences.
From Left Pane, select Appearance > System Settings > Android SDK
Select SDK Tools next to SDK Platforms and under Android SDK Location
Check mark Android SDK Command-line Tools (latest) and Press OK button.
Wait for installation to be finished
Step 2 (For Flutter Users):
Go to Terminal and run the following command
flutter doctor --android-licenses
Step 2 (For Android Users):
Go to the Terminal and run the following command
export JAVA_HOME=/Applications/Android\ Studio.app/Contents/jre/jdk/Contents/Home
yes | ~/Library/Android/sdk/tools/bin/sdkmanager --licenses
You can accept the license agreements of the stated SDKs by going to the SDK Manager (Settings > [Search for Android SDK]) then find the packages noted in the error message and find them there. Chances are, you'll find SDKs that are not fully installed and installing them will ask you to accept the license agreement.
use android-28 with build-tools at version 28.0.3; or build-tools at version 26.0.3.
or try this: yes | sudo sdkmanager --licenses
This works for me:
yes | ./sdkmanager "platforms;android-28"
yes | ./sdkmanager "build-tools;28.0.3"
yes | ./sdkmanager --licenses
For Android Studio Arctic Fox, it was solved for me by installing the Google Play Licensing Library.
Go to Preferences
Expand Appearance & Behavior
Then expand System Settings
Select Android SDK and go to SDK Tools tab
Install Google Play Licensing Library
If you are getting this error while using Flutter then please run the below command on command prompt.
flutter doctor --android-licenses
If you get below error after running the above command
Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema
at com.android.repository.api.SchemaModule$SchemaModuleVersion.<init>(SchemaModule.java:156)
at com.android.repository.api.SchemaModule.<init>(SchemaModule.java:75)
at com.android.sdklib.repository.AndroidSdkHandler.<clinit>(AndroidSdkHandler.java:81)
at com.android.sdklib.tool.sdkmanager.SdkManagerCli.main(SdkManagerCli.java:73)
at com.android.sdklib.tool.sdkmanager.SdkManagerCli.main(SdkManagerCli.java:48)
Then please do the below steps
Open android studio
Go to SDK manager
Click on SDK tools tab
Install Android SDK command line tool
Run flutter doctor --android-licenses again
In Android Studio go to: Tools > SDK Manager > SDK Tools
On the bottom right, check the "Show Package Details" box and download the version of sdk that you need:
Tried this on Android Studio and it worked for me:
Tools > SDK Manager (Make sure to check Show Packages below)
SDK Platforms > Show Packages > Android - 28
SDK Tools > Show Packages > 28.0.3
Appears to be a bug at the momment:
https://issuetracker.google.com/issues/123054726
Solution that worked for me:
Create a .travis.yml file in your project directory and copy these lines:
before_script:
- mkdir "$ANDROID_HOME/licenses" || true
- echo "24333f8a63b6825ea9c5514f83c2829b004d1fee" > "$ANDROID_HOME/licenses/android-sdk-license"
Reference:
https://github.com/square/RxIdler/pull/18/files
in Windows OS go to your sdkmanager path directory in cmd
You can find your sdkmanager in C:\Users\USER\AppData\Local\Android\Sdk\tools\bin
then execute the followwing command:
sdkmanager --licenses
after that it will ask to accept license agreement several times then accept all by just typing y on cmd
This works for me in Windows 10:
C:
cd \Users\YOUR_USER\AppData\Local\Android\Sdk\cmdline-tools\latest\bin
sdkmanager.bat --licenses
After, yes to all
On Mac OS 10.15.1, I got the same error even after accepted all the licenses by running sdkmanager --licenses It worked after I updated the ANDROID_HOME path configuration in the ~/.bash_profile to the following
export ANDROID_HOME=/Users/your_username/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
export PATH=$PATH:~/Library/Android/sdk/platform-tools
And reload the ~/.bash_profile
source ~/.bash_profile
I tried many solutions but didn't work for me.
The below solution works for me.
locate the sdkmanager file in android SDK.
In my case :
~/Android/Sdk/tools/bin
go to that path : cd ~/Android/Sdk/tools/bin
Accept licenses manually : ./sdkmanager --licenses
Enter Yes or y
If you are using flutter go with the following steps
1.open the command prompt
Then the following command
2.C:\Users\niroshan>flutter doctor
And you will see the issues as follows
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 1.22.2, on Microsoft Windows [Version 10.0.17763.1339], locale en-US)
[!] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
X Android licenses not accepted. To resolve this, run: flutter doctor --android-licenses
[!] Android Studio (version 4.1.0)
X Flutter plugin not installed; this adds Flutter specific functionality.
X Dart plugin not installed; this adds Dart specific functionality.
[√] VS Code (version 1.50.1)
[!] Connected device
! No devices available
! Doctor found issues in 3 categories.
Actually what you have to run is the below command
C:\Users\niroshan>flutter doctor --android-licenses
https://www.youtube.com/watch?v=g789PvvW4qo really helped me. What had done is open SDK Manager and download any new SDK Platform (dont worry it wont affect your desired api level).
Because with downlaoding any SDK Platforms(API level), you should accept licences. That's the trick worked for me.
I had the same problem when trying to run an app on my android device in a different project where I was working with some old version of tomcat8 and had to set the JAVA_OPTS variable and value. So I removed this system variable for JAVA_OPTS, which had a Variable value set to -Xms1024m (Remove the JAVA_OPTS system variable, but you can also store it for future use if you need to revert to using your old projects that might need it).
Then run the SDK manager bat file in your sdk path:
PS C:\Users[your_pc_username]\AppData\Local\Android\Sdk\tools\bin> .\sdkmanager.bat --licenses
Accept all licenses (Y).
How I solve this problem (AndroidStudio 4.2)
Click in Build tab
Select Failed to install the following Android SDK packages ... (warning)
Click Install missing SDK package(s)
On Ubuntu it still didn't work using the answers suggested.
This is what worked for me:
cd full-path-to-bin folder, where sdkmanager is located.
yes | ./sdkmanager --licenses --sdk_root="full-path-to-bin"
In the option --help it shows we can pass common args to it, which finally accepted ALL licences:
Usage:
...
sdkmanager --licenses [<common args>]
...
Common Arguments:
--sdk_root=<sdkRootPath>: Use the specified SDK root instead of the SDK containing this tool
To add to the answers, you can also change to the sdkmanager directory and in a sub shell and accept the licenses there
(
cd /home/user/android-sdk-linux/tools/bin
yes | ./sdkmanager --licenses
)
I just done File -> Invalidate caches and restart
Then install missing packages.
Worked for me.
On Windows:
Add USER Environment variables:
NOTE: Path should be appended
JAVA_HOME %ProgramFiles%\Android\Android Studio\jre
ANDROID_SDK_ROOT %LocalAppData%\Android\Sdk
Path %LocalAppData%\Android\Sdk
Run the below command to accept licenses:
NOTE: Accept all licenses (say y)
%ANDROID_SDK_ROOT%/tools/bin/sdkmanager.bat --licenses
Now run your app:
(like below, or another command that failed for you):
cd \myapp\
react-native run-android
in my case I just installed a new version of android studio on a new laptop and cloned the old repository where
buildToolsVersion "30.0.2" at application level build.gradle.
I just upgraded to 30.0.3 which android studio recommended on its own and the problem went away
I moved my Sdks and Avds folder as it was using lots of memory in local disk c, but after that I got the above issue.
For me Invalidate Caches/Restart solve the issue
File->Invalidate Caches/Restart
In my case updating buildToolsVersion in app level build.gradle worked perfectly. If you don't know which to use you can create new project and copy buildToolsVersion from that into existing one.
A one liner solution with downgrade to java 8:
sudo apt-get install openjdk-8-jdk -y && export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64 && flutter doctor --android-licenses

Jitpack: Failed to install the following Android SDK packages as some licences have not been accepted

I've googled, and some says it's fixed after few trys, and by creating a new release, but It doesn't seem to work for me.
How can I resolve this?
* What went wrong:
A problem occurred configuring project ':analytics'.
> Failed to notify project evaluation listener.
> Failed to install the following Android SDK packages as some licences have not been accepted.
platforms;android-27 Android SDK Platform 27
build-tools;27.0.3 Android SDK Build-Tools 27.0.3
To build this project, accept the SDK license agreements and install the missing components using the Android Studio SDK Manager.
Alternatively, to transfer the license agreements from one workstation to another, see http://d.android.com/r/studio-ui/export-licenses.html
Using Android SDK: /opt/android-sdk-linux
> Cannot add task ':analytics:install' as a task with that name already exists.
> Could not get unknown property 'androidJavadocs' for project ':analytics' of type org.gradle.api.Project.
https://jitpack.io/com/github/littlehome-eugene/analytics-android/1.0/build.log
You have probably ran into: https://issuetracker.google.com/issues/123054726
As a workaround I installed it individually. i.e.
$ yes | $ANDROID_HOME/tools/bin/sdkmanager "platforms;android-27"
$ yes | $ANDROID_HOME/tools/bin/sdkmanager "build-tools;27.0.3"
Are you sure that you have the correct SDK Platform installed?
If not, go to Android Studio, then Android Studio > Preferences > Appearance & Behaviour > System Settings > Android SDK. Select Android 8.1 with API Level 27 and install it.
Hope this helps.
I had the same problem, uhh spend a few hours until finally found a solution
In short:
1) Create a private gist android-sdk-license.sh with this content:
#!/bin/bash
set -ex
cd $ANDROID_HOME
mkdir -p licenses
cat << EOF >> licenses/android-sdk-license
8933bad161af4178b1185d1a37fbf41ea5269c55
d56f5187479451eabf01fb78af6dfcb131a6481e
24333f8a63b6825ea9c5514f83c2829b004d1fee
EOF
2) Get a raw link to this file
3) Create jitpack.yml in the root of your project with this content:
#!/bin/bash
before_install:
- curl PASTE_RAW_LINK_TO_GIST | sh
4) Commit & push
Hope this helps
That fixed our CI build, adding yes | before installing system image, platform and build tools.
RUN yes | sdkmanager --licenses
# update
RUN yes | sdkmanager --update
# Update SDK manager and install system image, platform and build tools
RUN yes | sdkmanager \
"tools" \
"platform-tools" \
"extras;android;m2repository" \
"extras;google;m2repository" \
"extras;google;google_play_services" \
"patcher;v4" \
"build-tools;$ANDROID_TOOLS_VERSION" \
"platforms;android-$ANDROID_BUILD_VERSION"
RUN sdkmanager --version
Reinstall sdk can solve this error. On Android studio , go to Tool > SDK manager uninstall that sdk and install it again.
To get rid of this error, close android studio and then run android studio again but this time, run as administrator

The "android" command is deprecated. How to update sdk using terminal

Im using ec2 instance which is Centos 7. Meaning I'm only using terminal not android studio. So I am trying to update my sdk using the command
echo yes | ./android update sdk --all --filter build-tools-26.0.1 --no-ui --force
But it says that:
*************************************************************************
The "android" command is deprecated.
For manual SDK, AVD, and project management, please use Android Studio.
For command-line tools, use tools/bin/sdkmanager and tools/bin/avdmanager
*************************************************************************
How do i convert the code above using the sdkmanager command? Thanks!
sdkmanager --update seems to work for me.
<a href>Documentation</a>

How to install Android SDK Build Tools on the command line?

I want to setup the Android dev environment from command line, and encounter the following issue:
wget http://dl.google.com/android/android-sdk_r22.0.5-linux.tgz
after extract the file, run
tools/android update sdk --no-ui
However, it is too slow on running
Fetching https://dl-ssl.google.com/android/repository/addons_list-2.xml
The result is that nothing in folder build-tools, and I want is aapt and apkbuilder, since I want to build apk from command line without ant.
By default, the SDK Manager from the command line does not include the build tools in the list. They're in the "obsolete" category. To see all available downloads, use
android list sdk --all
And then to get one of the packages in that list from the command line, use:
android update sdk -u -a -t <package no.>
Where -u stands for --no-ui, -a stands for --all and -t stands for --filter.
If you need to install multiple packages do:
android update sdk -u -a -t 1,2,3,4,..,n
Where 1,2,..,n is the package number listed with the list command above
As mentioned in other answers, you can use the --filter option to limit the installed packages:
android update sdk --filter ...
The other answers don't mention that you can use constant string identifiers instead of indexes (which will change) for the filter options. This is helpful for unattended or scripted installs. Man for --filter option:
... This also accepts the identifiers returned by 'list sdk --extended'.
android list sdk --all --extended :
Packages available for installation or update: 97
----------
id: 1 or "tools"
Type: Tool
Desc: Android SDK Tools, revision 22.6.2
----------
id: 2 or "platform-tools"
Type: PlatformTool
Desc: Android SDK Platform-tools, revision 19.0.1
----------
id: 3 or "build-tools-19.0.3"
Type: BuildTool
Desc: Android SDK Build-tools, revision 19.0.3
Then you can use the string ids as the filter options to precisely specify the versions you want:
android update sdk --filter tools,platform-tools,build-tools-19.0.3 etc
Version 25.2.3 (and higher) of Android SDK Tools package contains new tool - sdkmanager - which simplifies this task of installing build-tools from the command line.
It is located in android_sdk/tools/bin folder.
Usage (from documentation):
List installed and available packages:
sdkmanager --list [options] \
[--channel=channel_id] // Channels: 0 (stable), 1 (beta), 2 (dev), or 3 (canary)
Use the channel option to include a package from a channel up to and including channel_id. For example, specify the canary channel to list packages from all channels.
Install packages:
sdkmanager packages [options]
The packages argument is an SDK-style path, wrapped in quotes (for
example, "build-tools;25.0.0" or "platforms;android-25"). You can
pass multiple package paths, separated with a space, but they must
each be wrapped in their own set of quotes.
Example usage (on my Mac):
alex#mbpro:~/sdk/tools/bin$ ls ../../build-tools/
25.0.0/
alex#mbpro:~/sdk/tools/bin$ ./sdkmanager "build-tools;25.0.2"
done
alex#mbpro:~/sdk/tools/bin$ ls ../../build-tools/
25.0.0/ 25.0.2/
You can also specify various options, for example to force all connections to use HTTP (--no_https), or in order to use proxy server (--proxy_host=address and --proxy_port=port).
To check the available options, use the --help flag. On my machine (Mac), the output is as following:
alex#mbpro:~/sdk/tools/bin$ ./sdkmanager --help
Usage:
sdkmanager [--uninstall] [<common args>] \
[--package_file <package-file>] [<packages>...]
sdkmanager --update [<common args>]
sdkmanager --list [<common args>]
In its first form, installs, or uninstalls, or updates packages.
<package> is a sdk-style path (e.g. "build-tools;23.0.0" or
"platforms;android-23").
<package-file> is a text file where each line is a sdk-style path
of a package to install or uninstall.
Multiple --package_file arguments may be specified in combination
with explicit paths.
In its second form (with --update), currently installed packages are
updated to the latest version.
In its third form, all installed and available packages are printed out.
Common Arguments:
--sdk_root=<sdkRootPath>: Use the specified SDK root instead of the SDK containing this tool
--channel=<channelId>: Include packages in channels up to <channelId>.
Common channels are:
0 (Stable), 1 (Beta), 2 (Dev), and 3 (Canary).
--include_obsolete: With --list, show obsolete packages in the
package listing. With --update, update obsolete
packages as well as non-obsolete.
--no_https: Force all connections to use http rather than https.
--proxy=<http | socks>: Connect via a proxy of the given type.
--proxy_host=<IP or DNS address>: IP or DNS address of the proxy to use.
--proxy_port=<port #>: Proxy port to connect to.
* If the env var REPO_OS_OVERRIDE is set to "windows",
"macosx", or "linux", packages will be downloaded for that OS.
ADB Build-Tools Will Not be downloaded automatically, by command android update sdk --no-ui
So for installing Buil-Tool type (in console):
android list sdk --all
Remember the number that is listed before the item and execute the following:
android update sdk -u --all --filter <number>
commands should be typed in /YourFolder/android-sdk-linux/tools
Also for remote folder (server opened by ssh for example) type:
**./android** list sdk --all
**./android** update sdk -u --all --filter <number>
For simple list of ADB packages type in terminal:
android list sdk
for install all packages:
android update sdk --no-ui
Or with filters (comma is separator):
android update sdk --no-ui --filter 3,5,8,14
A great source of information I came across while trying to install everything Android SDK related from the command line, was this Dockerfile. Inside the Dockerfile you can see that the author executes a single command to install platform tools and build tools without any other interaction. In the case the OP has put forth, the command would be adapted to:
echo y | $ANDROID_HOME/tools/android update sdk --all --filter build-tools-21.1.0 --no-ui
If you have sdkmanager installed (I'm using MAC)
run sdkmanager --list to list available packages.
If you want to install build tools, copy the preferred version from the list of packages available.
To install the preferred version run
sdkmanager "build-tools;27.0.3"
The "android" command is deprecated.
For command-line tools, use tools/bin/sdkmanager and tools/bin/avdmanager
If you do not need Android Studio, you can download the basic Android command line tools from developer.android.com in section Command line tools only.
from CLI it should be somfing like:
curl --output sdk-tools-linux.zip https://dl.google.com/android/repository/sdk-tools-linux-4333796.zip
or
wget --output-document sdk-tools-linux.zip https://dl.google.com/android/repository/sdk-tools-linux-4333796.zip
After that just unpack the archive to the target folder
unzip sdk-tools-linux.zip
And now we can install everything you need...
./tools/bin/sdkmanager --install 'build-tools;29.0.2' 'platform-tools' 'platforms;android-29' 'tools'
You can get a complete list of packages using the command ./tools/bin/sdkmanager --list
Some packages require acceptance of the license agreement. you can accept it interactively or just pass "y" to the input stream, like this(two agreements in case):
echo -ne "y\ny" | ./tools/bin/sdkmanager --install 'system-images;android-29;default;x86_64'
And of course, for your convenience, you can export variables such as ANDROID_HOME or ANDROID_SDK_ROOT (including doing it in ~/.profile or ~/.bash_profile) or patch the PATH variable - all this is at your discretion.
Script example:
mkdir /opt/android-sdk
cd /opt/android-sdk
curl --output sdk-tools-linux.zip https://dl.google.com/android/repository/sdk-tools-linux-4333796.zip
unzip sdk-tools-linux.zip
echo -ne "y" | ./tools/bin/sdkmanager --install 'build-tools;29.0.2' 'platform-tools' 'platforms;android-29' 'tools'
Requirements:
curl(or wget) and unzip
Troubleshooting:
if you see Warning: Could not create settings, you need to have the tools directory inside the cmdline-tools directory inside the ANDROID_HOME (create it if needed with this exact name) see Android Command line tools sdkmanager always shows: Warning: Could not create settings
I just had a heck of a time getting android sdk dependencies installed via command line and since the documentation that comes with the tools and online are woefully lacking, I thought I'd post what I discovered here.
I'm working with android sdk r24.4.1 for linux. There are two commands that you can run to list the available packages:
android list sdk
and the more exhaustive:
android list sdk --all
The package numbers for specific packages differ for each command above! For example, the former lists package API 23.1 revision 3 as package #3 and the latter lists it as #29.
Now, there are two different ways to install using the android command.
tools/android update sdk --no-ui --filter <package number>
and
tools/android update sdk -u -a -t <package number>
Given that the install commands each can take the package # as a parameter, which package number do you use? After much online searching and trial and error, I discovered that
android update sdk --no-ui --filter uses the package numbers from android list sdk
and
android update sdk -u -a -t uses the package numbers from android list sdk --all
In other words - to install API 23.1 revision 3 you can do either:
android update sdk --no-ui --filter 3
or
android update sdk -u -a -t 29
Crazy, but it works.
Most of the answers seem to ignore the fact that you may need to run the update in a headless environment with no super user rights, which means the script has to answer all the y/n license prompts automatically.
Here's the example that does the trick.
FILTER=tool,platform,android-20,build-tools-20.0.0,android-19,android-19.0.1
( sleep 5 && while [ 1 ]; do sleep 1; echo y; done ) \
| android update sdk --no-ui --all \
--filter ${FILTER}
No matter how many prompts you get, all of those will be answered. This while/sleep loop looks like simulation of the yes command, and in fact it is, well almost. The problem with yes is that it floods stdout with 'y' and there is virtually no delay between sending those characters and the version I had to deal with had no timeout option of any kind. It will "pollute" stdout and the script will fail complaining about incorrect input. The solution is to put a delay between sending 'y' to stdout, and that's exactly what while/sleep combo does.
expect is not available by default on some linux distros and I had no way to install it as part of my CI scripts, so had to use the most generic solution and nothing can be more generic than simple bash script, right?
As a matter of fact, I blogged about it (NSBogan), check it out for more details here if you are interested.
However, it is too slow on running
Yes, I've had the same problem. Some of the file downloads are extremely slow (or at least they have been in the last couple of days). If you want to download everything there's not a lot you can do about that.
The result is that nothing in folder build-tools, and I want is aapt and apkbuilder, since I want to build apk from command line without ant.
Did you let it run to completion?
One thing you can do is filter the packages that are being downloaded using the -t switch.
For example:
tools/android update sdk --no-ui -t platform-tool
When I tried this the other day I got version 18.0.0 of the build tools installed. For some reason the latest version 18.0.1 is not included by this filter and the only way to get it was to install everything with the --all switch.
I prefer to put a script that install my dependencies
Something like:
#!/usr/bin/env bash
#
# Install JUST the required dependencies for the project.
# May be used for ci or other team members.
#
for I in android-25 \
build-tools-25.0.2 \
tool \
extra-android-m2repository \
extra-android-support \
extra-google-google_play_services \
extra-google-m2repository;
do echo y | android update sdk --no-ui --all --filter $I ; done
https://github.com/caipivara/android-scripts/blob/master/install-android-dependencies.sh
I just had this problem, so I finally wrote a 1 line bash dirty solution by reading and parsing the list of aviable tools :
tools/android update sdk -u -t $(android list sdk | grep 'Android SDK Build-tools' | sed 's/ *\([0-9]\+\)\-.*/\1/')
Inspired from answers by #i4niac & #Aurélien Lambert, this is what i came up with
csv_update_numbers=$(./android list sdk --all | grep 'Android SDK Build-tools' | grep -v 'Obsolete' | sed 's/\(.*\)\- A.*/\1/'|sed '/^$/d'|sed -e 's/^[ \t]*//'| tr '\n' ',')
csv_update_numbers_without_trailing_comma=${csv_update_numbers%?}
( sleep 5 && while [ 1 ]; do sleep 1; echo y; done ) \
| ./android update sdk --all -u -t $csv_update_numbers_without_trailing_comma
Explanation
get a comma separated list of numbers which are the indexes of build tools packages in the result of android list sdk --all command (Ignoring obsolete packages).
keep throwing 'y's at the terminal every few miliseconds to accept the licenses.
Download android SDK from developer.android.com (its currently a 149mb file for windows OS). It is worthy of note that android has removed the sdkmanager GUI but has a command line version of the sdkmanager in the bin folder which is located inside the tools folder.
When inside the bin folder, hold down the shift key, right click, then select open command line here.
Shift+right click >> open command line here.
When the command line opens, type sdkmanager click enter.
Then run type sdkmanager (space), double hyphen (--), type list
sdkmanager --list (this lists all the packages in the SDK manager)
Type sdkmanager (space) then package name, press enter.
Eg. sdkmanager platform-tools (press enter)
It will load licence agreement. With options (y/n). Enter y to accept and it will download the package you specified.
For more reference follow official document here
I hope this helps. :)
Build tools could not be downloaded automatically by default as Nate said in https://stackoverflow.com/a/19416222/1104031 post.
But I wrote small tool that make everything for you
I used "expect" tool as danb in https://stackoverflow.com/a/17863931/1104031 post.
You only need android-sdk and python27, expect.
This script will install all build tools, all sdks and everything you need for automated build:
import subprocess,re,sys
w = subprocess.check_output(["android", "list", "sdk", "--all"])
lines = w.split("\n")
tools = filter(lambda x: "Build-tools" in x, lines)
filters = []
for tool in tools:
m = re.search("^\s+([0-9]+)-", tool)
tool_no = m.group(1)
filters.append(tool_no)
if len(filters) == 0:
raise Exception("Not found build tools")
filters.extend(['extra', 'platform', 'platform-tool', 'tool'])
filter = ",".join(filters)
expect= '''set timeout -1;
spawn android update sdk --no-ui --all --filter %s;
expect {
"Do you accept the license" { exp_send "y\\r" ; exp_continue }
eof
}''' % (filter)
print expect
ret = subprocess.call(["expect", "-c", expect])
sys.exit(ret)
As stated in other responses, the build tools requires the --all flag to be installed. You also better use a -t filter flag to avoid installing ALL the packages but there is no way to filter all the build tools.
There are already features requests for these two points in AOSP bug tracker. Feel free to vote for them, this might make them happen some day:
https://code.google.com/p/android/issues/detail?id=78765
https://code.google.com/p/android/issues/detail?id=58337
I tried this for update all, and it worked!
echo y | $ANDROID_HOME/tools/android update sdk --no-ui
Try
1. List all packages
android list sdk --all
2. Install packages using following command
android update sdk -u -a -t package1, package2, package3 //comma seperated packages obtained using list command
android update sdk
This command will update and install all latest release for SDK Tools, Build Tools,SDK platform tools.
It's Work for me.
To setup android environment without installating the whole android studio :
Download JDK (version greater than 8)
Download gradle from https://gradle.org/install/
Download command line tools from https://developer.android.com/studio scroll down and download command line tools only
Setup the necessary environment variables
Download the necessary SDK tools

Categories

Resources