Error Logs, Issues And Solutions For Android Studio IDE - Tech Projects/Documentations
image

Error Logs, Issues And Solutions For Android Studio IDE

This article will be kept up to date with errors and solutions encountered while working with the android studio IDE. Original authors and help links will be referenced accordingly.

Author: Eze-Odikwa Tochukwu Jed

Error (Java):

> Failed to transform file 'RootTools.jar' to match attributes {artifactType=android-classes} using transform JarTransform
> Transform output file C:\Users\spider\Desktop\PROJECTS\rootchecker\app\Users\jiteshdugar\Sites\rootchecker\libs\RootTools.jar does not exist.


> Failed to transform file 'RootTools.jar' to match attributes {artifactType=android-classes} using transform JarTransform
> Transform output file C:\Users> Failed to transform file 'RootTools.jar' to match attributes {artifactType=android-classes} using transform JarTransform
> Transform output file C:\Users\.jar does not exist.


Solution:

The storage directory is not dynamic so we located the jar file to the correct directory

on Users/spider/Desktop/PROJECTS/rootchecker

The transform directory will be

/Users/spider/Desktop/PROJECTS/rootchecker/libs/RootTools.jar  

Moved libs to new folder.

This error occurs while working with project files structures from older projects like eclipse IDE and outdated android studio versions.

Error (Java):

Execution failed for task ':app:javaPreCompileDebug'.
> Annotation processors must be explicitly declared now. The following dependencies on the compile classpath are found to contain annotation processor. Please add them to the annotationProcessor configuration.

Solution:

Add this code to build gradle module app

