3

I am new to android studio and have no idea that why the Gradle Sync failed. I have tried below but all not working. 1. Rebuild project 2. Invalidate Caches / Restart 3. Re-install android studio 4. 58024814

According to Varo, I relocated my project file and .gradle to directory without space, but the gradle sync still failed.

Below failure codes are shown in build log

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project 'ChallengeWorld'.
> Could not open cp_proj remapped class cache for 6a7ectjlwa2vyu71qapalegwc (C:\myproject\ChallengeWorld\.gradle\caches\5.6.3\scripts-remapped\build_57lai3g6jtw8m4zpsw9v3eiox\6a7ectjlwa2vyu71qapalegwc\cp_proje8f5fda85dd1862799137f889c6c1788).
   > Could not open cp_proj generic class cache for build file 'C:\myproject\ChallengeWorld\build.gradle' (C:\myproject\ChallengeWorld\.gradle\caches\5.6.3\scripts\6a7ectjlwa2vyu71qapalegwc\cp_proj\cp_proje8f5fda85dd1862799137f889c6c1788).
      > Build file 'C:\myproject\ChallengeWorld\build.gradle' should not contain a package statement.

project build.gradle

package com.blab.challengeworld;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.Spinner;
import android.widget.Toast;

import com.blab.challengeworld.DB.ChallengeDB;
import com.blab.challengeworld.spinner.CountAdapter;
import com.blab.challengeworld.spinner.CountItemSpinner;

project file build.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 29
    buildToolsVersion "29.0.3"

    defaultConfig {
        applicationId "com.blab.challengeworld"
        minSdkVersion 15
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }

}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])

    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}

Event log

Gradle sync failed: Build file 'C:\myproject\ChallengeWorld\build.gradle' should not contain a package statement.

In the welcome page, IDE fatal error is shown: Exception in Studio Core.

Unable to serialize DslActivationStatus state

com.intellij.util.xmlb.XmlSerializationException: Can't serialize instance of class org.jetbrains.plugins.groovy.dsl.DslActivationStatus$State
    at com.intellij.configurationStore.JdomSerializerImpl.serialize(xmlSerializer.kt:58)
    at com.intellij.configurationStore.XmlSerializer.serialize(xmlSerializer.kt:19)
    at com.intellij.configurationStore.XmlSerializer.serialize$default(xmlSerializer.kt:18)
    at com.intellij.configurationStore.SaveSessionBaseKt.serializeState(SaveSessionBase.kt:46)
    at com.intellij.configurationStore.SaveSessionBase.setState(SaveSessionBase.kt:20)
    at com.intellij.configurationStore.ComponentStoreImpl.setStateToSaveSessionProducer(ComponentStoreImpl.kt:310)
    at com.intellij.configurationStore.ComponentStoreImpl.commitComponent(ComponentStoreImpl.kt:303)
    at com.intellij.configurationStore.ComponentStoreImpl.commitComponents$intellij_platform_configurationStore_impl(ComponentStoreImpl.kt:206)
    at com.intellij.configurationStore.ComponentStoreWithExtraComponents.commitComponents$intellij_platform_configurationStore_impl(ComponentStoreWithExtraComponents.kt:88)
    at com.intellij.configurationStore.ComponentStoreImpl.doCreateSaveSessionManagerAndCommitComponents$intellij_platform_configurationStore_impl(ComponentStoreImpl.kt:158)
    at com.intellij.configurationStore.ComponentStoreImpl$createSaveSessionManagerAndSaveComponents$$inlined$withEdtContext$intellij_platform_configurationStore_impl$1.invokeSuspend(ComponentStoreImpl.kt:645)
    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
    at kotlinx.coroutines.DispatchedTask.run(Dispatched.kt:238)
    at com.intellij.configurationStore.EdtPoolDispatcherManager.processQueue(EdtPoolDispatcher.kt:57)
    at com.intellij.configurationStore.EdtPoolDispatcherManager.access$processQueue(EdtPoolDispatcher.kt:21)
    at com.intellij.configurationStore.EdtPoolDispatcherManager$scheduleFlush$1.invoke(EdtPoolDispatcher.kt:35)
    at com.intellij.configurationStore.EdtPoolDispatcherManager$scheduleFlush$1.invoke(EdtPoolDispatcher.kt:21)
    at com.intellij.configurationStore.EdtPoolDispatcherKt$sam$java_lang_Runnable$0.run(EdtPoolDispatcher.kt)
    at com.intellij.openapi.application.TransactionGuardImpl$2.run(TransactionGuardImpl.java:312)
    at com.intellij.openapi.application.impl.LaterInvocator$FlushQueue.doRun(LaterInvocator.java:433)
    at com.intellij.openapi.application.impl.LaterInvocator$FlushQueue.runNextEvent(LaterInvocator.java:416)
    at com.intellij.openapi.application.impl.LaterInvocator$FlushQueue.run(LaterInvocator.java:399)
    at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:764)
    at java.awt.EventQueue.access$500(EventQueue.java:98)
    at java.awt.EventQueue$3.run(EventQueue.java:715)
    at java.awt.EventQueue$3.run(EventQueue.java:709)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:734)
    at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:878)
    at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:827)
    at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$8(IdeEventQueue.java:466)
    at com.intellij.openapi.progress.impl.CoreProgressManager.computePrioritized(CoreProgressManager.java:704)
    at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:465)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:205)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
Caused by: org.jdom.IllegalDataException: The data "org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
categoryTransformgdsl: 1: unexpected char: 0x0 @ line 1, column 5.
   ����
Ray
  • 31
  • 3

2 Answers2

0

I'm not an expert, but I do know that Graddle don't get along well with directories with spaces, so I think you should try these:

  1. Try moving your project to a directory without spaces or special characters on its name, such as "C:\MyProject".
  2. Clean Gradle: Android Studio -> Build -> Clean Project

I really hope this will work :)

arialdev
  • 51
  • 2
  • 6
0

I tried method 4 to replace the project build.gadle using notepad and sycn success.

Ray
  • 31
  • 3