Could not find target with hash string "android-25", although android-25 is actually installed

I have an Ubuntu Xenial VM running on OpenStack, where I downloaded the latest Android SDK tools ( tools_r25.2.3-linux.zip ) from https://developer.android.com/studio/index.html . And everything is well configured:

  • JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
  • ANDROID_HOME=<ANDROID_SDK_PATH>
  • PATH=${PATH}:${ANDROID_HOME}
  • echo "sdk.dir=<ANDROID_SDK_PATH>" > <MY_ANDROID_PROJECT_PATH>/local.properties

But when you try to complete the task: ./gradlew clean an error occurs:

 Preparing "Install Android SDK Build-Tools 25". Warning: Trying to install into ${ANDROID_HOME}/build-tools/25.0.0/ but package "Android SDK Tools 25.2.4" already exists at ${ANDROID_HOME}. It must be deleted or moved away before installing into a child directory. Preparing "Install Android SDK Platform 25". Warning: Trying to install into ${ANDROID_HOME}/platforms/android-25/ but package "Android SDK Tools 25.2.4" already exists at ${ANDROID_HOME}. It must be deleted or moved away before installing into a child directory. FAILURE: Build failed with an exception. * What went wrong: A problem occurred configuring project ':demo'. > Failed to install the following SDK components: [Android SDK Build-Tools 25, Android SDK Platform 25] Please install the missing components using the SDK manager in Android Studio. 

And actually, as the error log mentions, I have the necessary tools installed. Running $ANDROID_HOME/bin/sdkmanager --list shows my installed packages:

 Installed packages: Path | Version | Description | Location ------- | ------- | ------- | ------- build-tools;25.0.0 | 25.0.0 | Android SDK Build-Tools 25 | build-tools/25.0.0/ extras;android;m2repository | 41.0.0 | Android Support Repository, re... | extras/android/m2repository/ platform-tools | 25.0.2 | Android SDK Platform-Tools 25.0.2 | platform-tools/ platforms;android-25 | 3 | Android SDK Platform 25, rev 3 | platforms/android-25/ tools | 25.2.4 | Android SDK Tools 25.2.4 | tools/ 

What could be wrong here? I am a little suspicious of the SDK path.

+5
source share
2 answers

Just confirmed my assumptions - this is due to a new change in the latest version of the Android SDK.

Sincerely, we have a time machine, so that we can return to what exactly happened (cannot find any remark from the SDK Tools Release Note ).

Let's look at the ANDROID_HOME file structures before and after the change.

Before

 android-sdk-linux ├── SDK Readme.txt ├── add-ons (empty) ├── platforms (empty) └── tools ├── a bunch of preloaded tools ├── ... └── ... 

After :

 tools ├── a bunch of preloaded tools ├── ... └── ... 

More add-ons or platforms , but only tools as the new root directory.

Problem : Gradle will be confusing if you install $ANDROID_HOME directly in the unpacked topmost tools directory.

Solution . After unpacking the new SDK file (you will get the tools directory), create another directory (for example, android-sdk ) and completely move the tools directory inside empty android-sdk , then set the environment variables as:

 ANDROID_HOME=/android-sdk PATH=${PATH}:${ANDROID_HOME}/tools 

In short: DO NOT FIND install $ANDROID_HOME directly in the parent directory of tools , wrap it inside another parent!

+8
source

I used Invalidate catch / Restart in my android studio. It worked for me.

0
source

Source: https://habr.com/ru/post/1261412/


All Articles