0

I'm working with Android Studio version 3.5.3. The problem is when I want to create project with Java, I have the Error for Failing to resolve fragment and the same error for Activity. But I don't have the problem when I create project with Kotlin. you can see the Gradle file below.

Project Gradle

buildscript {
    repositories {
        google()
        jcenter()
        mavenCentral()
    }
    dependencies {
         classpath 'com.android.tools.build:gradle:3.5.3'
    }
}
allprojects {
    repositories {
        google()
        jcenter()
        mavenCentral()
    }
}
task clean(type: Delete) {
     delete rootProject.buildDir
}

App Module Gradle

apply plugin: 'com.android.application'
android {
      compileSdkVersion 29
      buildToolsVersion "29.0.2"
      defaultConfig {
            applicationId "com.example.myapplication"
            minSdkVersion 15
            targetSdkVersion 29
            versionCode 1
            versionName "1.0"
            testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
      }
      buildTypes {
            release {
                 minifyEnabled false
                 proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
            }
      }
}
dependencies {
        implementation fileTree(dir: 'libs', include: ['*.jar'])
        implementation 'androidx.appcompat:appcompat:1.1.0'
        implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
        testImplementation 'junit:junit:4.12'
        androidTestImplementation 'androidx.test.ext:junit:1.1.1'
        androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}

there is the error Log.

enter image description here

Yoshimitsu
  • 4,343
  • 2
  • 22
  • 28

1 Answers1

2

I've solved my problem by updating the Gradle version from 5.4.1 to 6.0.1. By the way, It should work with the previous Gradle version base on Google Document. But it has a problem with Java application.

You can find plugin version Android studio with the required Gradle version in this image.

enter image description here

Yoshimitsu
  • 4,343
  • 2
  • 22
  • 28