android{
    
    defaultConfig{
        
        javaCompileOptions {
            annotationProcessorOptions {
                includeCompileClasspath true
            }
        }
    }
    buildTypes {
        
    }

Error (Java):

com.android.build.api.transform.TransformException: com.android.builder.dexing.DexArchiveBuilderException: com.android.builder.dexing.DexArchiveBuilderException: Failed to process .jar

Solution:

Add this piece of code to your build.gradle to change the source compatibility version

{

    compileOptions {

        sourceCompatibility 1.8

        targetCompatibility 1.8

    } 

Error (Java):

No matching client found for package name 'com.tochycomputerservices.rootcheck

Solution:

Add or create a firebase .json file

Error (Java):

The SourceSet 'instrumentTest' is not recognized by the Android Gradle Plugin

Solution:

Replace ‘instrumentTest’ with ‘androidTest’

Error (Java):

java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details

Solution:

You will need to upgrade class path of your project in build.gradle e.g.

buildscript {
    repositories {
        mavenCentral()
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.1'
    }
}

repositories {
    google()
}

Error (Java):

A problem occurred configuring project ':app'.
> Removing unused resources requires unused code shrinking to be turned on.

Solution:

Enable code/resource shrinking

What is code shrinking?

To make your app as small as possible, you should enable shrinking in your release build to remove unused code and resources. When you enable shrinking, you also benefit from obfuscation, which shortens the names of your app’s classes and members, and optimization, which applies more aggressive strategies to further reduce the size of your app.

Resource shrinking works only in conjunction with code shrinking. After the code shrinker removes all unused code, the resource shrinker can identify which resources the app still uses.

Reference: developer.android.com/studio/build/shrink-code

Add the following code to your build.gradle to enable resource shrinking:

enable minify = true
android {
    ...
    buildTypes {
        release {
            shrinkResources true
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'),
                    'proguard-rules.pro'
        }
    }
}

Error (Java):

Caused by: org.gradle.api.internal.artifacts.ivyservice.DefaultLenientConfiguration$ArtifactResolveException: 
Could not resolve all files for configuration ':app:debugRuntimeClasspath'.


Caused by: org.gradle.api.resources.ResourceException: Could not get resource


Caused by: org.gradle.internal.resource.transport.http.HttpErrorStatusCodeException: 
Could not GET 'https://jitpack.io/com/github/glomadrian/MaterialAnimatedSwitch/1.1/MaterialAnimatedSwitch-1.1.pom'. 
Received status code 401 from server: Unauthorized

Possible Solution:

In properties file set the dist url to

distributionUrl=https\://services.gradle.org/distributions/gradle-4.8-all.zip

And in build.gradle set the class path to

classpath 'com.android.tools.build:gradle:3.0.1'

Error (Java):

Android resource compilation failed 6:13: AAPT: error: invalid parent reference 'style/Widget.AppCompat.Light.ActionBar.Solid.Inverse'.

Solution:

<style name="MyActionBar" parent="@android:style/Widget.Holo.Light.ActionBar.Solid.Inverse">

Error (Java):

Unsupported Java. 
Your build is currently configured to use Java 11.0.13. It's recommended to use Gradle 4.8 or newer.

Solution:

Change class path in build.gradle to

classpath 'com.android.tools.build:gradle:4.0.1'

Change dist Url in properties file to

distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip

Error (Java):

A problem occurred configuring root project 'gas flow calculator'.
> Could not resolve all artifacts for configuration ':classpath'.
   > Could not find com.android.tools.build:gradle:4.0.1.
     Searched in the following locations:

Solution:

This happens when importing open source projects, create a new build.gradle file and set the class path to

classpath 'com.android.tools.build:gradle:4.0.1'

Error (Java):

cvc-complex-type.2.4.a: Invalid content was found starting with element 'base-extension'. One of '{codename, tag}' is expected.

Solution:

Delete .idea folder, reimport the project and change gradle settings

Error (Java):

import android.support.annotation.CallSuper;


error: package android.support.annotation does not exist
import android.support.annotation.CallSuper;

Solution:

If you are refactoring or upgrading your project check

github.com/JakeWharton/butterknife

upgrade butterknife dependencies to:

implementation 'com.jakewharton:butterknife:10.2.3'
    annotationProcessor 'com.jakewharton:butterknife-compiler:10.2.3'

Fix the rest in necessary places:

buildscript {
  repositories {
    mavenCentral()
    google()
  }
  dependencies {
    classpath 'com.jakewharton:butterknife-gradle-plugin:10.2.3'
  }
}
apply plugin: 'com.android.library'
apply plugin: 'com.jakewharton.butterknife'

Error (Java):

Logcat output:

java.lang.NoSuchMethodError: No static method metafactory(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodHandle;Ljava/lang/invoke/MethodType;)Ljava/lang/invoke/CallSite; in class Ljava/lang/invoke/LambdaMetafactory; or its super classes (declaration of 'java.lang.invoke.LambdaMetafactory' appears in /apex/com.android.runtime/javalib/core-oj.jar)
        at butterknife.Unbinder.<clinit>(Unbinder.java:9)
        at butterknife.ButterKnife.bind(ButterKnife.java:165)
        at com.example.createpdf.fragment.HomeFragment.onCreateView(HomeFragment.java:81)
        at androidx.fragment.app.Fragment.performCreateView(Fragment.java:2439)
        at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManager.java:1460)
        at androidx.fragment.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1784)
        at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManager.java:1852)
        at androidx.fragment.app.BackStackRecord.executeOps(BackStackRecord.java:802)
        at androidx.fragment.app.FragmentManagerImpl.executeOps(FragmentManager.java:2625)
        at androidx.fragment.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2411)
        at androidx.fragment.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManager.java:2366)
        at androidx.fragment.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2273)
        at androidx.fragment.app.FragmentManagerImpl.dispatchStateChange(FragmentManager.java:3273)
        at androidx.fragment.app.FragmentManagerImpl.dispatchActivityCreated(FragmentManager.java:3229)
        at androidx.fragment.app.FragmentController.dispatchActivityCreated(FragmentController.java:201)
        at androidx.fragment.app.FragmentActivity.onStart(FragmentActivity.java:620)
        at androidx.appcompat.app.AppCompatActivity.onStart(AppCompatActivity.java:178)
        at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1433)
        at android.app.Activity.performStart(Activity.java:7978)
        at android.app.ActivityThread.handleStartActivity(ActivityThread.java:3512)
        at android.app.servertransaction.TransactionExecutor.performLifecycleSequence(TransactionExecutor.java:221)
        at android.app.servertransaction.TransactionExecutor.cycleToPath(TransactionExecutor.java:201)
        at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:173)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2175)
        at android.os.Handler.dispatchMessage(Handler.java:107)
        at android.os.Looper.loop(Looper.java:237)
        at android.app.ActivityThread.main(ActivityThread.java:7860)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1075)

Solution:

Change source compatibility version in build.gradle

android {

    ...
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

Error (Java):

Compiler output:

Could not resolve all artifacts for configuration ':app:classpath'.
   > Could not resolve com.crashlytics.tools.gradle:crashlytics-gradle:1.+.
     Required by:
         project :app
      > Failed to list versions for com.crashlytics.tools.gradle:crashlytics-gradle.

Event logger:

Gradle sync failed: Cause: invalid type code: 00 (602 ms)

Solution:

Change maven repository

buildscript {
    repositories {
        maven { url 'https://maven.fabric.io/public' }
    }

    dependencies {
        classpath 'io.fabric.tools:gradle:1.31.1'
    }
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'

repositories {
    maven { url 'https://maven.fabric.io/public' }
}

Error (Java):

Cannot create directory app\build\outputs\apk\debug

Solution:

Put this piece of code in build.gradle (project app)

applicationVariants.all { variant ->
    variant.outputs.all {
        outputFileName = "${variant.name}-${variant.versionName}.apk"
    }
}

Error (Java):

Gradle sync failed: Unable to determine constructor argument #1: missing parameter of type Factory,
 or no service of type Factory<LoggingManagerInternal>.

Solution:

Set the class path build gradle project to

classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'

leave your comment


Your email address will not be published. Required fields are marked *

Uploading