[Slove] could not initialize class com android sdklib repository androidsdkhandler

In this paragraph, Discous of could not initialize class com android sdklib repository androidsdkhandler error. Because of some days ago asking a little brother on this problem. Fastly brother asking the question below.

I am new to android development and learning from audacity nano degree That course was made in 2016. I imported an existing project and it is showing me this error[enter image description here
I am really sorry I even don’t know how to format questions on stack overflow][1] “Could not initialize class com.android.sdklib.repositoryv2.AndroidSdkHandler

could not initialize class com android sdklib repository androidsdkhandler

[Error] could not initialize class com android sdklib repository androidsdkhandler

**This is my build.Gradle file**
“`apply plugin: ‘com.android.application’

android {
compileSdkVersion 23
buildToolsVersion ‘27.0.3’

defaultConfig {
applicationId “com.example.android.miwok”
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName “1.0”
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile(‘proguard-android.txt’), ‘proguard-rules.pro’
}
}
}
dependencies {
compile fileTree(dir: ‘libs’, include: [‘*.jar’])
testCompile ‘junit:junit:4.12’
compile ‘com.android.support:appcompat-v7:23.3.0’
compile ‘com.android.support:support-v4:23.3.0’
compile ‘com.android.support:design:23.3.0’
}“`
This is my Gradle-wrapper properties

distributionPath=wrapper/dists
distributionUrl=https://services.gradle.org/distributions/gradle-4.8.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists“`

 

**This is my MainActivity file**
“`package com.example.android.miwok;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

// Set the content of the activity to use the activity_main.xml layout file
setContentView(R.layout.activity_main);

// Find the View that shows the numbers category
TextView numbers = (TextView) findViewById(R.id.numbers);

// Set a click listener on that View
numbers.setOnClickListener(new OnClickListener() {
// The code in this method will be executed when the numbers category is clicked on.
@Override
public void onClick(View view) {
// Create a new intent to open the {@link NumbersActivity}
Intent numbersIntent = new Intent(MainActivity.this, NumbersActivity.class);

// Start the new activity
startActivity(numbersIntent);
}
});

// Find the View that shows the family category
TextView family = (TextView) findViewById(R.id.family);

// Set a click listener on that View
family.setOnClickListener(new OnClickListener() {
// The code in this method will be executed when the family category is clicked on.
@Override
public void onClick(View view) {
// Create a new intent to open the {@link FamilyActivity}
Intent familyIntent = new Intent(MainActivity.this, FamilyActivity.class);

// Start the new activity
startActivity(familyIntent);
}
});

// Find the View that shows the colors category
TextView colors = (TextView) findViewById(R.id.colors);

// Set a click listener on that View
colors.setOnClickListener(new OnClickListener() {
// The code in this method will be executed when the colors category is clicked on.
@Override
public void onClick(View view) {
// Create a new intent to open the {@link ColorsActivity}
Intent colorsIntent = new Intent(MainActivity.this, ColorsActivity.class);

// Start the new activity
startActivity(colorsIntent);
}
});

// Find the View that shows the phrases category
TextView phrases = (TextView) findViewById(R.id.phrases);

// Set a click listener on that View
phrases.setOnClickListener(new OnClickListener() {
// The code in this method will be executed when the phrases category is clicked on.
@Override
public void onClick(View view) {
// Create a new intent to open the {@link PhrasesActivity}
Intent phrasesIntent = new Intent(MainActivity.this, PhrasesActivity.class);

// Start the new activity
startActivity(phrasesIntent);
}
});
}
}“`

 

 

**This is my manifest**
“`<?xml version=”1.0″ encoding=”utf-8″?>
<manifest xmlns:android=”http://schemas.android.com/apk/res/android”
package=”com.example.android.miwok”>
<application
android:allowBackup=”true”
android:icon=”@mipmap/ic_launcher”
android:label=”@string/app_name”
android:supportsRtl=”true”
android:theme=”@style/AppTheme”>
<activity android:name=”.MainActivity”>
<intent-filter>
<action android:name=”android.intent.action.MAIN” />

<category android:name=”android.intent.category.LAUNCHER” />
</intent-filter>
</activity>
<activity
android:name=”.NumbersActivity”
android:label=”@string/category_numbers”
android:parentActivityName=”.MainActivity”>
<!– Parent activity meta-data to support 4.0 and lower –>
<meta-data
android:name=”android.support.PARENT_ACTIVITY”
android:value=”.MainActivity”/>
</activity>
<activity
android:name=”.FamilyActivity”
android:label=”@string/category_family”
android:parentActivityName=”.MainActivity”>
<!– Parent activity meta-data to support 4.0 and lower –>
<meta-data
android:name=”android.support.PARENT_ACTIVITY”
android:value=”.MainActivity”/>
</activity>
<activity
android:name=”.ColorsActivity”
android:label=”@string/category_colors”
android:parentActivityName=”.MainActivity”>
<!– Parent activity meta-data to support 4.0 and lower –>
<meta-data
android:name=”android.support.PARENT_ACTIVITY”
android:value=”.MainActivity”/>
</activity>
<activity
android:name=”.PhrasesActivity”
android:label=”@string/category_phrases”
android:parentActivityName=”.MainActivity”>
<!– Parent activity meta-data to support 4.0 and lower –>
<meta-data
android:name=”android.support.PARENT_ACTIVITY”
android:value=”.MainActivity”/>
</activity>
</application>
</manifest>“`

How to solve could not initialize class com android sdklib repository androidsdkhandler

Answer: This is because your classpath build tools in build. Gradle root project is deprecated. Update it like this

buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
classpath ‘com.android.tools.build:gradle:7.0.0’
}
}

check more: https://stackoverflow.com/questions/46917365/error-could-not-initialize-class-com-android-sdklib-repository-androidsdkhandle

Author Details

admin photo

sobuj033@gmail.com

Sobuj Ali

Founder & CEO

Sobuj Ali is Founder & CEO at Apkpm.com. I have a good knowledge of Marketing. So I provide all Technology information on their website.

Leave a Reply

Your email address will not be published.

Your Rating: